在 MATLAB 中细化手写字符 [英] Thinning handwritten characters in MATLAB
问题描述
我想细化如下所示的手写字符:
I want to thin handwritten characters like shown below:
下面的代码给出了我的预期结果:
Code below give my expected result:
BW = imread('s.png');
BWI = imcomplement(BW);
BW2D = im2bw(BWI,0.1);
BWT = bwmorph(BW2D,'thin',Inf),
BWFinal = imcomplement(BWT);
figure, imshow(BWFinal);
这是正确的方法吗?或者在 MATLAB 中有另一种方法吗?
Is this the correct approach? Or is there another way to do it in MATLAB?
推荐答案
一致认为你的代码没问题.但是,为了让 Shai 在他的积分上有所作为,我添加了一个小评论:
The consensus is that your code is ok. However, to give Shai some mileage on his points, I add a minor comment:
imcomplement
的使用可能不是必需的,请参阅 文档.
The use of imcomplement
may not be necessary, see the documentation.
特别是:
提示如果IM是double类的灰度或者RGB图像,可以使用表达式 1-IM 而不是这个函数.
Tip If IM is a grayscale or RGB image of class double, you can use the expression 1-IM instead of this function.
如果 IM 是二进制图像,则可以使用表达式 ~IM 代替这个功能.
If IM is a binary image, you can use the expression ~IM instead of this function.
这篇关于在 MATLAB 中细化手写字符的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!