image thumbnail

Extraction of car plate region

by

 

it works for certain images.

extraction2.m
i = imread('c2.jpg');
i1 = rgb2gray(i);
i11 = imadjust(i1);



i2 = edge(i11,'canny',0.4);
figure,imshow(i2);
i22 = imclose(i2,se);
figure,imshow(i2);title('canny');
figure,imshow(i22);title('close line');



se = strel('square',2);
i3 = imdilate(i22,se);
i4 = imfill(i3,'holes');

[Ilabel num] = bwlabel(i4);
BW2 = bwareaopen(i4, 1620);
%d=bwmorph(BW2,'remove');
d=medfilt2(BW2,[3 3]);  %median filter
e=imclearborder(d, 4);

[L,NUM]=bwlabel(e,4);
disp(L);




subplot(1,8,1);imshow(i1);title('gray');
subplot(1,8,2);imshow(i2);title('canny');
subplot(1,8,3);imshow(i3);title('dilate');
subplot(1,8,4);imshow(i4);title('fill holes');
subplot(1,8,5);imshow(BW2);title('connected');
subplot(1,8,6);imshow(d);title('median filter');
subplot(1,8,7);imshow(e);title('clear border');
subplot(1,8,8);imshow(i11);title('adjust');



for i=1:NUM
    figure,imshow(L==i),title('object i');
   % figure,imhist(L==i);
    %J = imcrop(L==i,[60 40 100 90]);
    % figure,imshow(X2);title('cropped');
   
    
    pause(1);
end





disp(num);



Contact us