I want to recognize only the handwriting numbers (blue color). I attached my code, it can only recognize the printed numbers. I used Mnist database to recognize them. How to recognize only the handwriting numbers?

1 回表示 (過去 30 日間)
testnumber3.jpg
clear all
clc
load('MnistConv.mat');
I = imread('testnumber3.jpg');
% flipImage=flip(I,2);
% rotate=imrotate(flipImage,180);
image(I)
% Convert to grayscale image
Igray = double(rgb2gray(I));
% Convert to binary image
Ibw1 = im2bw(Igray,graythresh(Igray));
Ibw=(256-Igray)/256;
% Ibw = im2bw(Igray,graythresh(Igray));
% Edge detection
Iedge = edge(Ibw,'Roberts');
% Morphology
% * *Image Dilation*
se = strel('square',2);
Iedge2 = imdilate(Iedge, se);
% * *Image Filling*
Ifill= imfill(Iedge2,'holes');
[Ilabel num] = bwlabel(Ifill);
disp(num);
Iprops = regionprops(Ilabel);
Ibox = [Iprops.BoundingBox];
Ibox = reshape(Ibox,[4 num]);
% Plot the Object Location
hold on;
for cnt = 1:num
kotak=rectangle('position',Ibox(:,cnt),'edgecolor','r');
crop=imcrop(Ibw,Ibox(:,cnt));
% Resizing
imgLGE = imresize(crop, 5, 'bicubic');
X = abs(imresize(imgLGE, [28 28]));
for i=1:28
for j=1:28
if X(i,j)<0.
X(i,j)=0;
elseif X(i,j)>0.5
X(i,j)=X(i,j)+0;
end
end
end
k=1;
x = X(:, :, k); % Input, 28x28
y1 = Conv(x, W1); % Convolution, 20x20x20
y2 = ReLU(y1); %
y3 = Pool(y2); % Pool, 10x10x20
y4 = reshape(y3, [], 1); % 2000
v5 = W5*y4; % ReLU, 360
y5 = ReLU(v5); %
v = Wo*y5; % Softmax, 10
y(:,cnt) = Softmax(v); %
end
[max,result]=max(y);
result1.jpg

採用された回答

Prabhan Purwar
Prabhan Purwar 2019 年 8 月 28 日
Hey,
Assumption: This solution is justified only for cases having handwritten images in a different color to that of computer-generated and background.
Regionprops() function in MATLAB works well for BW images with well-defined boundaries as illustrated in its algorithm.
In the present scenario input to the function is as follows:
image.jpg
In order to get defined boundaries, make use of Color Thresholder app (using colorThresholder command) with spectrum settings as shown
Capture.JPG
Output after giving the following image as input is shown below
imageo.jpg
Once we segregate proper boxsets, by thresholding them based on box area, they can be further given as input to the neural network for recognition.
Although, more advanced techniques can be employed for this task, as linked below

その他の回答 (0 件)

製品


リリース

R2018b

Community Treasure Hunt

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

Start Hunting!

Translated by