Histogram Data out of axes boundries

10 ビュー (過去 30 日間)
Laurent
Laurent 2020 年 1 月 8 日
コメント済み: Laurent 2020 年 1 月 13 日
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

採用された回答

Subhadeep Koley
Subhadeep Koley 2020 年 1 月 13 日
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 件のコメント
Laurent
Laurent 2020 年 1 月 13 日
That worked, Thanks alot!

サインインしてコメントする。

その他の回答 (0 件)

カテゴリ

Help Center および File ExchangeSurface and Mesh Plots についてさらに検索

Community Treasure Hunt

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

Start Hunting!

Translated by