How to extract character and number only from this image to .txt?

1 Ansicht (letzte 30 Tage)
muizz akram
muizz akram am 5 Jan. 2023
Beantwortet: Kevin Holly am 6 Jan. 2023
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.

Antworten (1)

Kevin Holly
Kevin Holly am 6 Jan. 2023
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 =
ocrText with properties: Text: 'JTT 8525↵↵' CharacterBoundingBoxes: [10×4 double] CharacterConfidences: [10×1 single] Words: {2×1 cell} WordBoundingBoxes: [2×4 double] WordConfidences: [2×1 single]
License.Text
ans =
'JTT 8525 '
writelines(License.Text,"temp.txt")

Kategorien

Mehr zu Image Processing Toolbox finden Sie in Help Center und File Exchange

Produkte

Community Treasure Hunt

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

Start Hunting!

Translated by