helpful image handling utils – abstracts various file and opencv and pil features into result oriented functions

usage examples:

from image_handlers import *

load an image – a simple task in theory but often set with details…is the file there? is the argument a string and not a PathLib object, should it be loaded as rgb or bgr format?



toggle channel order with toRgb and toBgr – a common issue with opencv

opencv continues to have BGR as it’s channel format, vs PIL and the rest of the world use RGB format. A common source of confusion is thus confusing the channel format, resulting in blue tinted images.

Snowfall thus adds simple cover functions, toRgb and toBgr, to wrap the openCV cvtColor function to switch back and forth.
Note that the numpy trick of […,::-1] and similar simply switch the view of the data using that can greatly slow down future openCV operations on that image since it’s no longer contiguous memory, forcing OpenCV to have to copy the data for every function.


vs common mistake:



View Github