Clarification regarding masking an image
1 view (last 30 days)
Show older comments
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.
0 Comments
Accepted Answer
Image Analyst
on 9 Jan 2014
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.
More Answers (0)
See Also
Categories
Find more on Author Block Masks in Help Center and File Exchange
Products
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!