I have an rgb image how can i select the blue color plane from the RGB color space?

4 views (last 30 days)
i have this code but it show the error
redPlane1 =rgbImage1(:, :, 1);
greenPlane1 = rgbImage1(:, :, 2);
bluePlane1 = rgbImage1(:, :, 3);
rgbImage2(:, :, 3) = bluePlane1;
bluePlane1 = rgbImage1(:, :, 3);
bluePlane2 = rgbImage2(:, :, 3);
averageBlue = (double(bluePlane1) + double(bluePlane2)) / 3.0;
rgbImage2(:, :, 3) = uint8(averageBlue);

Answers (2)

Star Strider
Star Strider on 9 Oct 2015
What was the error?
One problem is that I do not see that you have defined ‘averageBlue’ in the code you posted. Did you intend:
averageBlue = (double(bluePlane1) + double(bluePlane2)) / 3.0;
If not, please copy all the red text from the Command Window and paste it to a Comment to your Question here.

Image Analyst
Image Analyst on 9 Oct 2015
What's with the char() function????? Try this:
% Extract the individual red, green, and blue color channels.
redChannel = rgbImage(:, :, 1);
greenChannel = rgbImage(:, :, 2);
blueChannel = rgbImage(:, :, 3);
You define the averageGreen to be 2/3 the blue channel of your image 1, but you don't every use it. Then you try to use averageBlue which has not been defined yet.

Categories

Find more on Image Processing Toolbox in Help Center and File Exchange

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!