Improved License Plate Localization
1.) Localization:
clear all;
close all;
clc;
rgb = imread("HPIM0929.JPG");
figure
imshow(rgb)
gray = rgb2gray(rgb);
figure
imshow(gray)
resized = imresize(gray,[480 640]);
figure
imshow(resized)
tophat = imtophat(resized,strel('rectangle',[3 25]));
figure
imshow(tophat)
T = graythresh(tophat);
BW = imbinarize(tophat,T);
figure
imshow(BW)
open = imopen(BW,strel('arbitrary',[1 1 1 1;1 1 1 1]));
figure
imshow(open)
closed = imclose(open,strel('rectangle',[3 11]));
figure
imshow(closed)
2.) Optimal SE(structuring element)
clear all;
close all;
clc;
rgb = imread('4.JPG');
gray = rgb2gray(rgb);
resize = imresize(gray,[240 320]);
[rows, columns] = size(resize);
if rows == 240 && columns == 320
for i = 0:15
tophat = imtophat(gray,strel('rectangle',[3 13]));
binary = imbinarize(tophat);
open = imopen(binary,de2bi(i,4));
closed = imclose(open,strel('rectangle',[3 8]));
figure
imshow(closed)
end
elseif rows == 319 && columns == 425
tophat = imtophat(gray,strel('rectangle',[3 18]));
binary = imbinarize(tophat);
open = imopen(binary,strel('arbitrary',[0 1 0;1 1 1;0 1 0]));
closed = imclose(open,strel('rectangle',[3 9]));
figure
imshow(closed)
elseif rows == 480 && columns == 640
for i = 0:15
for j = 0:15
tophat = imtophat(gray,strel('rectangle',[3 25]));
binary = imbinarize(tophat);
open = imopen(binary,[de2bi(i,4);de2bi(j,4)]);
closed = imclose(open,strel('rectangle',[3 11]));
figure
imshow(closed)
end
end
end
Comments
Post a Comment