Shape matching and distance measuring methods

Here is my original image
This is my fist project regarding image processing so please bear with me. I am trying to
  1. detect the shape of few fabric shapes, the attached code and image "detected shape" show my effort on this.
  2. measure measure distance of the shape border, the attached image "measured image" show how i would like to measure my shape. (some method to automatically measure distances like in imtool)
  3. match those distance values with set values to check if they have correct size. It is a quality check application to test if the cut fabric parts are with in the given tolerance.(+ or - 5 mm)
I have completed shape detection part and searched the internet for months to find method to accurately measure distance in the method shown in "measured image". Please guide me in correct path. thank you
if true
%%read image
I = imread('D:\ICBT files\Bng final project\Test samples\Original pocket.JPG');
%%convert the image into gray image
Igray = rgb2gray (I);
%imshow (Igray)
%%Sobel edge detection
bw = edge(Igray,'Sobel',[0.04],'both','nothinning');
Ifilled = imfill(bw,'holes');
imshow(Ifilled);
%imtool(Ifilled);
end

1 Comment

Several years late getting to this question but as of R2026b there is now edge-based shape matching and subpixel measurement workflows enabled by the Visual Inspection Toolbox.
The examples shown here would be a worthwhile thing to check out that use the new shapemodel and matchshape functionality in Visual Inspection Toolbox for locating objects based on their contour profiles and automating measurements relative to the AnchorPoint defined by a shapemodel.

Sign in to comment.

 Accepted Answer

Image Analyst
Image Analyst on 15 Jan 2018
Edited: Image Analyst on 15 Jan 2018
Get the area with regionprops() or bwarea(). See my Image Segmentation Tutorial where I go over how to threshold an image and measure area and other features of blobs. https://www.mathworks.com/matlabcentral/fileexchange/?term=authorid%3A31862&sort=downloads_desc
See attached shape description demos.

3 Comments

Thank you for this information. In this method we are measuring the perimeter of the shape. Can I take five separate measurements of the five sides of the polygon? (like shown in the figure)
Yes. Use my demo to find the vertices. Then use sqrt() to find the distance between them. Please try it yourself, since I may not have time to do it for you for several days, if ever.
Thank you for your help. I will try that method.

Sign in to comment.

More Answers (0)

Community Treasure Hunt

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

Start Hunting!