フィルターのクリア

How can I extract characters from a binary image when I have its centroid?

3 ビュー (過去 30 日間)
Kartik Bharadwaj
Kartik Bharadwaj 2017 年 9 月 22 日
コメント済み: Image Analyst 2017 年 10 月 7 日
I = imread('download5.png');
J = rgb2gray(I);
K = bwareaopen(J,10,8);
h1 = fspecial('gaussian', 3, 1);
h2 = fspecial('average', 2);
g = imfilter(K,h1, 'replicate');
g1 = imfilter(g,h2, 'replicate');
g1 = ~g1;
g1 = bwmorph(g1,'clean');
g1 = bwmorph(g1,'bridge',Inf);
g1 = imdilate(g1, [1 1 1; 1 1 1; 1 1 1]);
[B, L, N, A] = bwboundaries(g1, 'holes');
s = regionprops(L,'all');
imshow(g1)
hold on
for k = 1:length(B)
boundary = B{k};
if k <= N
plot(boundary(:,2), boundary(:,1))
end
end
centroids = cat(1, s.Centroid);
plot(centroids(:,1),centroids(:,2), 'b*')
In the above image, I am getting extra centroids apart from that of the characters. How can I eliminate the unwanted centroids and extract only the characters using centroids? (Extract meaning that I want to save each character separately as an image)

採用された回答

Image Analyst
Image Analyst 2017 年 9 月 22 日
See my Image Segmentation Tutorial http://www.mathworks.com/matlabcentral/fileexchange/?term=authorid%3A31862&sort=downloads_desc It shows you how to find blobs and then crop out the blobs to individual images by asking reginoprops() for the BoundingBox.
As far as removing "unwanted" blobs, you'll have to define what unwanted is. If it's just small ones, then you can use bwareafilt() or bwareaopen().
  4 件のコメント
Kartik Bharadwaj
Kartik Bharadwaj 2017 年 10 月 7 日
Neither am I. However, to satiate my curiosity on whether we can smoothen the edges, I want to try it out.
Image Analyst
Image Analyst 2017 年 10 月 7 日
There are a variety of ways to smooth a binary image, such as blurring and thresholding, or calling imclose(), or using sgolayfilt() or other means, such as the attached demo.

サインインしてコメントする。

その他の回答 (0 件)

カテゴリ

Help Center および File ExchangeImages についてさらに検索

Community Treasure Hunt

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

Start Hunting!

Translated by