📄 colorhist.m
字号:
function [histogram]=colorhistogram(imIn,nBinsD,varargin)
%make color histogram
% hist=colorhistogram(imIn,nBinsD,imMask,sigma)
%
% Author: Z.Zivkovic
% Date: 21-6-2003
nBins=nBinsD^3;
hist=zeros(nBins,1);%RGB
nPoints=size(imIn,1)*size(imIn,2);
H=zeros(nPoints,nBins);
imIn=double(reshape(imIn,nPoints,3));
if (nargin==3)
%use kernel mask
imMask=varargin{1};
imMask=reshape(imMask,1,nPoints);
else
imMask=ones(1,nPoints)./nPoints;
end
nDiv=256/nBinsD;
imIn=floor(imIn/nDiv);
%H
for i=1:nPoints
iBin=nBinsD^2*imIn(i,1)+nBinsD*imIn(i,2)+imIn(i,3);
if (~isnan(iBin))
H(i,iBin+1)=1;
end
end
hist=imMask*H;
histogram.data=hist;
histogram.H=H;
histogram.nBinsD=nBinsD;
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -