I am trying to write a simple program to read a bmp image in gray scale. I have a set of patterns (the whole alphabet except for 'I') and I want to match them. I have problems doing this in Matlab.
What I got so far:
clear
clc
%set of patterns
BW1 = imread('alphabet.bmp');
patterns = bwlabel(~BW1);
patternStats = regionprops(patterns,'all');
patternNumber = size(patternStats);
imagePatternArray = cell(patternNumber);
%make cell array of pattern vectors
for i = 1:1:patternNumber
imageMatrix = patternStats(i).Image;
imageVector = imageMatrix(:);
imagePatternArray{i} = imageVector;
end
%set of chars
BW2 = imread('text.bmp');
text = bwlabel(~BW2);
textStats = regionprops(text,'all');
letterNumber = size(textStats);
imageLetterArray = cell(letterNumber);
%make cell array of text vectors
for i = 1:1:letterNumber
imageMatrix = textStats(i).Image;
imageVector = imageMatrix(:);
imageLetterArray{i} = imageVector;
end
%lookup table
charSet =['A','B','C','D','E','F','G','H','J','K','L','M','N','O','P','Q','R','S','T','U','V','W','X','Y','Z'];
Now I would like to compare the pattern vectors with the given vector, but they have different sizes.
How can I do this? Is there some special compare function? Should I add 0s to the end and then calculate the distance with pdist
?