Réponse acceptée

Salaheddin Hosseinzadeh
Salaheddin Hosseinzadeh le 27 Mai 2015
Modifié(e) : Salaheddin Hosseinzadeh le 27 Mai 2015

0 votes

Salam Behnam!
I guess by smoothing you mean getting rid of the jagged edges.
What do you think of performing a dilation with a huge radial element and then perform thining?
I just did this here is the result
I hope this is good enough. I did it with a disk of 10 pixels radious you maybe reduce/increase the disk size and get a better smoothing.
Good Luck!

3 commentaires

behnam emami
behnam emami le 27 Mai 2015
Yes, this was my answer Please send Code Here Thank You
Salaheddin Hosseinzadeh
Salaheddin Hosseinzadeh le 27 Mai 2015
Modifié(e) : Salaheddin Hosseinzadeh le 27 Mai 2015
Dear Behnam,
You can search MATLAB help for the keywords in my answer. Please also have a look at Image Analyst response, that is far more scientific.
dilatedImage = imdilate(image,strel('disk',10));
thinedImage = bwmorph(dilatedImage,'thin',inf);
Good luck!
behnam emami
behnam emami le 27 Mai 2015
Thank You Mr Salaheddin Hosseinzadeh

Connectez-vous pour commenter.

Plus de réponses (1)

Image Analyst
Image Analyst le 27 Mai 2015
Modifié(e) : Image Analyst le 27 Jan 2016

5 votes

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 commentaires

Salaheddin Hosseinzadeh
Salaheddin Hosseinzadeh le 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
Image Analyst le 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
Salaheddin Hosseinzadeh le 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
DanitD
DanitD le 27 Jan 2016
Modifié(e) : DanitD le 27 Jan 2016
Hello,
I would like to know where did you take the (savitzky_golay_filter_smooth_outline.m)function from? Any reference to cite?!
Thanks,
Image Analyst
Image Analyst le 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
DanitD le 28 Jan 2016
Yes, very useful indeed! thanks for sharing.
Image Analyst
Image Analyst le 28 Jan 2016
Attached are two more of my Savitzky-Golay filter demos.
Kamu
Kamu le 16 Fév 2017
Modifié(e) : Kamu le 16 Fév 2017
Thanks Image Analyst. However, how can I use the outcome image with Savitzky-Golay filter for further image processing steps (like regionprops)?
Image Analyst
Image Analyst le 16 Fév 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
sufian ahmed le 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
Bram Mast le 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
Image Analyst le 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
Bram Mast le 14 Fév 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, ...) ?
newbie
newbie le 20 Mar 2019
Modifié(e) : newbie le 20 Mar 2019
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
Harshan Desu le 8 Avr 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
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
Harshan Desu le 8 Avr 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
Image Analyst le 9 Avr 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
Harshan Desu le 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:
  1. How to remove unnecessary edges out of the image.
  2. How to smoothening images so that i can use it for trajectory
I have attached the images of my last output.

Connectez-vous pour commenter.

Community Treasure Hunt

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

Start Hunting!

Translated by