1 | initial version |
I'm not sure that mask.jpg is grayscale image. Your link is a png with 24 bits depth image (some site change image format).
Now in jpg format I don't think it's possible to use a specific color space. When you use imread wit a jpg file you will get a three channel image : imread("mask.jpg",IMREAD_UNCHANGED )
three channels means B G R. (of course some users can save YUV as a jpg and everything is broken but you cannot know this before display image)
Now your code is wrong :
mask = imread("mask.jpg")>200;
cvtColor(mask, red, COLOR_GRAY2BGR);
because in imread second parameter default value is IMREAD_COLOR
2 | No.2 Revision |
I'm not sure that mask.jpg is grayscale image. Your link is a png with 24 bits depth image (some site change image format).
Now in jpg format I don't think it's possible to use a specific color space. When you use imread wit a jpg file you will get a three channel image : imread("mask.jpg",IMREAD_UNCHANGED )
three channels means B G R. (of course some users can save YUV as a jpg and everything is broken but you cannot know this before display image)
Now your code is wrong :
mask = imread("mask.jpg")>200;
cvtColor(mask, red, COLOR_GRAY2BGR);
because in imread second parameter default value is IMREAD_COLORIMREAD_COLOR and if image is a grayscale image then image will be convert in color.
3 | No.3 Revision |
I'm not sure that mask.jpg is grayscale image. Your link is a png with 24 bits depth image (some site change image format).
Now in jpg format I don't think it's possible to use a specific color space. When you use imread wit a jpg file you will get a three channel image : imread("mask.jpg",IMREAD_UNCHANGED )
three channels means B G R. (of course some users can save YUV as a jpg and everything is broken but you cannot know this before display image)
Now your code is wrong :
mask = imread("mask.jpg")>200;
cvtColor(mask, red, COLOR_GRAY2BGR);
because in imread second parameter default value is IMREAD_COLOR and if image is a grayscale image then image will be convert in color.
if you want to know how many channels are in mask.jpg :
mask = imread("mask.jpg",IMREAD_UNCHANGED)
cout<<mask.channels();< p="">