Open thekester opened 4 months ago
hi @thekester , sorry I took 3 weeks to review this. I like the PR so that we don't get that warning anymore but I prefer not to add another module like opencv
as there are now other toolkits that share dependencies with coastsat (like coastseg). So would there be a way to avoid the warning without bringing in new packages?
Since Pillow
is already a dependency of matplotlib
(matplotlib) and we have imageio
, there’s definitely a way to avoid the warning without implementing OpenCV. I’m working on a solution using these existing libraries, and I’ll add the commit to the PR shortly (add on (https://github.com/kvos/CoastSat/pull/523/commits/ef71e417d234f476094cd73de498cc8f16795289 )
thanks! will test it
@thekester , was wondering why we need to resize the image to 2864, 1440? this may create animations that are quite large no?
Please feel free to choose the most appropriate size; the example providedsize=(2864, 1440
) is just a suggestion. The goal is to ensure all images are the same size before creating the animation, thereby avoiding the IMAGEIO FFMPEG WRITER WARNING.
@thekester , I'm not convince about the resizing as every ROI has a different aspect ratio, some beaches are E or W facing while other are N or S facing, then if you resize all the images to a fixed size it will not work. I am happy to live with the warning as it seems to create good quality clips anyways. But if you want to resize, I suggest you find the most common size in the image folder and use that size for resizing all the images. It can happen that some satellite images are clipped, hence the difference in size that ffpmeg doesn't like. Something like this:
list_files = sorted(os.listdir(filepath_images))
sizes = [Image.open(os.path.join(filepath_images,_)).size for _ in list_files]
unique_sizes = set(sizes)
# select most common size
Thank you for your feedback, @kvos. I hadn't considered the issue of different aspect ratios due to the varying orientations of the beaches—this is a great point. I'll look into a method to automatically detect the aspect ratio of each image, identifying whether the beaches are oriented East-West or North-South. Then, I can adjust the resizing process to maintain the original proportions of the images while still avoiding the IMAGEIO FFMPEG warnings.
I'll test this approach and add a commit if it works.
Hello, this pull request addresses issue #522 by adding new functionality to create and update animations from a series of images. It includes the following key changes:
Changes made in SDS_tools and include 2 libraries
import cv2 from PIL import Image
to implement them, replacepip install pyqt5 imageio-ffmpeg
withpip install pyqt5 imageio-ffmpeg opencv-python Pillow