centralmoment.m
上传用户:zslfgd
上传日期:2010-04-06
资源大小:115k
文件大小:1k
源码类别:

图形/文字识别

开发平台:

Matlab

  1.      %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
  2.    %%                                                            %%
  3.  %%       Prof. Sclaroff's CS585 Image avd Video Processing       %%
  4. %%                         Project  ONE                            %%
  5. %%           C H A R A C T E R   R E C O G N I T I O N             %%
  6. %%                                                                 %%
  7. %%                    by Stanislav Rost                    %%
  8.  %%                       ID:  31764117                           %%
  9.   %%                                                             %%
  10.    %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
  11. function result = centralmoment(j, k, matrix, width, height)
  12. % CENTRALMOMENT.M
  13. %
  14. % Returns the value for the (j,k)- th central moment of matrix "matrix"
  15. result = 0;
  16. [ xcen, ycen ] = gravcenters(matrix, width, height);
  17. for y = 1:height,
  18. for x = 1:width,
  19. if matrix(y,x) == 1
  20. result = result + (x - xcen)^j*(y - ycen)^k;
  21. end
  22. end
  23. end