centralmoment.m
上传用户:zslfgd
上传日期:2010-04-06
资源大小:115k
文件大小:1k
- %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
- %% %%
- %% Prof. Sclaroff's CS585 Image avd Video Processing %%
- %% Project ONE %%
- %% C H A R A C T E R R E C O G N I T I O N %%
- %% %%
- %% by Stanislav Rost %%
- %% ID: 31764117 %%
- %% %%
- %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
- function result = centralmoment(j, k, matrix, width, height)
- % CENTRALMOMENT.M
- %
- % Returns the value for the (j,k)- th central moment of matrix "matrix"
- result = 0;
- [ xcen, ycen ] = gravcenters(matrix, width, height);
- for y = 1:height,
- for x = 1:width,
- if matrix(y,x) == 1
- result = result + (x - xcen)^j*(y - ycen)^k;
- end
- end
- end