资源简介
matlab Stroke width transform
代码片段和文件信息
function [ letters ] = extractletters( swtMap swtLabel ccNum )
%LETTERCANDIDATES Summary of this function goes here
% Detailed explanation goes here
numLetters = 0;
letters = zeros(size(swtLabel));
maxLetterHeight = 300;
minLetterHeight = 10;
for i=1:ccNum
[rc] = find(swtLabel==i);
idx = sub2ind(size(swtMap)rc);
componentSW = swtMap(idx);
varianceSW = var(componentSW);
meanSW = mean(componentSW);
width = max(c) - min(c);
height = max(r) - min(r);
aspectRatio = width/height;
diameter = sqrt(width^2+height^2);
medianSW = median(componentSW);
maxSW = max(componentSW);
% Accepted font heights are between 10px and 300px
if height>maxLetterHeight | height
% Reject CC with hight stroke width variance. The threshold if half
% the average stroke width of a connected component
if varianceSW/meanSW > .5 continue end
% Ratio between the diameter of the connected component and its
% median stroke width to be a value less than 10
if diameter/medianSW >= 10 continue end
% Aspect ratio to be a value between 0.1 and 10
if aspectRatio < 0.1 && aspectRatio > 10 continue end
if size(componentSW1)/maxSW < 5 continue end
if width > height*2.5 continue end
letters(idx) = 1;
% if varianceSW <= meanSW*0.5
% %if 0.1 <= aspectRatio && aspectRatio <= 10
% numLetters = numLetters + 1;
% letters(idx) = 1;
% %end
% end
end
end
属性 大小 日期 时间 名称
----------- --------- ---------- ----- ----
目录 0 2014-05-09 12:53 SWT\
文件 82290 2014-05-07 12:29 SWT\1196.jpg
目录 0 2014-05-09 13:12 __MACOSX\
目录 0 2014-05-09 13:12 __MACOSX\SWT\
文件 172 2014-05-07 12:29 __MACOSX\SWT\._1196.jpg
文件 33218 2014-05-07 12:29 SWT\1313.jpg
文件 172 2014-05-07 12:29 __MACOSX\SWT\._1313.jpg
文件 23934 2014-05-07 12:29 SWT\1324.jpg
文件 172 2014-05-07 12:29 __MACOSX\SWT\._1324.jpg
文件 47607 2014-05-07 12:29 SWT\1351.jpg
文件 172 2014-05-07 12:29 __MACOSX\SWT\._1351.jpg
文件 39571 2014-05-07 12:29 SWT\1389.jpg
文件 172 2014-05-07 12:29 __MACOSX\SWT\._1389.jpg
文件 35008 2014-05-07 12:29 SWT\1470.jpg
文件 172 2014-05-07 12:29 __MACOSX\SWT\._1470.jpg
文件 35489 2014-05-07 12:29 SWT\1485.jpg
文件 172 2014-05-07 12:29 __MACOSX\SWT\._1485.jpg
文件 36147 2014-05-09 12:53 SWT\19-139-thickbox.jpg
文件 18823 2014-05-07 12:29 SWT\2935-238x300.jpg
文件 172 2014-05-07 12:29 __MACOSX\SWT\._2935-238x300.jpg
文件 298255 2014-05-09 12:53 SWT\6d968876fef7d65b7f706b7941a8c9ab.jpg
文件 1549 2014-05-09 00:39 SWT\extractletters.m
文件 120 2014-05-09 00:39 __MACOSX\SWT\._extractletters.m
文件 1818 2014-05-09 00:40 SWT\label.m
文件 120 2014-05-09 00:40 __MACOSX\SWT\._label.m
文件 5823 2014-05-09 12:54 SWT\swt.m
文件 120 2014-05-09 12:54 __MACOSX\SWT\._swt.m
文件 5817 2014-05-09 12:15 SWT\swt.m~
文件 505 2014-05-09 12:55 SWT\SWT_demo.m
文件 120 2014-05-09 12:55 __MACOSX\SWT\._SWT_demo.m
评论
共有 条评论