Clarification regarding masking an image
1 次查看(过去 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.
0 个评论
采纳的回答
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 个)
另请参阅
类别
在 Help Center 和 File Exchange 中查找有关 Author Block Masks 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!