MATLAB Answers

Measuring Diameter of Calibration Pin

4 views (last 30 days)
Ang Xian Jia
Ang Xian Jia on 28 Nov 2019
Edited: Ang Xian Jia on 30 Nov 2019
I want to measure the diameter of the pin but getting a bad edge detection image. Can someone help me to further improve it?
My edge detection image:
My coding:
%% Read and Binarize
load image.mat
I4 = imgaussfilt(I3);
I4 = I4 <120;
I5 = edge(I4,'Sobel');


Sign in to comment.

Accepted Answer

Image Analyst
Image Analyst on 28 Nov 2019
Why are you doing edge detection???? I see no need for that. If the edges are about where you put them, then try thresholding and getting the area and divide by the width:
mask = grayImage < someValue;
mask = imfill(mask, 'holes');
diameter = nnz(mask) / size(mask, 2); % height = area / width. Answer is in pixels.
It's trickier if you want the inner, instead of outer, dark thing.


Show 2 older comments
Ang Xian Jia
Ang Xian Jia on 30 Nov 2019
Hi Image Analyst, thanks for the reply. It helps me a lot.
So actually in image processing,even though we have done all the steps correctly(adjust lighting, good threshold, etc.), how do we know the images after we have processed are considered as 'accurate' to the original image? For example, for this pin in this case, will we ever know the edge is actually straight line or ragged?
Image Analyst
Image Analyst on 30 Nov 2019
Do you have another, more trusted method? If not, then why do you doubt the image analysis? Why do you assume it's wrong if you don't have another more trusted method? If it's the only thing you have that gives you an answer, then why do you doubt it?
What you really need to ask is if the image analysis meets your needs. For example does it properly identify diameters that are for usable parts and unusable parts? If not, you can construct an ROC curve.
Ang Xian Jia
Ang Xian Jia on 30 Nov 2019
In measurement field, I think it's a headache to ask myself whether the image analysis had met my need. I think using more sample as you had mentioned is the best way to know whether I had done enough step/coding to process the pin image. Thank you so much, Image Analyst! #LongLiveImageAnalyst

Sign in to comment.

More Answers (0)