i've been trying to open a .jpg image using
im = Image.open('file.jpg').
my problem is that for some reason the "im" is not an RGB image, i.e the channels are not R,G,B. this also cause the im.convert('L')
(rgb2gray) give a very bad result.
channel 0 image, attemped gray sacale.
Im using: Python 2.7.12 |Anaconda 4.1.1 (64-bit)
I would very much appreciate any help figuring this out.
edit: it seems the problem is that the matplotlib color map isn't set right. does anyone know why? and how to fix?
The basic difference between OpenCV image and PIL image is OpenCV follows BGR color convention and PIL follows RGB color convention and the method of converting will be based on this difference.
getrgb() Convert a color string to an RGB tuple. If the string cannot be parsed, this function raises a ValueError exception. Another Example:– Here used different colors.
You can find current mode in im.mode
and do convert with im.convert('RGB')
.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With