资源简介
用matlab实现汉字的笔画细化用matlab实现汉字的笔画细化算法
代码片段和文件信息
function OutBW = Condition1( BW debug )
MaskBW = zeros(size(BW)+2) ;
MaskBW([2:end-1][2:end-1]) = BW ;
BW = MaskBW ;
BW = double( BW ) ;
OutBW = BW ;
[row col] = find( BW == 1 ) ;
for i = 1 : length(row)
indx = row(i) ;
indy = col(i) ;
if debug == 1
if indx == 189 && indy == 28
close all ;
imshow(BW) ;
hold on ;
plot(indyindx‘r*‘) ;
end
end
Mask = [ BW(indx-1indy-1) BW(indx-1indy) BW(indx-1indy+1) ;...
BW(indxindy-1 ) BW(indxindy) BW(indxindy+1 ) ;...
BW(indx+1indy-1) BW(indx+1indy) BW(indx+1indy+1) ];
%% Condition 1
if Mask(23) == 0 && ( Mask(13) == 1 || Mask(12) == 1)
b1 = 1;
else
b1 = 0;
end
if Mask(12) == 0 && ( Mask(11) == 1 || Mask(21) == 1)
b2 = 1;
else
b2 = 0;
end
if Mask(21) == 0 && ( Mask(31) == 1 || Mask(32) == 1)
b3 = 1;
else
b3 = 0;
end
if Mask(32) == 0 && ( Mask(33) == 1 || Mask(23) == 1)
b4 = 1;
else
b4 = 0;
end
b = b1 + b2 + b3 + b4 ;
%% Condition 2
Mask = logical(Mask) ;
N1 = double( Mask(23) | Mask(13) ) + double( Mask(12) | Mask(11) ) + double( Mask(21) | Mask(31) ) + double( Mask(32) | Mask(33) );
N2 = double( Mask(13) | Mask(12) ) + double( Mask(11) | Mask(21) ) + double( Mask(31) | Mask(32) ) + double( Mask(33) | Mask(23) ) ;
NCondition2 = min(N1N2) ;
%% Condition 3
Mask = logical(Mask) ;
Mask(33) = ~Mask(33) ;
NCondition3 = ( Mask(13) | Mask(12) | Mask(33) ) & Mask(23) ;
%% Judgement
if NCondition3 == 0 && NCondition2>=2 && NCondition2<=3 && b == 1
OutBW(indxindy) = 0 ;
end
end
OutBW = OutBW([2:end-1][2:end-1]) ;
属性 大小 日期 时间 名称
----------- --------- ---------- ----- ----
目录 0 2010-04-20 04:11 Thinning In Matlab\
目录 0 2010-04-20 04:11 Thinning In Matlab\Thinning In Matlab\
文件 7082 2010-04-17 22:28 Thinning In Matlab\Thinning In Matlab\bw.bmp
文件 7082 2010-04-17 17:59 Thinning In Matlab\Thinning In Matlab\bw2.bmp
文件 7082 2010-04-18 16:54 Thinning In Matlab\Thinning In Matlab\bw4.bmp
文件 2271 2010-04-19 14:38 Thinning In Matlab\Thinning In Matlab\Condition1.m
文件 2212 2010-04-19 14:38 Thinning In Matlab\Thinning In Matlab\Condition2.m
文件 646 2010-04-19 14:37 Thinning In Matlab\Thinning In Matlab\Testthin.m
文件 7680 2010-04-19 21:35 Thinning In Matlab\Thinning In Matlab\Thumbs.db
文件 1537 2010-04-19 16:26 license.txt
- 上一篇:使用VC实现EXCEL的函数库
- 下一篇:数字滤波器GUI设计
评论
共有 条评论