function [bw, crop] = extract_LP(pic1);
% extract_LP: Extracts the License Plate from the supplied picture. Returns
% a binary image which contains the normalized LP, and the rgb picture of
% the LP precisely cropped from the image given in parameter.
load global_var.mat;
% chosen size for the normalized LP.
XSIZE = 50;
YSIZE = 150;
% Yellow region extraction:
yellow_pic = extract_yellow_region(pic1);
display_picture(yellow_pic, debug1 + debug2, 'Yellow Regions Filter:', 3);
% Fixing the LP Region:
[x, x2, y, y2] = detect_lp_area(yellow_pic, 50);
lp_area = pic1(y:y2, x:x2, :);
display_picture(lp_area, debug1 + debug2, 'License Plate Region:', 3);
% Fixing the LP angle and rotating the ROI accordingly:
[angle, lines] = find_angle(lp_area);
if(debug1 + debug2 ~= 0)
load global_var.mat;
if is_killed == 1
close all;
return;
end;
subplot(2,2,3), imshow(pic1(y:y2, x:x2, :)); draw_lines(lines); title('Determining the angle of the plate using the Radon transform:');
pause(speed);
end;
pic = imrotate(yellow_pic(y:y2, x:x2), angle, 'bilinear'); % Used to show the rotation on the GUI only..
display_picture(pic, debug1 + debug2, 'Yellow Region Rotated:', 3);
% improving the LP region on the smaller rotated region obtained before:
[small_pic, xx, xx2, yy, yy2] = improved_lp_area(pic, angle);
display_picture(small_pic, debug2, 'Improved License Plate region:', 4);
display_picture('internal_images/black.jpg', debug2, '', 4, 0);
display_picture(small_pic, debug1 + debug2, 'Improved License Plate region:', 3, 0);
display_picture('internal_images/black.jpg', debug2, '', 2, 0);
% cropping the LP:
[image, RECTx, RECTy] = crop_lp(small_pic, lp_area, xx, xx2, yy, yy2, angle);
display_picture('internal_images/black.jpg', debug2, '', 2, 0);
crop = image; % output...
display_picture(image, debug2, 'LP Crop:', 4);
display_picture('internal_images/black.jpg', debug2, '', 4, 0);
display_picture(image, 1, 'LP Crop:', 3);
% Image quantization:
[grayImage, quantImage, bw] = quantizeImage(image);
display_picture(grayImage, debug1 + debug2, 'Gray Scale LP:', 3);
display_picture(quantImage, debug2, 'LP Quantisation and Equalization:', 4);
display_picture('internal_images/black.jpg', debug2, '', 4, 0);
display_picture(quantImage, debug1 + debug2, 'LP Quantisation and Equalization:', 3);
display_picture(bw, debug1 + debug2, 'Binary LP:', 3);
% Normalized LP:
bw = normalized_lp(bw, RECTx, RECTy, XSIZE, YSIZE);
display_picture(imcomplement(bw), debug2, 'Normalized LP:', 4);
display_picture('internal_images/black.jpg', debug2, '', 4, 0);
display_picture(imcomplement(bw), debug1 + debug2, 'Normalized LP:', 3);
% Adjusting the LP horizontal contours: (the vertical contours are not
% adjusted in order not to cut digits: this will be done transparently by
% the segmentation machine.
bw = normalized_lp_contour(bw, [XSIZE, YSIZE]);
display_picture(bw, debug2, 'LP Horizontal Contours Adjusted:', 4);
display_picture('internal_images/black.jpg', debug2, '', 4, 0);
display_picture(bw, debug1 + debug2, 'LP Horizontal Contours Adjusted:', 3);
return;
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% detect_lp_area
% Finds the License Plate region in a RGB picture with the supplied safety
% spacing around the plate, and returns the coordinates of the found region.
function [x, x2, y, y2] = detect_lp_area (yellow_pic, spacing);
LP_MIN_AREA = 2670;
LP_MAX_RATIO = 0.67;
LP_MIN_RATIO = 0.16;
% Dilating the yellow regions:
dilated_pic = imdilate(yellow_pic, strel('diamond', 5));
load global_var.mat;
display_picture(dilated_pic, debug1 + debug2, 'Yellow Region Dilated:', 3);
% Separating the pictures into connected components:
stat = imfeature(bwlabel(dilated_pic));
% Selecting the license plates from the candidates in stat.
% The chosen area is the deepest region in the frame which has the
% following properties:
% area > LP_MIN_AREA
% LP_MIN_RATIO <= height/width <= LP_MAX_RATIO
% area >= max(areas of the candidates)/3.5
depth = -1;
for i = 1 : length([stat.Area])
if stat(i).BoundingBox(2) >= depth && stat(i).Area > LP_MIN_AREA && ...
stat(i).BoundingBox(4) <= LP_MAX_RATIO*stat(i).BoundingBox(3) && ...
stat(i).BoundingBox(4) >= (LP_MIN_RATIO)*stat(i).BoundingBox(3) && stat(i).Area >= max([stat.Area])/3.5
depth = stat(i).BoundingBox(2);
end;
end;
% finding the components which are at the depth "depth":
r = [];
for i = 1 : length([stat.Area])
if stat(i).BoundingBox(2) == depth && stat(i).Area > LP_MIN_AREA && ...
stat(i).BoundingBox(4) <= LP_MAX_RATIO*stat(i).BoundingBox(3) && ...
stat(i).BoundingBox(4) >= (LP_MIN_RATIO)*stat(i).BoundingBox(3) && stat(i).Area >= max([stat.Area])/3.5
r = [r stat(i).Area];
end;
end;
% if we did not find any region with the above criterion, taking the
% candidate of maximum area.
if(length(r) == 0)
index = (find([stat.Area] == max([stat.Area])));
else
% otherwise, taking the candidate with maximum area from the
% filtered candidates:
index = (find([stat.Area] == max(r)));
end;
% set the coordinates of the supposed license plate region:
x = max(floor(stat(index).BoundingBox(1) - spacing), 1);
y = max(floor(stat(index).BoundingBox(2) - spacing), 1);
width = ceil(stat(index).BoundingBox(3) + 2*spacing);
height = ceil(stat(index).BoundingBox(4) + 2*spacing);
y2 = min(y + height, size(yellow_pic, 1));
x2 = min(x + width, size(yellow_pic, 2));
return;
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% Returns an improved LP area running again the algorithm in the function
% detect_lp_area with zero spacing and on the smaller rotated pictures
% given as parameter.
function [pic, x1, x2, y1, y2] = improved_lp_area(image, angle);
[x1,x2,y1,y2] = detect_lp_area(image, 0);
pic = image(y1:y2, x1:x2);
return;
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
function [image, RECTx, RECTy] = crop_lp(pic, lp_area, x1, x2, y1, y2, angle);
rec = find_lp_location(pic);
image = imrotate(lp_area, angle, 'bilinear');
image = image(y1:y2, x1:x2, :);
RECTy = [rec(2), rec(2), rec(2) + rec(4), rec(2) + rec(4)];
RECTx = [rec(1), rec(1) + rec(3), rec(1) + rec(3), rec(1)];
image = imcrop(image, rec);
return;
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% find_lp_location: Returns the coordinates of the LP rectangle inside the
% supplied small picture: uses "find_contours" for the sum of the lines and of the
% columns in the picture.
function [rec] = find_lp_location(im);
load global_var.mat;
p1 = sum(im);
plot_vector(p1, 4, 'Adjusting the LP Vertical Contours - Columns Sum Graph:', debug2);
[x1, x2] = find_contours(p1);
p2 = sum(im');
plot_vector(p2, 2, 'Adjusting the LP Horizontal Contours - Lines Sum Graph:', debug2);
[y1, y2] = find_contours(p2);
rec = [x1, y1, x2-x1, y2-y1];
return;
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% find_contours: Returns the x-coordinates respectively of the first point at
% the left and the first point at the right of the vector which is superior
% or equal to the average of the vector. This permits to delimit the plate
% eliminating noises around it.
function [index1, index2] = find_contours(vec);
avg = mean(vec);
% left side:
for j = 1 : length(vec)
if(vec(1,j) <= avg)
continue;
end;
index1 = j - 1;
break;
end;
% right side:
for j = length(vec) : -1 : 1
if(vec(1,j) <= avg)
continue;
end;
index2 = j + 1;
break;
没有合适的资源?快使用搜索试试~ 我知道了~
matlab.rar_matlab 车牌_matlab 车牌识别_车牌识别 matlab_车牌识别程序 MATLAB
共72个文件
jpg:50个
m:15个
db:2个
1.该资源内容由用户上传,如若侵权请联系客服进行举报
2.虚拟产品一经售出概不退款(资源遇到问题,请及时私信上传者)
2.虚拟产品一经售出概不退款(资源遇到问题,请及时私信上传者)
版权申诉
5星 · 超过95%的资源 2 下载量 122 浏览量
2022-09-21
04:22:10
上传
评论
收藏 3.86MB RAR 举报
温馨提示
使用matlab平台的车牌识别程序,已经条是通过,希望大家多多交流
资源推荐
资源详情
资源评论
收起资源包目录
matlab.rar (72个子文件)
matlab车牌识别
Matlab
extract_LP.m 10KB
images
im30.JPG 34KB
im37.JPG 50KB
im15.JPG 63KB
im9.jpg 38KB
im1.jpg 94KB
im20.jpg 39KB
im27.JPG 79KB
im31.JPG 94KB
im34.JPG 124KB
im10.JPG 62KB
im28.JPG 109KB
im13.JPG 57KB
im41.jpg 160KB
im7.jpg 32KB
im24.JPG 135KB
im45.jpg 133KB
im44.jpg 113KB
im16.JPG 18KB
im6.JPG 25KB
im12.jpg 35KB
im17.jpg 73KB
im11.JPG 25KB
im4.jpg 93KB
im42.JPG 182KB
im23.jpg 72KB
im22.jpg 115KB
im25.JPG 74KB
im19.jpg 144KB
im38.jpg 33KB
im36.jpg 58KB
im32.JPG 25KB
im29.jpg 111KB
Thumbs.db 166KB
im2.jpg 59KB
im5.jpg 85KB
im18.JPG 75KB
im33.jpg 184KB
im14.JPG 25KB
car.jpeg 73KB
im3.jpg 73KB
im40.JPG 77KB
im26.JPG 36KB
im8.jpg 15KB
im35.JPG 126KB
im43.jpg 203KB
im21.JPG 47KB
im39.jpg 111KB
draw_lines.m 606B
net.mat 63KB
find_optimal_threshold.m 2KB
cleanScreen.m 278B
plot_vector.m 322B
hs_err_pid3720.log 14KB
display_picture.m 457B
find_angle.m 1KB
character_segmentation.m 6KB
internal_images
title.jpg 41KB
black.jpg 7KB
title2.JPG 27KB
title4.jpg 24KB
Thumbs.db 13KB
title3.jpg 30KB
cut_bw_img.m 906B
horizontal_crop.m 2KB
OCR.m 3KB
go.m 1KB
quantizeImage.m 857B
global_var.mat 327B
extract_yellow_region.m 1KB
run.m 6KB
www.pudn.com.txt 218B
共 72 条
- 1
资源评论
- xiaojin002362024-01-18资源很受用,资源主总结的很全面,内容与描述一致,解决了我当下的问题。
- m0_716848782023-05-28超级好的资源,很值得参考学习,对我启发很大,支持!
周楷雯
- 粉丝: 80
- 资源: 1万+
下载权益
C知道特权
VIP文章
课程特权
开通VIP
上传资源 快速赚钱
- 我的内容管理 展开
- 我的资源 快来上传第一个资源
- 我的收益 登录查看自己的收益
- 我的积分 登录查看自己的积分
- 我的C币 登录后查看C币余额
- 我的收藏
- 我的下载
- 下载帮助
安全验证
文档复制为VIP权益,开通VIP直接复制
信息提交成功