How can I find faint objects with known general shape and location in an image?
2 vues (au cours des 30 derniers jours)
Afficher commentaires plus anciens
I am trying to locate objects in an image, such as the two squares in the attached image. I then want to compare the objects dimensional accuracy relative to the intended shape. This means I should know the general shape and location of each object in the image. Normally it would be no problem to find the shapes with imbinarize() or edge() but the objects are transparent and the boundaries are too faint so all of the edge detection methods I have tried do not accurately pick up the objects edges. Just looking at the image its very obvious to the eye where these objects are so it seems like there should be a way to identify these edges.
0 commentaires
Réponses (1)
Shraddha Jain
le 11 Mar 2021
Hi Jason,
Applying edge function directly onto the image attached above does not give desired results due to the grainy texture of the image. You would see better edge detection if the image is first smoothed out using imgaussfilt function.
Below is the code to create the binary gradient mask of the above attached image, which could further be used for edge detection of the shapes present in the image,
% Read input image
I = imread('two_squares_RG.png');
% Apply 2-D Gaussian smoothing kernel with standard deviation of 4
S = imgaussfilt(I,4);
imshowpair(I,S,'montage')
% Convert input RGB image to grayscale image
G = im2gray(S);
% Find edges
BW_mask = edge(G,'sobel');
imshow(BW_mask)
title('Binary Gradient Mask')
You can further apply morphological operations on BW to find the outline of the detected shapes. Follow this example for more information on this, https://www.mathworks.com/help/images/detecting-a-cell-using-image-segmentation.html
Hope this helps!
0 commentaires
Voir également
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!