Eliminating(excluding) the while or black color in a color histogram function matlab
조회 수: 2 (최근 30일)
이전 댓글 표시
I have this implementation of a function that performs color histogram on an image. and i would like to exclude and eliminate a particular image. is there a way to do it?
for example i want my function to totally forget about the white color.
I do really appreciate your help
Here's the function code:
function H = colorhist(I, nBins)
%%RGBHIST: color Histogram of an RGB image.
%
% nBins : number of bins per EACH color => histogram is 'nBins^3' long.
% H : The vectorized histogram.
%
if (size(I, 3) ~= 3)
error('rgbhist:numberOfSamples', 'Input image must be RGB.')
end
H=zeros([nBins nBins nBins]);
for i=1:size(I,1)
for j=1:size(I,2)
p=double(reshape(I(i,j,:),[1 3]));
p=floor(p/(256/nBins))+1;
H(p(1),p(2),p(3))=H(p(1),p(2),p(3))+1;
end
end
H=H(:);
% Un-Normalized histogram
H=H./sum(H);
%l1 normalization
end
댓글 수: 0
채택된 답변
Image Analyst
2015년 1월 28일
How are you defining "white"? Let's say it's everything brighter than 240 in all 3 components. Then you should be able to do:
H(240:end, 240:end, 240:end) = 0;
추가 답변 (0개)
참고 항목
카테고리
Help Center 및 File Exchange에서 Histograms에 대해 자세히 알아보기
제품
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!