MATLAB Answers

0

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?

DONY DARMAWAN PUTRA さんによって質問されました 2019 年 8 月 24 日
最新アクティビティ DONY DARMAWAN PUTRA さんによって コメントされました 2019 年 8 月 28 日
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

  0 件のコメント

サインイン to comment.

製品


リリース

R2018b

1 件の回答

回答者: 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

  1 件のコメント

Thanks Prof Prabhan Purwar, your solution is amazing. It is very helpfull to solve my problem.

サインイン to comment.



Translated by