Page 102 - Algorithm Collections for Digital Signal Processing Applications using MATLAB
P. 102

90                                                         Chapter 3

              Note that CM = TM’ *  CT  * TM

              As the pixel positions of the image are represented as positive integers,
           are transformed vectors are properly biased and rounded off.

           1.3      Matlab Program


              ___________________________________________________________

              hotellinggv.m

              A=imread('Binimage','bmp');
              A=double(A);
              [x,y]=find(A==0);
              vector=[x y];
              Meanvector=sum(vector)/length(vector);
              CM=(vector'*vector)/length(vector);
              CM=CM-Meanvector'*Meanvector;
              %Covariance matrix for the original set of vectors is CM
              [E,V]=eig(C);
              %Transformation Matrix
              TM=E';
              transvector=TM*(vector'-repmat(Meanvector',1,length(vector)));
              xposition=fix(transvector(1,:)+abs(min(transvector(1,:)))+1);
              yposition=fix(transvector(2,:)+abs(min(transvector(2,:)))+1);
              B=zeros(50,50);
              for i=1:1:length(xposition)
                  B(xposition(i),yposition(i))=1;
              end
              %Covariance matrix computed for transformed vectors is computed as CT
              MeanvectorT=sum(transvector')/length(transvector');
              CT=(transvector*transvector')/length(transvector');
              CT=CT-MeanvectorT'*MeanvectorT;
              figure
              subplot(2,1,1)
              imshow(A)
              title('ORIGINAL IMAGE')
              subplot(2,1,2)
              imshow(uint8(B*255))
              title('TRANSFORMED IMAGE USING HOTELLING TRANSFORMATION')
              ___________________________________________________________
   97   98   99   100   101   102   103   104   105   106   107