Clarification regarding masking an image

2 次查看(过去 30 天)
I just want to ask this question for clarification. Example I have this image below.
And then I mask it using the code below so that I can only focus on the green color because that's my region of interest.
greenChannel = rgbImage(:,:,2);
mask = greenChannel > 55;
mask = bwareaopen(mask, 6000);
mask = imfill(mask,'holes');
The output after masking is this:
If I used the following code below to get the mean of the LChannel, does the value of the LChannel_LCC equal only to the white portion of the image (shown above) after masking? Or it is equal of the LChannel of the whole image?
colorTransform = makecform('srgb2lab');
labImage = applycform(rgbImage, colorTransform);
LChannel = labImage(:, :, 1);
LChannel_LCC = mean(LChannel(mask));
Also, how can I transform only the ROI (which is the green part) to LAB? I mean, only the green color in the original image will be transformed to LAB space.
Thank you.

采纳的回答

Image Analyst
Image Analyst 2014-1-9
That uses logical indexing. So LChannel(mask) gives a column vector of only those values of LChannel where mask is true. So the mean of LChannel(mask) is the mean only within the mask (white) area, not of the whole image.

更多回答(0 个)

标签

Community Treasure Hunt

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

Start Hunting!

Translated by