我想瘦手写的字符,如下所示:

以下代码给出了我的预期结果:
BW = imread('s.png');
BWI = imcomplement(BW);
BW2D = im2bw(BWI,0.1);
BWT = bwmorph(BW2D,'thin',Inf),
BWFinal = imcomplement(BWT);
figure, imshow(BWFinal);
Run Code Online (Sandbox Code Playgroud)
这是正确的方法吗?或者在MATLAB中有另一种方法吗?