Questions tagged [python-imageio]
Imageio is a Python library that provides an easy interface to read and write a wide range of image data including animated images, volumetric data, and scientific formats. Make to use this tag for question related to it.
193
questions
1
vote
2
answers
121
views
imageio.imread(): Retains the original grayscale values when reading a png file
I would like to process a 12-bit grayscale image saved in png format. A monochromatic 12-bit camera was used as the signal source. The image file was created with NI Vision IMAQ Write File2.vi. The ...
1
vote
1
answer
72
views
Count tuples in array that are equal to same value
I have a NumPy array of shape (100,100,3) (an RGB image). I want to compare all 3-eleemnt tuples contained in the array for equality to produce array of booleans of shape (100,100).
Expected usage:
...
0
votes
0
answers
47
views
Saving an Image matrix with imageio for opening using ImageJ
Hey so I am trying to save an images that are in the form (10, 1926, 1926, 9). That is 10 z-stacks of 1926x1926 pixel images over 9 channels. However, when I try to save the processed images using the ...
0
votes
1
answer
56
views
How can I turn distinct R G B arrays back into an image?
In Python:
I read in an image and I want to process each channel (RGB) separately, then put the modified channels back together into an image and save it to disk. I have tried everything I can think ...
0
votes
0
answers
41
views
I'm using imageio.imread, the folder has 22 tif files the shape of the matrix I get is (514 1030 4), I expect (514 1030 22)
(First time user)
I want to read tif files from a folder.
N=22 (the number of tif files in the folder)
The name of the folder is: tif_files
The file names start at E_0 and ends at E_21
I'm reading the ...
0
votes
1
answer
109
views
How to make an animated set of images with a working duration per image
I want to make an animated set of images in python. I can't use an animated gif as I need more than 256 colors. I have tried an animated png but it seems the duration argument doesn't work. Here is a ...
0
votes
0
answers
118
views
How to save HDR file with numpy array?
I try to save HDR file with numpy array as follows.
numpy array like this (dtype:np.float32)
# hdr_file_data
[[[0.32543945, 0.38671875, 0.44213867],
[0.30029297, 0.34204102, 0.3737793 ],
[0....
0
votes
0
answers
52
views
Pythong imageio.v3 OverflowError: Python int too large to convert to C long
I am getting "Python int too large to convert to C long" when executing out_file.init_video_stream("vp9", fps=fps)
Maybe my video is to large is the cause of it? (vidoe info size: ...
0
votes
0
answers
91
views
How can I create a random pattern flashing at specific frequency in Python for GIF creation?
I am trying to write a code that creates a random pattern flashing (twinkling) at a specific frequency. Below is the code I am using, but the problem is that, different frequencies (frame rates) that ...
1
vote
0
answers
137
views
How to properly read .exr file and save it to .flo?
Firstly, I want to explain step by step what I am trying to do:
I have game motion vectors stored in .exr file (have no information about pixel format, likely float32), however I am provided with ...
0
votes
2
answers
447
views
increassing jpeg compression in the tifffile library
I'm saving numpy arrays as jpeg compressed tiff files in the following way
import tifffile
import numpy as np
im = np.zeros((4,256,256))
tifffile.imsave('myFile.tif' , im, compression = 'jpeg' )
...
2
votes
0
answers
232
views
Discoloration in GIF saved by imageio
I have a list of PIL images I want to turn into a GIF. I have a gray mouse moving around in a maze, following a cyan dot. However, the mouse renders as cyan in the saved GIF, and I don't know why.
...
0
votes
1
answer
1k
views
ValueError: Could not find a backend to open `my_path` with iomode `wi`
Code snippet giving the error:
for i in range(masks.shape[0]):
imsave(os.path.join(PATH_TO_SAVE, f"prediction_{(i+1):04d}"), masks[i])
Error message:
"ValueError: Could not find a ...
1
vote
1
answer
265
views
How to grab video frames fast?
For my project I want to extract frames from a video to make thumbnails. However every method i find is super slow going through the entere video. Here is what I have tried:
with iio.imopen(v.file....
1
vote
0
answers
140
views
imageio get_data skips frames
For a viewer, I am trying to randomly access frame in an mp4 file. Unfortunately, depending on where I start off, I am getting different frames from the same index, in my case for any frame after ...
0
votes
1
answer
494
views
skimage/imageio fails to read grayscale images
I have been reading images using (Python) skimage.imread (or imageio.imread) for months successfully, but now, without changing the code, I get failures when reading grayscale images. My collaborators ...
0
votes
0
answers
96
views
Python imageio: What is the best way to transfer video over TCP?
I have a python program running on an embedded Linux board (like a raspberry pi), and another python program running on my PC.
I am trying to use the imageio library as a way of capturing frames from ...
0
votes
2
answers
718
views
Fastest way to load an animated GIF in Python into a numpy array
Surprisingly I couldn't see any coverage of this.
I've found 3 recognised ways of performing this - Pillow, OpenCV, and Imageio. The results surprised me, so I've posted them as a self-answering Q&...
1
vote
2
answers
53
views
Optimize conversion of numpy ndarray to string
I am currently doing a python program to convert from image to hex string and the other way around. I need two functions, one that takes an image and returns a hex string that corresponds to the RGB ...
0
votes
2
answers
120
views
Fast way to convert string to numpy ndarray
I am currently doing a python program to convert from image to hex string and the other way around. I need two functions, one that takes an image and returns a hex string that corresponds to the RGB ...
0
votes
1
answer
425
views
GIF not getting saved while using ImageIO/PIL
I am trying to use both ImageIo and PIL to save a sequence of my images as GIF. The images do get saved in a .gif file. But, they are getting saved as a sequence of images and not as a "video&...
3
votes
1
answer
1k
views
How to get video metadata from bytes using imageio.v3?
I am creating a python class to process videos received from a http post. The videos can be from a wide range of sizes, 10 seconds up to 10 hours. I am looking for a way to get video metadata such as ...
2
votes
2
answers
2k
views
MoviePy RuntimeError: imageio.ffmpeg.download() has been deprecated
I try to run a simple script in Google Colab to determine a length of a video:
!pip install moviepy
from moviepy.editor import *
# Change directory:
os.chdir(r'/content/my_data')
clip = VideoFileClip(&...
1
vote
3
answers
686
views
How do I connect two GIFs to play one after another in Python?
If I have two GIFs, GIF 1 being 10 seconds long and GIF 2 being 5 seconds long, is there a way to connect them so the final GIF is a total of 15 seconds long?
Would I have to loop through each frame ...
1
vote
2
answers
870
views
Python pillow put text in center/middle
I am trying to put the text always in middle from very side. and i found this solution, but it doesnt work when i make the font size bigger.
I found this solution, it doesnt work too: Center-/middle-...
1
vote
0
answers
409
views
Open images in .cine file with Python module imageio
Using a Phantom high speed camera, the software saves an array of images in the '.cine' file format. This format is supported by imageio in python according to the docs. So, I installed the FreeImage ...
1
vote
1
answer
703
views
List to numpy array to write with imageio as video
I have a list as all_frames. I want to write this as a video with imageio but I got the error that you can find in below. How can I change all_frame from list to np.array?
You can find imageio code ...
1
vote
1
answer
291
views
How to get the last frame of a video with imageio in python?
I wanna grab 5 frames of a video distributed evenly including first and last frame. The answer to this helped me to loop over the video and get frames. However I didn't find out how to know when it's ...
1
vote
1
answer
644
views
Set webcam grabbing resolution with ImageIO in Python
Using simple Windows/Python to read from Webcam:
camera = iio.get_reader("<video0>")
screenshot = camera.get_data(0)
camera.close()
I'm getting a default resolution of 1980x1920. The ...
3
votes
1
answer
2k
views
How to seek a frame in video using `imageio`?
I have a video and I would like to extract only specific frames from the video.
Currently what I do is:
index = [1,2,3,4,5,6,7,8]
img_list = []
for i, frame in enumerate(iio.imiter("imageio:...
0
votes
1
answer
737
views
Adding Text to GIF made with `imageio.mimread()`
I am working with this data analysis pipeline that makes gifs of video recordings, the function used for this is:
def make_gif(self, datafile, save_file, frame_limit:int=20, fps:int=10, verbose=True):
...
0
votes
1
answer
534
views
How to read images using skimage
seed = 42
np.random.seed = seed
Img_Width=128
Img_Height=128
Img_Channel = 3
Train_Path = 'stage1_train/'
Test_Path = 'stage1_test/'
train_ids = next(os.walk(Train_Path))[1]
test_ids = next(os.walk(...
0
votes
0
answers
811
views
OpenCV - How to create webM with a transparent background?
When I'm using COLOR_RGBA2BGR all works fine,but transparent background of the GIF become black
Example gif url: https://i.stack.imgur.com/WYOQB.gif
When I'm using COLOR_RGBA2BGRA, then OpenCV will ...
0
votes
0
answers
1k
views
Play mp4 (with audio) in Tkinter Python
i need play video with audio using module tkinter by giving location of files of ( mp4 and audio ) or mp4 and also both the video and audio should sync
i tried this is my
code-1:
from tkinter import *
...
0
votes
1
answer
881
views
Combining various image channels after gaussian filtering produces white image
I am trying to implement a gaussian filter for an image with dimensions (256, 320, 4).
I first generated a gaussian Kernel for the same and then individually perform the convolution on each of the 4 ...
0
votes
1
answer
466
views
Animate static image
I have a static image that I would like to animate to appear like this (except starting from a black image, not a white image):
(image is from this post: Create animated gif from static image)
Here ...
1
vote
1
answer
1k
views
gif generating using imageio.mimwrite
I have the following code to generate GIFs from images, the code works fine and the gif is saved locally, what I want to do rather the saving the GIF locally, I want for example data URI that I could ...
1
vote
2
answers
642
views
How to convert a float32 img to uint8 where range is(-1 to -0.85)?
I want to convert a float32 image into uint8 image in Python.
I tried using the following code, but the output image only has values like 2 and 3 so the image is practically black.
gen_samples[0] * ...
1
vote
1
answer
575
views
Pyinstaller .exe fails in image reading
I have a gui ocr application in python. Script runs successfully. However when I build it via pyinstaller with the command below,
python -m PyInstaller --upx-dir='D:\upx-3.96-win64' --paths=Baris --...
1
vote
1
answer
494
views
Combination of RawPy and imageio result in red image
I want to do some image processing using .dng files. I am using rawpy to convert the file into a numpy array. Then imageio to save the image. It is a very simple code, given on the rawpy webpage.
The ...
1
vote
0
answers
1k
views
pkg_resources.ContextualVersionConflict: (numpy 1.19.5), Requirement.parse('numpy>=1.20.0'),
I find some version conflict.
pkg_resources.ContextualVersionConflict: (numpy 1.19.5 (/home/mehnaz/environments/nnUnet_ve/lib/python3.6/site-packages), Requirement.parse('numpy>=1.20.0'), {'imageio'...
0
votes
1
answer
1k
views
TypeError: _open() got an unexpected keyword argument 'pilmode'
I am training a CNN model on the COCO dataset, and I am getting this error after a few iterations. The error is not consistent because I got this error in 1100 iterations, once in 4500 iterations and ...
2
votes
1
answer
12k
views
cannot import module imageio in python3
Using python3, I am unable to import the imageio module into my python program, which I need, as I try to animate a list of PNG images I have. Thus far I have tried:
"pip3 install imageio" ...
1
vote
3
answers
720
views
How set white color background when concatenating images via python?
import numpy as np
from imageio import imread, imwrite
im1 = imread('https://api.sofascore.app/api/v1/team/2697/image')[...,:3]
im2 = imread('https://api.sofascore.app/api/v1/team/2692/image')[...,:3]...
1
vote
0
answers
23
views
imagio throws an error when i try to extract text
I am trying to package a computer vision software using pyinstaller. But python-imagio from easyocr seems to have a problem with something I suspect is handling formats. The Gui runs fine. I am able ...
1
vote
1
answer
204
views
Pyinstaller Codec Error on Executable When Using No Console And No Debug Option
I'm making this program that uses imageio and imageio-ffmpeg, I want to turn it into an executable, so I entered the virtualenv environment I'm using for the project, generated the .spec with pyi-...
2
votes
1
answer
129
views
Where is imageio finding 'chelsea.png'
I'm working with imageio in Python and the sample code shows a variable "im" reading "chelsea.png" but that file doesn't exist on my machine anywhere.
import imageio as iio
im = ...
0
votes
1
answer
147
views
mp4 to gif converter failing to produce
I'm struggling with my converter from mp4 to gif.
Its basically been put together from imageio website and YouTube, but cant get it to work.
#[python converter.py]
import imageio
import os
clip = os....
0
votes
0
answers
499
views
Read only first frame from an MKV with Python
This answer shows how to read MKV video using Python, but it appears to be reading/processing the entire video before the call to imageio.get_reader returns. Is there a way to parse just the first ...
0
votes
1
answer
155
views
convert all img in one pdf .?
I would like to finish my script, I tried a lot to solve but being a beginner failed.
I have a function imageio which takes image from website and after that, i would like resize all images in 63x88 ...