How to detect contents of a beaker in an image
3 vues (au cours des 30 derniers jours)
Afficher commentaires plus anciens
I have an image of a beaker in which I want to automatically detect the contents of the beaker. I cannot use the intensity for this because sometimes the intensity of the beaker content is the same as the one in the walls. Also the the length and height of the beaker content is not always the same. Is there a method that I can use to create a mask for just the beaker content without having to do it manually?
![](https://www.mathworks.com/matlabcentral/answers/uploaded_files/1212173/image.jpeg)
8 commentaires
Image Analyst
le 7 Fév 2023
Attach the original image, not a screenshot with tick marks, tick labels, and other stuff. We want just the bare image. Not a figure or .fig file, just the original .tiff, .jpg, or .PNG file.
Réponses (2)
DGM
le 7 Fév 2023
Here's an initial attempt. How well this works really depends on how vague the gap between the blobs can be. As Walter mentions, if there are images other than screenshots, that would probably help too.
% read the images
A = imread('bk1.png');
B = imread('bk2.png');
imshow(generatemask(A))
imshow(generatemask(B))
function mk = generatemask(inpict)
% try to make things less sensitive to value
inpict = imadjust(inpict);
% binarize (idk how well this will work across all images)
mk = imbinarize(inpict,'adaptive','sensitivity',0.7);
% clean up the mask
mk = imopen(mk,ones(5)); % try to break any small bridges
mk = imfill(mk,'holes'); % fill any holes
mk = bwareaopen(mk,10E3); % get rid of small blobs
mk = bwpropfilt(mk,'extent',[0.85 1]); % keep blobs which are roughly grid-aligned rectangles
mk = bwareafilt(mk,1); % keep the largest remaining blob
end
As to how to apply watershed segmentation to this problem, I'm not the one to ask, but if it's a particularly good use-case, I'd like to see an example applied to this specific problem.
0 commentaires
Voir également
Catégories
En savoir plus sur Image Processing Toolbox dans Help Center et File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!