Filter löschen
Filter löschen

Clarification regarding masking an image

3 Ansichten (letzte 30 Tage)
Elvin
Elvin am 8 Jan. 2014
Kommentiert: Elvin am 9 Jan. 2014
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.

Akzeptierte Antwort

Image Analyst
Image Analyst am 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.

Weitere Antworten (0)

Kategorien

Mehr zu Author Block Masks finden Sie in Help Center und File Exchange

Tags

Community Treasure Hunt

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

Start Hunting!

Translated by