def main(args): m = 100 img = im_to_arr(args[0]) m = max(0, min(m, 255)) inv = bound(img + m) inv = Image.fromarray(inv.astype(np.uint8)) inv.show()
def main(args): img = im_to_arr(args[0]) thresholded = threshold(img, 90) projection = np.zeros( (thresholded.shape[0] + 32, thresholded.shape[1] + 32)) projection[32:, 32:] = thresholded projection = np.repeat(projection, 3).reshape( (projection.shape[0], projection.shape[1], 3)) projection[30:32, :] = (0, 0, 200) projection[:, 30:32] = (0, 0, 200) for x in range(thresholded.shape[0]): sum_in_row = np.sum(thresholded[x, :]) white_ratio = sum_in_row / thresholded.shape[1] / 255 stretched = int(round(30 * white_ratio)) for p in range(stretched, -1, -1): projection[x + 32, p] = (255, 0, 0) for x in range(thresholded.shape[1]): sum_in_col = np.sum(thresholded[:, x]) white_ratio = sum_in_col / thresholded.shape[0] / 255 stretched = int(round(30 * white_ratio)) for p in range(stretched, -1, -1): projection[p, x + 32] = (255, 0, 0) projection = Image.fromarray(projection.astype(np.uint8)) projection.show()
def main(args): img = im_to_arr(args[0]) avg = applyFilter(img, averaging) avg = Image.fromarray(avg.astype(np.uint8)) avg.show() ga = applyFilter(img, gauss) ga = Image.fromarray(ga.astype(np.uint8)) ga.show() sha = applyFilter(img, sharpening) sha = Image.fromarray(sha.astype(np.uint8)) sha.show() rob = roberts_filter(img) rob = Image.fromarray(rob.astype(np.uint8)) rob.show() sobel = sobel_filter(img) sobel = Image.fromarray(sobel.astype(np.uint8)) sobel.show() img = Image.fromarray(img.astype(np.uint8)) img.show()
def main(args): img = im_to_arr(args[0]) wei, avg = conv_gray(img) wei = Image.fromarray(wei) avg = Image.fromarray(avg) wei.show() avg.show()
def main(args): img = im_to_arr(args[0]) thresholded = threshold(img) thresholded = Image.fromarray(thresholded.astype(np.uint8)) thresholded.show()
def main(args): img = im_to_arr(args[0]) r_lut = bound(np.array(range(0, 256)) + 50) g_lut = bound(np.array(range(0, 256)) + 40) b_lut = bound(np.array(range(0, 256)) - 100) img[:, :, 0] = lut_mainp(img[:, :, 2], r_lut) img[:, :, 1] = lut_mainp(img[:, :, 2], g_lut) img[:, :, 2] = lut_mainp(img[:, :, 2], b_lut) img = Image.fromarray(img.astype(np.uint8)) img.show()
def main(args): img = im_to_arr(args[0]) r_channel = img[:, :, 0] g_channel = img[:, :, 1] b_channel = img[:, :, 2] expanded = np.zeros_like(img) expanded[:, :, 0] = expand_hist(r_channel) expanded[:, :, 1] = expand_hist(g_channel) expanded[:, :, 2] = expand_hist(b_channel) Image.fromarray(img.astype(np.uint8)).show(title='original image') Image.fromarray(expanded.astype(np.uint8)).show(title='histogram expanded') print_hist_img([img, expanded])
def main(args): factor = 8 img = im_to_arr(args[0]) ce = bound(((img / 255 - 0.5) * factor + 0.5) * 255) ce = Image.fromarray(ce.astype(np.uint8)) ce.show()