How to extract character and number only from this image to .txt?
1 次查看(过去 30 天)
显示 更早的评论
![](https://www.mathworks.com/matlabcentral/answers/uploaded_files/1252982/image.png)
This is the last figure from erode.
close all;
clear all;
%open original image/rgb image
im = imread('2.jpeg');
imshow(im)
%crop the number plate area
img = imcrop(im, [140 620 610 380]);
f1 = figure;
%convert RGB to grayscale image
imgray = rgb2gray(img);
imshow(imgray)
f2 = figure;
%edge detection from grayscale using sobel method
e = edge(imgray, 'sobel');
imshow(e)
f3 = figure;
%to make the image more thicker
se90 = strel('line',4,90);
se0 = strel('line',4,0);
s = imdilate(e,[se90 se0]);
imshow(s)
f4 = figure;
% Use bwareaopen to delete objects smaller than minSize
g = bwareaopen(s, 150,8);
% g = bwareaopen(g, 1100, 8);
imshow(g)
f5 = figure;
% Using imclearborder to delete object that touch border of the image
h = imclearborder(g);
imshow(h)
f6 = figure;
% to make the image more thinner
se = strel('line',5,45);
f = imerode(h,se);
imshow(f)
f7 = figure;
Please help me about that. Thanks by now for your attention.
0 个评论
回答(1 个)
Kevin Holly
2023-1-6
You could use the optical character recognition (ocr) function that comes with the image processing and computer vision toolbox as such:
img = imread('2.jpeg');
imshow(img)
cropped_img = img(850:950,300:700,:);
imshow(cropped_img)
License = ocr(cropped_img, 'TextLayout', 'line', 'CharacterSet', 'ABCDEFGHIJKLMNOPQRSTUOVWXYZ0123456789')
License.Text
writelines(License.Text,"temp.txt")
0 个评论
另请参阅
产品
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!