python-imageio

How to resize an image using imageio?

断了今生、忘了曾经 提交于 2021-02-11 12:32:30
问题 Consider an image img of type imageio.core.util.Array . The shape of img is (256, 256, 3) . I want to resize it to (128, 128, 3) . I tried at least the following three: img.resize(img_res, pilmode="RGB") img.resize(img_res) img = cv2.resize(img, self.img_res) Here img_res = (128, 128) . None of them worked well. How can I resize my image to the desired size? 回答1: According to the documentation on imageio.core.util.Array, Array is "a subclass of np.ndarray [...]". Thus, when calling resize on

“float” object cannot be interpreted as an integer while reading the frame

一曲冷凌霜 提交于 2021-01-29 01:35:36
问题 I am trying to read the frames using imageio API. I have a reader as an object which I have received using imageio.get_reader(video_path,"ffmpeg") . I have the following frame reader function def read_frames(reader, frame_q, use_webcam): if use_webcam: time.sleep(15) frame_cnt = 0 while True: #if frame_cnt % 5 == 0: # ret, frame = reader.read() # cur_img = frame[:,:,::-1] # frame_q.put(cur_img) #else: # ret, frame = reader.read() ret, frame = reader.read() cur_img = frame[:,:,::-1] # bgr to

“float” object cannot be interpreted as an integer while reading the frame

ぃ、小莉子 提交于 2021-01-29 01:35:19
问题 I am trying to read the frames using imageio API. I have a reader as an object which I have received using imageio.get_reader(video_path,"ffmpeg") . I have the following frame reader function def read_frames(reader, frame_q, use_webcam): if use_webcam: time.sleep(15) frame_cnt = 0 while True: #if frame_cnt % 5 == 0: # ret, frame = reader.read() # cur_img = frame[:,:,::-1] # frame_q.put(cur_img) #else: # ret, frame = reader.read() ret, frame = reader.read() cur_img = frame[:,:,::-1] # bgr to

“float” object cannot be interpreted as an integer while reading the frame

喜你入骨 提交于 2021-01-29 01:35:05
问题 I am trying to read the frames using imageio API. I have a reader as an object which I have received using imageio.get_reader(video_path,"ffmpeg") . I have the following frame reader function def read_frames(reader, frame_q, use_webcam): if use_webcam: time.sleep(15) frame_cnt = 0 while True: #if frame_cnt % 5 == 0: # ret, frame = reader.read() # cur_img = frame[:,:,::-1] # frame_q.put(cur_img) #else: # ret, frame = reader.read() ret, frame = reader.read() cur_img = frame[:,:,::-1] # bgr to

How to Create .fits file from numpy array

泪湿孤枕 提交于 2020-01-06 07:01:08
问题 I am currently trying to convert a .cr2 into .fits file. I am currently unable to create .fits as any file I create doesn't open or work because of the wrong shape of fits. I have tried using the solution Write 3d Numpy array to FITS file with Astropy but, still, it doesn't work. import numpy as np from astropy.io import fits im = imageio.imread(r'E:\FYP\cr.cr2', format="RAW-FI") a = np.array(im) print (a.shape) hdu = fits.PrimaryHDU(a) hdulist = fits.HDUList([hdu]) hdulist.writeto(r'E:\FYPcr

VOC2012: PIL Image.open converts PNG to 2d array

帅比萌擦擦* 提交于 2019-12-31 02:55:11
问题 I am working with VOC2012 dataset. The input image is in PNG format which has a shape of (375, 500, 4) when I use imageio to open the image. When I use PIL to open the image, then suddenly the shape becomes (500, 375). PNG images should have four dimensions on the last axis: r g b & alpha. The image is obviously colored image, so it should have 3 dimensions (height, width, depth). PIL seems to suggest that it only has two dimensions: width & height. Can PNG images be represented by a 2d array

making gif from images using imageio in python

一笑奈何 提交于 2019-12-20 14:16:30
问题 I have tried reading a lot of examples online and found imageio is the perfect package for it. Also found examples written in here. I have just followed the example as shown and tried the following import imageio as io import os file_names = sorted((fn for fn in os.listdir('.') if fn.startswith('surface'))) #making animation with io.get_writer('surface.gif', mode='I', duration=0.5) as writer: for filename in file_names: image = io.imread(filename) writer.append_data(image) writer.close() and

making gif from images using imageio in python

痞子三分冷 提交于 2019-12-20 14:16:00
问题 I have tried reading a lot of examples online and found imageio is the perfect package for it. Also found examples written in here. I have just followed the example as shown and tried the following import imageio as io import os file_names = sorted((fn for fn in os.listdir('.') if fn.startswith('surface'))) #making animation with io.get_writer('surface.gif', mode='I', duration=0.5) as writer: for filename in file_names: image = io.imread(filename) writer.append_data(image) writer.close() and

Why is my gif missing png files after 753 iterations

£可爱£侵袭症+ 提交于 2019-12-12 04:07:29
问题 I'm using the following python code to generate a .gif file from about 3000 .png files. But the .gif file has only about 1000 .png files. Why is the .gif not having all the .png files? Is there a limit to the number of .png files I can combine to create a .gif file? import imageio import os filenames =[] dirPath = "D:\\BandSim_2017-06-20_12_00_45\\" for file in os.listdir(dirPath): if file.endswith(".png"): filenames.append(dirPath+file) moviePath ="D:\\simulation.gif" with imageio.get_writer