hist2d.m

来自「一种彩色分割的算法,基于各个波段进行分割,然后将分割的结果进行融合」· M 代码 · 共 25 行

M
25
字号
function [his2]=hist2D(im)
%HIST2D is to generate the 2-D histogram based on the cooccurence matrics
%IM is the imput, hist2 is the output 2D 256-by-256 metrics
%Programmed by Dr. Yingzi (Eliza) Du

his2=zeros(256); %to rember the 2-D histogram

co=size(im,1);
ro=size(im,2);
%get the 2-D histogram
for i=1:co-1
   for j=1:ro-1
      his2(im(i,j)+1,im(i+1,j)+1)=his2(im(i,j)+1,im(i+1,j)+1)+1;
      his2(im(i,j)+1,im(i,j+1)+1)=his2(im(i,j)+1,im(i,j+1)+1)+1;
  end;
end;

for j = 1:ro-1
    his2(im(co,j)+1,im(co,j+1)+1)=his2(im(co,j)+1,im(co,j+1)+1)+1;
end;

his2=his2./sum(sum(his2));


⌨️ 快捷键说明

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