1

I am working on augmenting some images and I have run not necessary into a problem, but something that struck me as odd. For most of my augmentation methods I am using the Imgaug library and using imageio.imread to read my files. Though for my rotation augmentation I am using cv2.imread. I am using cv2 because of a function I need to not loose any of the image when it is rotated (imutils.rotate_bound()). Both methods work to read the image (jpeg), but I've noticed that the color changes with using the cv2 method. Please see examples below. Is this something that I should be concerned about or ...?

enter image description here

Edits: Just read through this post about cv2. Just to be clear, cv2 is just stacking the bands in a different order? So unless I am adding bands from multiple images and not taking into consideration that band 1 from one image could be the Blue band and one band from another image could be the Red band, then I do not need to convert? The pixel values are the same, but how it is displayed is different?

Binx
  • 382
  • 7
  • 22
  • 3
    `cv2` keeps colors as `BGR` instead of `RGB` and maybe you have to convert it. `cv2.cvtColor(img, cv2.COLOR_BGR2RGB)` – furas Jan 21 '21 at 01:56
  • _Just to be clear, `cv2` is just stacking the bands in a different order?_ Yeah, but that's crucial for displaying. Matplotlib for example expects NumPy arrays to displayed to be RGB ordered, while `cv2.imshow` awaits images with BGR ordering. So, when mixing `imageio.imread` and `cv2.imread` you'll get different output results for any displaying method (Matplotlib, OpenCV). Please provide your code, so people can point to the exact location, where your "error" occurs. – HansHirse Jan 23 '21 at 09:33
  • 1
    Nevertheless, your linked Q&A is a proper duplicate target, so I'm voting to close this question as duplicate of [Python OpenCV - imshow doesn't need convert from BGR to RGB](https://stackoverflow.com/questions/50963283/python-opencv-imshow-doesnt-need-convert-from-bgr-to-rgb) – HansHirse Jan 23 '21 at 09:38

0 Answers0