Eliminating(excluding) the while or black color in a color histogram function matlab
2 vues (au cours des 30 derniers jours)
Afficher commentaires plus anciens
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 commentaires
Réponse acceptée
Image Analyst
le 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;
Plus de réponses (0)
Voir également
Catégories
En savoir plus sur Histograms dans Help Center et File Exchange
Produits
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!