Ask Your Question
0

Merging HSV planes to get modified S plane

asked 2016-08-31 09:51:50 -0500

riya1405 gravatar image

updated 2016-08-31 09:54:09 -0500

I separated the HSV planes and modified the s plane.I need the merged image to look exactly like the modified s plane. How should I do that?

Modified s plane image: modified s plane

Output obtained after setting other layers to 0 and merging: output obtained after merging

edit retag flag offensive close merge delete

Comments

please show your code (we can't help without seeing it)

berak gravatar imageberak ( 2016-08-31 10:25:53 -0500 )edit

I need the merged image to look exactly like the modified s plane. Then why not keep that modified S plane as a single channel grayscale image instead of making it a 3 channel image again?

StevenPuttemans gravatar imageStevenPuttemans ( 2016-09-01 03:21:36 -0500 )edit

I need to superimpose another 3 channel image with this one.

riya1405 gravatar imageriya1405 ( 2016-09-01 05:19:34 -0500 )edit

1 answer

Sort by ยป oldest newest most voted
1

answered 2016-09-01 03:25:14 -0500

updated 2016-09-01 03:26:38 -0500

My question still remains, but what I guess you are looking for is

Mat image_BGR, image_HSV;
imread("/path/to/image", IMREAD_COLOR);
cvtColor(image_BGR, image_HSV, COLOR_BGR2HSV);
vector<Mat> channels;
split(image_HSV, channels);
Mat S_channel = channels[1].clone();
// do some processing on the S channel here and store it back in S_channel
// Make a 3 channel image again exactly like the modified S-channel looking 
Mat merged(image_HSV.rows, image_HSV.cols, CV_8UC3);
Mat in[] = { S_channel, S_channel, S_channel };
int from_to[] = { 0,0, 1,1, 2,2 };
mixChannels( in, 3, &merged, 1, from_to, 3 );

Good luck!

edit flag offensive delete link more

Comments

1

Yeah it helped. Thanks a lot!

riya1405 gravatar imageriya1405 ( 2016-09-01 05:21:37 -0500 )edit

You are welcome! Do accept the answer as a solution once you are able too.

StevenPuttemans gravatar imageStevenPuttemans ( 2016-09-01 06:28:54 -0500 )edit

Question Tools

1 follower

Stats

Asked: 2016-08-31 09:51:50 -0500

Seen: 539 times

Last updated: Sep 01 '16