Eliminating(excluding) the while or black color in a color histogram function matlab
2 Ansichten (letzte 30 Tage)
Ältere Kommentare anzeigen
alladin
am 28 Jan. 2015
Kommentiert: alladin
am 28 Jan. 2015
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 Kommentare
Akzeptierte Antwort
Image Analyst
am 28 Jan. 2015
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;
Weitere Antworten (0)
Siehe auch
Kategorien
Mehr zu Histograms finden Sie in Help Center und File Exchange
Produkte
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!