How to mark the foreign object inside this bottle.

Hello, i need some help, i got image of beverage with sample of foreign object inside. so how to make a mark (red outline or fill the foreign object with red colour) the area of the foreign object. here i attach my simple code and picture. thank you.

 採用された回答

Image Analyst
Image Analyst 2020 年 12 月 23 日

1 投票

Your best bet might be to take a photo of a perfect sample and then subtract them. Any pixel that is not zero or slightly above is bad. Or you could try the Color Thresholder app on the Apps tab of the tool ribbon to find any non-green pixels.

7 件のコメント

MOHAMMAD AZRUL AIMAN
MOHAMMAD AZRUL AIMAN 2020 年 12 月 29 日
Hi, i just try using imsubtract method. but the result not like i need. sorry im still new in matlab
so this is what i got. did u have any demo to i refer .
MOHAMMAD AZRUL AIMAN
MOHAMMAD AZRUL AIMAN 2020 年 12 月 29 日
sorry, i just reverse the subtract, so i got this result . but still how can i mark the contamination spot in the figure 3. maybe the bottle have slightly allignment problem
Image Analyst
Image Analyst 2020 年 12 月 29 日
How would you LIKE to mark it? Do you want to use plot() to place a marker above it in the overlay?
MOHAMMAD AZRUL AIMAN
MOHAMMAD AZRUL AIMAN 2020 年 12 月 30 日
i got several sample of contamination. so the placement of contamination not fixed. so i think adter subtraction all green region left (in figure 3) will be mark as contamination will red outline.
Image Analyst
Image Analyst 2020 年 12 月 30 日
Then how about imoverlay()?
MOHAMMAD AZRUL AIMAN
MOHAMMAD AZRUL AIMAN 2020 年 12 月 30 日
i working with imoverlay, but after threshhold the image, i got many small pixel. did u have any solution to remove unwanted pixel and left the contamination pixel only
Image Analyst
Image Analyst 2020 年 12 月 30 日
After subtraction, you have to threshold the subtraction image to only find differences that exceed a certain difference.
% Convert to lab color space
labImageRef = rgb2lab(rgbImageRef);
% Convert to lab color space
labImageTest = rgb2lab(rgbImageTest);
% Get color differences in each color channel.
deltaL = labImageRef(:, :, 1); - labImageTest(:, :, 1);
deltaA = labImageRef(:, :, 2); - labImageTest(:, :, 2);
deltaB = labImageRef(:, :, 3); - labImageTest(:, :, 3);
% Get the overall color difference Delta E (See Wikipedia on Color Difference)
% https://en.wikipedia.org/wiki/Color_difference
deltaE = sqrt(deltaL .^ 2 + deltaA .^ 2 + deltaB .^ 2);
majorDifferences = deltaE > 8; % Adjust number as needed.

サインインしてコメントする。

その他の回答 (0 件)

Community Treasure Hunt

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

Start Hunting!

Translated by