%This looks for all occurrences of the letter e in a block of text.
%It is a good application of classification of spatially-shifted images.
clear;load text.mat;E=X(24:32,194:200);%E is a 9X7 image of e from the block of text X.
Y=conv2(X,fliplr(flipud(E)),'same');Y(Y<900000)=0;%Threshold cross-correlation of X and E.
figure,imagesc(X),colormap(gray),axis off,title('Image of block of text')
figure,imagesc(Y),colormap(gray),axis off,title('Thresholded cross-correlation')
%Only interested in cross-correlation lying in support of 33X256 text block.
%Scale X and Y so can depict superposition of both using different colors.
Z(:,:,1)=Y(1:33,1:256)/1007814;Z(:,:,2)=X/255;Z(:,:,3)=0;%Superpose X and Y.
figure,imagesc(Z),axis off,title('Superposition of text block and locations of e')
%Cross-correlation found all 7 occurrences of e. Thresholds set by trial-and-error.


