I am converting a grayscale signature image to thin image but not getting the desired output
You are now following this question
- You will see updates in your followed content feed.
- You may receive emails, depending on your communication preferences.
An Error Occurred
Unable to complete the action because of changes made to the page. Reload the page to see its updated state.
Show older comments

after applying the im2bw(img,graythresh(img)) function i get the following image

but the image is not smooth enough after applying thining on the said image i get the following

so how to get rid of extra roots from the thin image and get smooth signature skeleton
Accepted Answer
Anand
on 17 Sep 2015
It looks like you need to clean up the binary image a little before thinning.
This worked for me:
bw = im2bw(img,graythresh(img));
% remove some of the noisy edges in the mask.
bw_clean = imopen(bw, strel('disk',1));
% remove small foreground objects.
bw_clean = bwareaopen(bw_clean, 25);
% invert the image and thin it.
bw_thin = bwmorph(imcomplement(bw_clean), 'thin', Inf);
9 Comments
Sohail
on 18 Sep 2015
Hi Anand thanks for your response. let me ask you about the following image

here in the image there are some white pixels inside black stroke of the signature can we remove this by adding black pixels in place of white pixels inside the stroke
imclose the object to fill the small holes.
Sohail
on 18 Sep 2015
Hi Walter Roberson how would you approach to correctly thin the grayscale image (attached with question) to thin image without having extra roots
Whats the function to remove extra roots around after thining function
I would not do that. "Extra roots" is not well defined and "correctly thin" is not well defined. When it comes to signature verification, little turns can be characteristic, as can be stroke width.
However, you might find it interesting to dilate the object, then filter out small blobs such as with bwareaopen or bwareafilt, and then skeletonize it.
actually i am only interested in endpoints after thinning and the roots produces extra endpoints which increase total endpoints count and that is what i dont want
Image Analyst
on 18 Sep 2015
imfill() will fill completely surrounded holes and leave exterior boundaries unchanged. imclose() will fill interior holes and will smooth out exterior boundaries.
Image Analyst
on 18 Sep 2015
More Answers (0)
Categories
Find more on Image Processing Toolbox in Help Center and File Exchange
Products
See Also
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!Select a Web Site
Choose a web site to get translated content where available and see local events and offers. Based on your location, we recommend that you select: .
You can also select a web site from the following list
How to Get Best Site Performance
Select the China site (in Chinese or English) for best site performance. Other MathWorks country sites are not optimized for visits from your location.
Americas
- América Latina (Español)
- Canada (English)
- United States (English)
Europe
- Belgium (English)
- Denmark (English)
- Deutschland (Deutsch)
- España (Español)
- Finland (English)
- France (Français)
- Ireland (English)
- Italia (Italiano)
- Luxembourg (English)
- Netherlands (English)
- Norway (English)
- Österreich (Deutsch)
- Portugal (English)
- Sweden (English)
- Switzerland
- United Kingdom (English)