How can I find minima in specific regions & closest bin to value in Histogram?
    5 visualizaciones (últimos 30 días)
  
       Mostrar comentarios más antiguos
    
    Joe Perkins
 el 8 de Dic. de 2018
  
    
    
    
    
    Comentada: Joe Perkins
 el 10 de Dic. de 2018
            Hi all,
As part of my work I am producing greyscale images that produce similar histogram profiles (see. fig). The information I am trying to obtain from each is 
1) Peak count greyscale value 
2) The greyscale value of the minima shown in region X 
3) The closest greyscale value that corresponds to 25% of the peak pixel count in region Y. So for histogram shown in fig; the bin with value approx 3000000 in region Y (12000000* 0.25) . 
Peak value I have already successfully calculated. Can anyone point me in the direction of how to tackle 2) & 3)? Any help would be greatly apprechiated. 
Thanks, Joe 

0 comentarios
Respuesta aceptada
  Image Analyst
      
      
 el 9 de Dic. de 2018
        Try this:
% Read in image.
grayImage = imread('pout.tif');
imshow(grayImage, []);
% Get histogram
counts = imhist(grayImage);
plot(counts, '-', 'LineWidth', 2);
xlabel('Gray Level', 'FontSize', 15);
ylabel('Count', 'FontSize', 15);
title('Histogram', 'FontSize', 15);
grid on;
% Enlarge figure to full screen.
set(gcf, 'Units', 'Normalized', 'OuterPosition', [0, 0.04, 1, 0.96]);
% Find max count and what gray level it's at.
[maxCount, glAtMaxCount] = max(counts)
% Find the min in region X
minCount = min(counts(1:glAtMaxCount-1))
glAtMinCount = find(counts(1:glAtMaxCount-1) <= minCount)  % Might be more than one.
% Find the closest greyscale value that corresponds to 25% of the peak pixel count in region Y
temp = counts;
temp(1:glAtMaxCount) = maxCount;
gl25 = find(temp < 0.25 * maxCount, 1, 'first')
% Put red line there
hold on;
line([gl25, gl25], ylim, 'Color', 'r', 'LineWidth', 2);
Más respuestas (0)
Ver también
Categorías
				Más información sobre Histograms en Help Center y File Exchange.
			
	Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!