radon车牌校正代码 matlab,基于Radon变换车牌矫正(包括垂直矫正和水平矫正)Matlab实现...

clear all

clc

close all

[inputfilename,dirname] = uigetfile('*.*');

inputfilename = [dirname, inputfilename];

im = imread(inputfilename); % For example: 'input.jpg'

grayImage = rgb2gray(im);

%%%%%

%%%%% Edge detection and edge linking....

binaryImage = edge(grayImage,'canny'); % 'Canny' edge detector

binaryImage = bwmorph(binaryImage,'thicken'); % A morphological operation for edge linking

%%%%%

%%%%% Radon transform projections along 180 degrees, from -90 to +89....

% R: Radon transform of the intensity image 'grayImage' for -90:89 degrees.

% In fact, each column of R shows the image profile along corresponding angle.

% xp: a vector containing the radial coordinates corresponding to each row of 'R'.

% Negative angles correspond to clockwise directions, while positive angles

% correspond to counterclockwise directions around the center point (up-left corner).

% R1: A 1x180 vector in which, each element is equal the maximum value of Radon transform along each angle.

% This value reflects the maximum number of pixels along each direction.

% r_max: A 1x180 vector, which includes corresponding radii of 'R1'.

theta = -90:89;

[R,xp] = radon(binaryImage,theta);

imagesc(theta,xp, R); colormap(jet);

xlabel('theta (degrees)');ylabel('x''');

title('theta方向对应的Radon变换R随着x''的变化图');

colorbar

%%%%%

[R1,r_max] = max(R);

theta_max = 90;

while(theta_max > 50 || theta_max

[R2,theta_max] = max(R1); % R2: Maximum Radon transform value over all angles.

% theta_max: Corresponding angle

R1(theta_max) = 0; % Remove element 'R2' from vector 'R1', so that other maximum values can be found.

theta_max = theta_max - 91;

end

correctedImage = imrotate(im,-theta_max); % Rotation correction

correctedImage(correctedImage == 0) = 255; % Converts black resgions to white regions

subplot(1,2,1), subimage(im)

subplot(1,2,2), subimage(correctedImage)

  • 0
    点赞
  • 4
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值