I have a file with a lot of .tif images.
Part 1. Preview of TIFF images
When I try to opreview them by clicking on them in the jupyter folder (which look like this one the Jupyter folder), I get the following message :
Error ! D:...\image.tif is not UTF-8 encoded
On the opposite, if I click on a png in the Jupyter folder, Jupyter does display an image.
How could I fix my images, knowing that I have more than 1000 of them in my folder ?
Nonetheless, if I write :
sph = cv2.imread('A1.tif',-1)
plt.imshow(sph)
plt.show()
I do get the image : image of 'A1.tif'.
Now I also checked :
import chardet
chardet.detect('A1.det')
--> {'confidence': 1.0, 'encoding': 'ascii', 'language': ''} # result
So apparently I it is encoded in ascii. Is it the same as utf-8 or should I convert them ?
Edit : Answer : In one of the comments, @FabienP answers that "According the official documentation, Jupyter lab does not support TIFF format for image preview (as of now)", which answers this question.
Part 2 : writing a video out of TIFF images
I have another question and I don't know if both questions are connected.
I want to make a video out of them.
import cv2
import os
image_folder = 'A549_A1'
video_name = 'video.avi'
images = [img for img in os.listdir(image_folder) if img.endswith(".tif")]
frame = cv2.imread(os.path.join(image_folder, images[0]))
height, width, layers = frame.shape
video = cv2.VideoWriter(video_name, 0, 1, (width,height))
for image in images:
video.write(cv2.imread(os.path.join(image_folder, image)))
cv2.destroyAllWindows()
video.release()
But instead of getting the expected video, I get a strange one with many images at one step : caption of the video. You can compare it to the image above to check that it's not normal.
How can I fix that ?