Ask Your Question

Revision history [back]

click to hide/show revision 1
initial version

Why the cvtColor don't work?

I am confusing,why this code don't work

mask = imread("mask.jpg")>200;
cvtColor(mask, red, COLOR_GRAY2BGR);

It cannot run normally and will pop an abort window.But if I specify the color space when load the mask like

mask1 = imread("mask.jpg",IMREAD_GRAYSCALE)>200;
cvtColor(mask1, red, COLOR_GRAY2BGR);

Then the code is work well. I think this problem is result to the mask is not grayscale image. But how to know the color space of a image in OpenCV?

Why the cvtColor don't work?

I am confusing,why this code don't work

mask = imread("mask.jpg")>200;
cvtColor(mask, red, COLOR_GRAY2BGR);

It cannot run normally and will pop an abort window.But if I specify the color space when load the mask like

mask1 = imread("mask.jpg",IMREAD_GRAYSCALE)>200;
cvtColor(mask1, red, COLOR_GRAY2BGR);

Then the code is work well. I think this problem is result to the mask mask is not grayscale image. But how to know the color space of a image in OpenCV?

Why the cvtColor don't work?

I am confusing,why this code don't work

mask = imread("mask.jpg")>200;
cvtColor(mask, red, COLOR_GRAY2BGR);

It cannot run normally and will pop an abort window.But if I specify the color space when load the mask like

mask1 = imread("mask.jpg",IMREAD_GRAYSCALE)>200;
cvtColor(mask1, red, COLOR_GRAY2BGR);

Then the code is work well. I think this problem is result to the mask is not grayscale image. But how to know the color space of a image in OpenCV?


This is my test image.

Why the cvtColor don't work?

I am confusing,why this code don't work

mask = imread("mask.jpg")>200;
cvtColor(mask, red, COLOR_GRAY2BGR);

It cannot run normally and will pop an abort window.But if I specify the color space when load the mask like

mask1 = imread("mask.jpg",IMREAD_GRAYSCALE)>200;
cvtColor(mask1, red, COLOR_GRAY2BGR);

Then the code is work well. I think this problem is result to the mask is not grayscale image. But how to know the color space of a image in OpenCV?


This is my image test imagemask.

Why the cvtColor don't work?

I am confusing,why this code don't work

mask = imread("mask.jpg")>200;
cvtColor(mask, red, COLOR_GRAY2BGR);

It cannot run normally and will pop an abort window.But if I specify the color space when load the mask like

mask1 = imread("mask.jpg",IMREAD_GRAYSCALE)>200;
cvtColor(mask1, red, COLOR_GRAY2BGR);

Then the code is work well. I think this problem is result to the mask is not grayscale image. But how to know the color space of a image in OpenCV?


This is my image mask.