필터 지우기
필터 지우기

Clarification regarding masking an image

조회 수: 2 (최근 30일)
Elvin
Elvin 2014년 1월 8일
댓글: Elvin 2014년 1월 9일
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.
  댓글 수: 1
Elvin
Elvin 2014년 1월 9일
Now it's clear. Thank you very much. :)

댓글을 달려면 로그인하십시오.

추가 답변 (0개)

태그

Community Treasure Hunt

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

Start Hunting!

Translated by