Histogram Data out of axes boundries

1 vue (au cours des 30 derniers jours)
Laurent
Laurent le 8 Jan 2020
Commenté : Laurent le 13 Jan 2020
As you can see on the attached image, the values of my histogram are getting out of the axes boundries. Is there a way to limit that?
This is the code I've used for this axes:
%... GUI Elements
axes_img2 = axes('Units','pixels','Position',[631,350,450,300]);
%... GUI Elements & Functions
function btn_histo_Callback (~,~)
Bild2 = imread(Bild1); % Gibt Bilddatei in einem array (x*y) zurueck
if size(Bild2, 3) > 1 % Fehlerbehebung für "MAP must be a m x 3 array." bzw. Bild ist kein RBG-Bild. Size, gibt die "Grösse" des Bildes züruck, siehe 127.
Bild2gray = rgb2gray(Bild2); % rbg2gray erzeugt einen graustufenbild 1x1 Matrix aus einer 1x3 Matrix (RGB), falls Graustufenbild gezeigt werden soll, entsprechendes Arg. in imshow(I) aendern
else
Bild2gray = Bild2;
end
axes(axes_img2);
imhist(Bild2gray); % Erzeugt einen Histogramm des Graubildes. Das Histogramm zeigt wo (bei Maxima) die Mehrzahl eines Graustufenwertes sich befindet und sagt somit aus, welcher Wert der Hintergrund hat.
% Dieser Wert wird für den Schwellwert T (Threshold value) gebraucht um zu entscheiden ab wann, die Pixel den Wert 1 oder 0 annehmen. Abhaegigkeit 0->256 zu 0->1 ????
end

Réponse acceptée

Subhadeep Koley
Subhadeep Koley le 13 Jan 2020
Hi, you can use axis limits to extend the plot to the edges of the axes. Refer the code below.
%... GUI Elements
axes_img2 = axes('Units','pixels','Position',[631,350,450,300]);
%... GUI Elements & Functions
function btn_histo_Callback (~,~)
Bild2 = imread(Bild1);
if size(Bild2, 3) > 1
Bild2gray = rgb2gray(Bild2);
else
Bild2gray = Bild2;
end
axes(axes_img2);
imhist(Bild2gray); axis tight;
end
Hope this helps!
  1 commentaire
Laurent
Laurent le 13 Jan 2020
That worked, Thanks alot!

Connectez-vous pour commenter.

Plus de réponses (0)

Community Treasure Hunt

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

Start Hunting!

Translated by