# Revision history [back]

you do not have to "implement" anything on your own, just use cvtColor like:

Mat src = ...
Mat dst;
cvtColor(src, dst, COLOR_BGR2GRAY);


please also note, that it's BGR order, not RGB, like in photoshop.

you do not have to "implement" anything on your own, just use cvtColor like:

Mat src = ...
Mat dst;
cvtColor(src, dst, COLOR_BGR2GRAY);


please also note, that it's BGR order, order in opencv, not RGB, like in photoshop.

you do not have to "implement" anything on your own, just use cvtColor like:

Mat src = ...
Mat dst;
cvtColor(src, dst, COLOR_BGR2GRAY);


please also note, that it's BGR order in opencv, not RGB, like in photoshop.

again, you won't be able to get a 1 to 1 mapping to photoshop, there's a lot of small differences, like byte order, hue range in [0..180], no support for alpha, etc.

you do not have to "implement" anything on your own, just use cvtColor like:

Mat src = ...
Mat dst;
cvtColor(src, dst, COLOR_BGR2GRAY);


please also note, that it's BGR order in opencv, not RGB, like in photoshop.

again, you won't be able to get a 1 to 1 mapping to photoshop, there's a lot of small differences, like byte order, hue range in [0..180], no support for alpha, etc.

maybe you started your question at the wrong end ? if you wanted to do something like segmentation based on color, you'd roughly do it like this (let's say, looking for cyan):

Mat hsv;
cvtColor(src, hsv, COLOR_BGR2HSV);

Mat binary;
Scalar lo(90-10, 40, 40); // again, H is in [0..180] !
Scalar hi(90+10, 90, 90);
inRange(hsv, lo, hi, binary);
// now use binary e.g. for findContours()


you do not have to "implement" anything on your own, just use cvtColor like:

Mat src = ...
Mat dst;
cvtColor(src, dst, COLOR_BGR2GRAY);


please also note, that it's BGR order in opencv, not RGB, like in photoshop.

again, you won't be able to get a 1 to 1 mapping to photoshop, there's a lot of small differences, like byte order, hue range in [0..180], no support for alpha, etc.

maybe you started your question at the wrong end ? if you wanted to do something like segmentation based on color, you'd roughly do it like this (let's say, looking for cyan):

Mat hsv;
cvtColor(src, hsv, COLOR_BGR2HSV);

Mat binary;
Scalar lo(90-10, 40, 40); 90, 90); // again, H is in [0..180] !
Scalar hi(90+10, 90, 90);
150, 150);
inRange(hsv, lo, hi, binary);
// now use binary e.g. for findContours()