How to obtain a smaller matrix for an input image in neural network training

2 views (last 30 days)
Hi! I'm currently new with Neural networks. I'm working on a project that would recognize handwritten numbers and letters. I've read different sources online on regarding the pre-processing o the image and the training of the network. However, I'm stuck on how to get the binary representation of the image.
Here are the steps I've done so far in image processing: 1. Read image 2. Convert to bw 3. Detect edges and crop 4. Resize image to 42x24 5. Skeletonization
These seem to work well, however the performance and accuracy I got was low. From the sources I found online, the matrix size of their image was small (e.g. 8x6 in this article http://airccse.org/journal/jcsit/0211ijcsit07.pdf). I tried resizing my image/matrix but those doesn't seem to work. Any thoughts on how I can obtain a smaller matrix for my image?
Below is a sample input image I use.
Code:
for k = 1
baseFileName = pngFiles(k).name;
fullFileName = fullFile(imgPath, baseFileName);
X = imread(fullFileName);
threshold = graythresh(X);
X =~im2bw(X,threshold); %convert image to bw
X = bwareaopen(X,30);%threshold
s = regionprops(X, 'BoundingBox');%detect edges
imCrop = imcrop(X, s.BoundingBox); %crop image
%figure, imshow(imCrop);
Y = imresize(imCrop, [42 24]); %resize image
BW2 = bwmorph(Y,'skel',Inf);%skeletonization
%figure, imshow(BW2);
disp(BW2)
col = sum(BW2,1);
NormCol = col/42;
TarNumOne(:,k) = NormCol;
end
Thank you very much!

Answers (1)

Image Analyst
Image Analyst on 29 Aug 2015
The smaller you resize your image to, the cruder it becomes, and harder to recognize. Nonetheless, if you want an 8x6 array, then why did you resize to a 42x42 array?

Community Treasure Hunt

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

Start Hunting!