Starting from:
$35

$29

Assignment A7: Image Features Solution


    1. Use image called MASK in file chars45.mat to study shape analysis using Hu’s moments for the characters:


A,B,C,D,E,F,G,H,I,K,L,M,N,O,R,S,T,U,V,Y

a,c,d,e,f,g,h,i,k,l,m,n,o,p,r,s,t,u,v,y

0,1,2,3,4,5,6,7,8,9


Use a character from the image as a model, (A1, (A2, (A3, (A4, (A5, (A6), for each charac-ter above. Develop the functions listed below and report performance in terms of overall and per character success.


function Mpq = CS4640_central_moment(pts,p,q)

    • CS4640_central_moment - compute a central moment
    • Mpq = sum sum (xˆp*yˆq)
%    x    y

    • On input:

    • pts (nx2 array): row and cols of points

    • p (int): exponent for x

    • q (int): exponent for y

    • On output:

    • Mpq (float): Mpq moment

    • Call:

    • M00 = CS4640_central_moments([1 1; 2 2; 3 3],0,0);

    • Author:

    • T. Henderson

1





    • UU

    •  

    • 
function Epq = CS4640_normal_moment(pts,p,q)

    • CS4640_normal_moment - compute a central normal moment

%    Epq = <pq/M00ˆb    where b = 1+(p+q)/2

    • On input:

    • pts (nx2 array): row and cols of points

    • p (int): exponent for x

    • q (int): exponent for y

    • On output:

    • Epq (float): Epq moment

    • Call:

    • E00 = CS4640_normal_moment([1 1; 2 2; 3 3],0,0);

    • Author:

    • T. Henderson

    • UU

    •  

%

function H = CS4640_Hu_moments(pts)

    • CS4640_Hu_moments - compute Hu’s 6  moments

    • On input:

    • pts (nx2 array): row and cols of points

    • On output:

    • H (6x1 vector): Hu moments

    • Call:

    • H = CS4640_Hu_moments([1 1; 2 2; 3 3]);

    • Author:

    • T. Henderson

    • UU

    •  

%

function H_models = CS4640_Hu_build(templates)

    • CS4640_Hu_models - produce Hu models for image templates

    • On input:

    • templates (n-element vector struct): template images

    • (k).im (MxN binary image): image template

    • On output:

    • H_models (nx7 array): Hu models

    • Call:

    • Hm = CS4640_Hu_models(templates);

2





    • Author:

    • T. Henderson

    • UU

    •  

%

function classes = CS4640_Hu_classify(im,H_models)

    • CS4640_Hu_classify - classify characters using Hu models

    • On input:

    • im (MxN binary image): input image

    • H_models (nx7 array): Hu models for n characters

    • On output:

    • classes (kx2 array): class and distance for each CC

    • Call:

    • Hm = CS4640_Hu_classify(im,Hm);

    • Author:

    • T. Henderson

    • UU

    •  

%




    2. Implement an eigenchars classification approach similar to the eigenfaces method dis-cussed in the text. Develop a template database of 100 images (2 examples of each charac-ter). Build the models and then report performance on overall and per character success on MASK from chars45.mat. Develop the following functions.


function classes = CS4640_Hu_classify(im,H_models)

    • CS4640_Hu_classify - classify characters using Hu models

    • On input:

    • im (MxN binary image): input image

    • H_models (nx7 array): Hu models for n characters

    • On output:

    • classes (kx2 array): class and distance for each CC

    • Call:

    • Hm = CS4640_Hu_classify(im,Hm);

    • Author:

    • T. Henderson

    • UU

    •  

%

3





function [V,MM,PCA_models] = CS4640_PCA_model(templates)

    • CS4640_PCA_model - build PCA model from templates

    • On input:

    • templates (vector struct): n template images

    • (k).im (MxN binary array): template image for character k

    • On output:
    • V (M*nxM*n array): eigenvectors
    • MM (M*nx1 vector): mean vector
    • PCA_models (nxk array): weight values for first k eigenvectors

    • Call:

    • [V,MM,PCA_models] = CS4640_PCA_model(templates);

    • Author:

    • T. Henderson

    • UU

    •  

%

function c = CS4640_PCA_classify(im,V,MM,PCA_models)

    • CS4640_PCA_classify - classify image using PCA models

    • On input:

    • im (MxN binary array): input image
    • V (M*NxM*N array): eigenvectors
    • MM (M*Nx1 vector): mean vector
    • PCA_models (nxk array): weight values for first k eigenvectors

    • On output:

    • c (int): class

    • Call:

    • [V,MM,PCAm] = CS4640_PCA_model(templates);

    • Author:

    • T. Henderson

    • UU

    •  

%













4

More products