gravcenters.m

来自「《Visual C++数字图像识别技术典型案例》之光学字符识别技术源码」· M 代码 · 共 40 行

M
40
字号
     %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%   %%                                                            %% %%       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 [ gx, gy ] = gravcenters(matrix, width, height)% GRAVCENTERS.M%% function [ gx, gy ] = gravcenters(matrix, width, height)%% Returns the centers of gravity for the matrix "matrix"% which represents a binary image% Calculate the area (0-th moment), and also% M_10(S) and M_01(S)area = 0;m10 = 0;m01 = 0;for y = 1:height,	for x = 1:width,		if matrix(y,x)==1			area = area + 1;			m10 = m10 + x;			m01 = m01 + y;		end	endend% Figure out the center of gravitygx = m10/area;gy = m01/area;

⌨️ 快捷键说明

复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?