The crop_colours.py script is currently experiencing slow processing times when cropping black and white blocks from images. This issue needs to be investigated and addressed to improve the performance of the script.
Areas to investigate:
Pixel-by-pixel iteration: The script currently checks every pixel in an image, which is time-consuming. Investigate vectorization techniques, such as using NumPy or OpenCV, to process images more efficiently.
Image processing libraries: Explore potential optimizations or alternatives to the PIL (Pillow) library, which may include using OpenCV or NumPy for faster image manipulation..
Parallel processing: Consider using multi-threading or parallel processing (e.g., concurrent.futures or multiprocessing) to handle multiple images simultaneously, which could significantly speed up batch processing..
Thresholding optimization: Investigate if the threshold logic for determining black and white pixels can be optimized further to minimize redundant checks across large sections of the image.
Memory management: Review how memory is being handled during image processing and whether there are any opportunities to optimize memory usage, such as processing images in chunks instead of loading them entirely into memory.
Acceptance Criteria:
The script should process images faster without losing the correctness of the cropping logic.
If a solution is found and implemented, performance improvements should be measurable (e.g., processing time reduced for large batches of images).
The script should continue to save cropped images in the "Cropped Images" folder as per the existing functionality.
The
crop_colours.py
script is currently experiencing slow processing times when cropping black and white blocks from images. This issue needs to be investigated and addressed to improve the performance of the script.Areas to investigate:
PIL
(Pillow) library, which may include usingOpenCV
orNumPy
for faster image manipulation..concurrent.futures
ormultiprocessing
) to handle multiple images simultaneously, which could significantly speed up batch processing..Acceptance Criteria: