def _read_jpg(): dumm = glob.glob('/Users/HANEL/Desktop/' + '*.png') print(len(dumm)) filename_queue = tf.train.string_input_producer(dumm) # filename_queue = tf.train.string_input_producer(['/Users/HANEL/Desktop/tf.png', '/Users/HANEL/Desktop/ft.png']) reader = tf.WholeFileReader() key, value = reader.read(filename_queue) my_img = tf.image.decode_png(value) # my_img_flip = tf.image.flip_up_down(my_img) init_op = tf.initialize_all_variables() with tf.Session() as sess: sess.run(init_op) # Start populating the filename queue. coord = tf.train.Coordinator() threads = tf.train.start_queue_runners(coord=coord) for i in range(1): gunel = my_img.eval() print(gunel.shape) Image._showxv(Image.fromarray(np.asarray(gunel))) coord.request_stop() coord.join(threads)
def test_showxv_deprecation(self): class TestViewer(ImageShow.Viewer): def show_image(self, image, **options): return True viewer = TestViewer() ImageShow.register(viewer, -1) im = Image.new("RGB", (50, 50), "white") with pytest.warns(DeprecationWarning): Image._showxv(im) # Restore original state ImageShow._viewers.pop(0)
r1 = (i - center1) * 2 + (j - center2) * 2 # euclidean distancefrom origin r = math.sqrt(r1) # using cut_off radius to eliminate high freq # if r > d_0: # for ideal low pass # H[i, j] = 0.0 # for butterworth low pass # H[i, j] = 1 / (1 + (r / d_0) ** t1) # for Gaussian low pass # H[i, j] = math.exp(-r * 2 / t1 * 2) if 0 < r < d_0: # for ideal high pass # H[i, j] = 1.0 # for butterworth high pass filter H[i, j] = 1 / (1 + (d_0 / r)**t1) # for gaussian high pass # H[i, j] = 1 - math.exp(-r * 2 / t1 * 2) # # converting H to image H = Image.fromarray(H) # performing convolution con = d * H # computing mag of inverse FFT e = abs(fftim.ifft2(con)) # from array to image f = Image.fromarray(e) Image._showxv(f, " lowpass filter")
def showImg(save_path): Image._showxv(Image.open(save_path), 'Generated QrCode')
from img_preprocess import grayscale_avg from sobel_filter import sobel_filter_horizontal from sobel_filter import sobel_filter_vertical from sobel_filter import sobel_filter from gaussian_filter import gaussian_filter from laplacian_of_gaussian_filter import log_filter from PIL import Image import numpy as np # read the RGB images img = Image.open('data/checkerbox.jpg') # converts the input image to np.array of 3 dimensions (height, width, 3) where 3 stands for RGB channels Image._showxv(img,title="original") img_gray = grayscale_avg(np.asarray(img)) # converts the input image to gayscale using average method # Image._show(Image.fromarray(img_gray),title="grayscaled") # Image._show(Image.fromarray(gaussian_filter(img_gray)),title="gaussian filter") # Image._show(Image.fromarray(sobel_filter_vertical(img_gray)),title="sobel vertical filter") # Image._show(Image.fromarray(sobel_filter_horizontal(img_gray)),title="sobel horizontal filter") Image._show(Image.fromarray(sobel_filter(img_gray)),title="sobel filter") Image._show(Image.fromarray(log_filter(img_gray)),title="log filter")