Split the license plate letters

1 Ansicht (letzte 30 Tage)
Blazej Staniak
Blazej Staniak am 29 Nov. 2021
Kommentiert: yanqi liu am 30 Nov. 2021
Hi, I need to split the license plate letters. My program consists in uploading a photo, finding the image of the license plate and cutting out the plate. I just need to split the numbers and letters of this array right now. I don't know exactly how to do this. Does anyone know how it should look like? I will present the effect that I want to achieve in the attachment. The result he wants to achieve is shown on the first appendix
Regards

Antworten (1)

yanqi liu
yanqi liu am 29 Nov. 2021
yes,sir,may be use
clc; clear all; close all;
img = imread('https://ww2.mathworks.cn/matlabcentral/answers/uploaded_files/807304/obraz_2021-11-20_110914.png');
img2 = imcrop(img, [94 129 1086 217]);
bw = im2bw(img2);
bw = ~bw;
bw = imclearborder(bw);
bw = bwareaopen(bw, round(numel(bw)*0.01));
[L,num] = bwlabel(bw);
stats = regionprops(L);
rects = cat(1, stats.BoundingBox);
rects = sortrows(rects, 1);
ims = [];
figure('Color', [0.8 0.8 0.8]);
for i = 1 : size(rects, 1)
ims{i} = imcrop(img2, round(rects(i,:)));
bwi = ~im2bw(ims{i});
bwi = imresize(bwi, [48 28], 'bilinear');
subplot(1,size(rects, 1),i); imshow(bwi, []);
end
  2 Kommentare
Blazej Staniak
Blazej Staniak am 29 Nov. 2021
Iprops=regionprops(im4,'BoundingBox','Area', 'Image');
area = Iprops.Area;
count = numel(Iprops);
maxa= area;
boundingBox = Iprops.BoundingBox;
for i=1:count
if maxa<Iprops(i).Area
maxa=Iprops(i).Area;
boundingBox=Iprops(i).BoundingBox;
end
end
im = imresize(im4, [240 NaN]);
im = imopen(im, strel('rectangle', [4 4]));
im = imcrop(im3, boundingBox);%wyciecie tablicy
%%figure(5); imshow(im)
im = bwareaopen(~im, 1000); %usuniece obiektow jesli szerokosc jest za dluga lub za krotka niz 500
im_neg = imcomplement(im);
%%figure(6), imshowpair(im,im_neg,'montage');
labeledImage= bwlabel(im);
this is part of my code, I just need to add a few lines to make it work the way you presented
yanqi liu
yanqi liu am 30 Nov. 2021
clc; clear all; close all;
img = imread('https://ww2.mathworks.cn/matlabcentral/answers/uploaded_files/807304/obraz_2021-11-20_110914.png');
img2 = imcrop(img, [94 129 1086 217]);
bw = im2bw(img2);
bw = ~bw;
bw = imclearborder(bw);
im4 = bwareaopen(bw, round(numel(bw)*0.01));
Iprops=regionprops(im4,'BoundingBox','Area', 'Image');
area = Iprops.Area;
count = numel(Iprops);
maxa= area;
boundingBox = Iprops.BoundingBox;
for i=1:count
if maxa<Iprops(i).Area
maxa=Iprops(i).Area;
boundingBox=Iprops(i).BoundingBox;
end
end
im = imresize(im4, 240/size(im4, 1), 'bilinear');
im = imopen(im, strel('rectangle', [4 4]));
%%figure(6), imshowpair(im,im_neg,'montage');
im = imclose(im, strel('rectangle', [2 2]));
labeledImage= bwlabel(im);
% use the follow code
stats = regionprops(labeledImage);
rects = cat(1, stats.BoundingBox);
rects = sortrows(rects, 1);
ims = [];
figure('Color', [0.8 0.8 0.8]);
for i = 1 : size(rects, 1)
imi = imcrop(im, round(rects(i,:)));
imi = imresize(imi, [48 28], 'bilinear');
subplot(1,size(rects, 1),i); imshow(imi, []);
end

Melden Sie sich an, um zu kommentieren.

Kategorien

Mehr zu Read, Write, and Modify Image finden Sie in Help Center und File Exchange

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by