フィルターのクリア

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

採用された回答

Image Analyst
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 ExchangeHistograms についてさらに検索

製品

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by