How To Smooth The Image Edge
Ältere Kommentare anzeigen
<<

>>i use : image=imread('hand.png'); e=edge(image,'canny'); imshow(e);
Akzeptierte Antwort
Weitere Antworten (1)
Image Analyst
am 27 Mai 2015
Bearbeitet: Image Analyst
am 27 Jan. 2016
5 Stimmen
One way is to blur the image with imfilter() or conv2() before you do the edge detection. Another way is to smooth the outline coordinates with a Savitzky-Golay filter, sgolayfilt() in the Signal Processing Toolbox.
See demo and image in the comment below - tell it to show the older comments because it's collapsed now.
19 Kommentare
Salaheddin Hosseinzadeh
am 27 Mai 2015
Dear Image Analyst,
I just checked sgolayfilt, is there a 2 dimensional version of this in MATLAB?
Thanks a lot.
Image Analyst
am 28 Mai 2015
Salaheddin: See attached demo. You have a choice of several images to pick from. It thresholds to find outlines, then calls sgolayfilt() to smooth both the x and y coordinate vectors.

The effect is clearer (more obvious) when you run the demo and can see the images full size.
Salaheddin Hosseinzadeh
am 28 Mai 2015
Dear Image Analyst.
Thank you sooo much! It's amazing. I will try this against imfilter but I don't think if that does any good! I learned something new, which means a lot to me!
Regards,
Salah
Image Analyst
am 27 Jan. 2016
The Savitzky-Golay filter is in the Signal Processing Toolbox. It takes it's name after its two inventors. Basically it's a moving window where it replaces the center of the window with a value taken from a polynomial fit of the data in the window.
The m-file you reference was written by myself. Glad you (hopefully) like it. Vote for my answer if you do.
DanitD
am 28 Jan. 2016
Yes, very useful indeed! thanks for sharing.
Image Analyst
am 28 Jan. 2016
Attached are two more of my Savitzky-Golay filter demos.
Image Analyst
am 16 Feb. 2017
You can send the smoothed outlines into poly2mask() if you want. This will define a new, smoother region of interest within which you make your measurements with regionprops().
sufian ahmed
am 22 Sep. 2017
this filter can i use before canny edge detection to remove noise and smooth edges ? i need smooth edges. Now i use median filter
Bram Mast
am 16 Jan. 2019
Thank you Image Analyst.
I have a problem using the SG filter. I don't get closed regions after aplying the filter to angular regions. How can I fix this ?
Thank you
Image Analyst
am 16 Jan. 2019
Bram:
You probably forgot to make the last point the same as the first point before filtering, so that the curve is closed. If you did, then attach your data.
Bram Mast
am 14 Feb. 2019
After you have extracted the boundary and applied a smoothing filter on the coordinates, which command can you use to extract information about de boundary (area, perimeter, ...) ?
Hello Image Analyst,
I am working on a similar problem where the SG filter is not closing the region despite making sure that first and last points are the same.
Can you suggest any way to smooth out the kinks at the edges?
Here is an example (First figure is showing the whole data set which forms a circle and second figure is a zoom in of the edges):
I am also attaching the raw data passed to sgolayfilt function. I used a window size of 311 and a degree of 3
Fig2 - Blue line - raw data; red dots - smoothed data;
Harshan Desu
am 8 Apr. 2020
Hi Image Analyst and everyone in this loop.
I have an image as follows,
I have tired all the filters like savitzky_golay_filter and other filters I found online. None of it is helping me smooth the edges in the image. Could you please help me with this.
Thanks in advace,
~Harshan

Image Analyst
am 8 Apr. 2020
Blur the image with imfilter() and then threshold at 0.5 if you want a binary image again.
windowSize = 5;
kernel = ones(windowSize) / windowSize^2;
blurryImage = imfilter(double(binaryImage), kernel);
binaryImage = blurryImage > 0.5;
Harshan Desu
am 8 Apr. 2020
Hi Image Analyst, I tired using the above, it is not showing any improvement. I tried changing the threshold too. It ain't helping. Is there any other way to get sleek and continous edges? Please help me out, Im a beginner.
The below is the Image after what u told me to try VS before that. FYI

Image Analyst
am 9 Apr. 2020
I don't know the resolution. Maybe those jaggies are just one pixel big? If so, you'd have to increase the number of pixels then blur and threshold.
Harshan Desu
am 1 Mai 2020
I have tired working on it for the past two weeks sir, I couldnt still get what I want. Let me explain my project clearly.. Please suggest me how I can work on it.
Project: Finding the edges of a door and used those edges as a trajectory for a sensor that checks edges for Gap/Flush.
Problem: I used Savitzky Golay, Edge Linking and Line Segment Fitting from your blog:
(https://www.peterkovesi.com/matlabfns/#step2line). After all this I am not able to get good edges, its either not smooth or has a lot of unnecessary edges.
Method I used: Image Analyst's Savitzky filter smoothening at three diffrent thresholds, obtain three images and blend them. The output is again processed to Edge linking and line segmenting program which I got from ur blog.
Questions:
- How to remove unnecessary edges out of the image.
- How to smoothening images so that i can use it for trajectory
You can also see my question: https://www.mathworks.com/matlabcentral/answers/519030-how-to-extract-curves-from-edges-of-a-complex-image?s_tid=prof_contriblnk
I have attached the images of my last output.
Kategorien
Mehr zu Smoothing and Denoising finden Sie in Hilfe-Center und File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!
