image intensity scale sub-divide into two ranges
Mostrar comentarios más antiguos
I have an image. I obtain the histogram for that image and calculate probability distribution using the code below:
if size(I,3) == 1 %grayscale image
[n_countR, x_valueR] = imhist(I(:,:,1));
Nt = size(I,1) * size(I,2); %Total number of pixels in the image ROW X COL
%Lmax segmenting color levels 0-256
Lmax = 256; %256 different maximum levels are considered in an image (i.e., 0 to 255)
% Probability distribution for each intensity level histogram 0 - 256
for i = 1:Lmax
if size(I,3) == 1
%grayscale image
probR(i) = n_countR(i) / Nt;
end
Now I want this image histogram, having range 0 to 255, to sub-divide into two having the range 0 to 127 and 128 to 255 respectively and find probability distribution for both. Please help. I hope now you can better understand my question. Much thanks..
Respuesta aceptada
Más respuestas (1)
Thorsten
el 2 de Dic. de 2014
h1 = hist(I(I<=127), 0:127);
h2 = hist(I(I>=128), 128:255);
4 comentarios
Nataliya
el 2 de Dic. de 2014
Thorsten
el 2 de Dic. de 2014
Make sure that your image I is in the range 0:255. For example
I = imread('peppers.png');
Don't use im2double which converts the image to the range 0:1.
Alternatively, if your image is in the range 0:1, use
I = I*255;
before you run my code.
Nataliya
el 2 de Dic. de 2014
Thorsten
el 2 de Dic. de 2014
ind = find(I < 128);
Plow = hist(I(I < 128), 0:127)/numel(ind);
ind = find(I >= 128);
Plow = hist(I(I >= 128), 128:255)/numel(ind);
Categorías
Más información sobre Histograms en Centro de ayuda y File Exchange.
Productos
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!