correction of rough edges for image detection
Show older comments
I am working on code to detect the edges of printed capacitors that we print in my lab.
I have little (honestly almost none) knowledge about image processing. I have been able to write some code that I can find the edges of a capacitor in an image and label those edges with markers. This code right now only works with a test image I made in paint. However when I try to run it on a real image I find broken, false or non-dectected lines.
I do not have any idea how to improve this. I have looked through and played with all the functions in the image processing tool box. Some made minor improvements but I am still not able to get the correct detection.
I have read that you can blur the edges then re-detect them. I was not sure however if this will change the length or position of the line/edge. If this is true this method will not work for me since I need as precise measurements as I can get.
I have attached the simple paint image I made, a real image of a printed capacitor, and the code.
If anyone has any suggestions I would be deeply appreciative. Thank you all for your help.
6 Comments
Image Analyst
on 19 Jan 2019
Most likely I would not use edge detection. I'd probably just use thresholding and then do something (though I don't know what the something is).
Tell me what you really want to do. You've said that basically edge detection is the final output, but I highly doubt that. Let's say that you had the edges. What would you do then? Just quit? I doubt it. What do you really want? The average spacing between the electrodes? Number of defects in the electrode bars? Something else? I assume the real image is an ideal case. What does a defective/bad image look like? What do you really want to detect? If the image is good or not? Exactly what defines good and not good? Thickness of bars? Thickness of the spacing between bars? Darkness of the bars?
jason wright
on 19 Jan 2019
Image Analyst
on 19 Jan 2019
What I'd do is to threshold the image then call bwdist() and bwmorph(bw, ''skel', inf) to get the Euclidean distance transform and the skeleton. If you multiply those two images together you get the thickness of the "in between" part, or the thickness of the electrodes, depending on what's being represented by the binary image. Something like (untested)
binaryImage = grayImage > someThreshold;
edtImage = bwdist(~binaryImage);
skelImage = bwmorph(binaryImage, 'skel', inf);
distanceImage = edtImage .* skelImage;
[skelRows, skelColumns] = find(skelImage);
From that, you can get the min distance, max distance, thickness, and means or distributions of any of those.
minThickness = min(edtImage(skelImage));
maxThickness = max(distanceImage);
etc.
It's just a few lines of code so see if you can do it over the next half hour or so. Post your code. I'll check back later this morning.
jason wright
on 19 Jan 2019
jason wright
on 6 Feb 2019
Image Analyst
on 7 Feb 2019
No - lots of problems with your code. Just see my attached code.


Answers (0)
Categories
Find more on Object Analysis in Help Center and File Exchange
Products
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!