cut.m

来自「车牌识别的matlab程序。十分新颖的程序。有兴趣可以」· M 代码 · 共 41 行

M
41
字号
function [image] = cut_bw_img(bwImage, noise_amp, direction);
% cut_bw_img: Cuts from the supplied pictures all the corners until a
% signal with intensity greater than "moise_amp" is encountered. If
% direction is zero the corners correspond to the left and right sides of
% the image, otherwise, they correspond to the up and down corners.

% summing colums/lines:
if direction == 0
    hist = sum(bwImage);
else
    hist = sum(bwImage');
end;

left = 1;
right = 1;

% treating one side:
for i = 1 : length(hist)
    if(hist(i) > noise_amp)
        left = i;
        break;
    end;
end;

% treating the other side:
for j = length(hist) : -1 : 1
    if(hist(j) > noise_amp)
        right = j;
        break;
    end;
end;

% returning the result:
if direction == 0
    image = bwImage(:, left : right);
else
    image = bwImage(left : right, :);
end;
    
return;

⌨️ 快捷键说明

复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?