why the histogram wont show in the wanted axes the code has no errors but it wont show

조회 수: 4 (최근 30일)

채택된 답변

Walter Roberson
Walter Roberson 2023년 1월 9일
When you have no output variable for imhist() and you do not tell it which axes to display into, then it will call gca() to find the current axes. gca() will not look for axes whose handle visibility is turned off, but by default handle visibility is off for all uiaxes in app designer.
You need to either turn on handle visibility for the target axes and make it the current axes (not recommended), or else you have to pass the target axes to imhist (recommended)
  댓글 수: 2
jana
jana 2023년 1월 10일
but i thought i did tell it which axes to show up in i dont know this is the code
a =app.Image;
o=im2gray(a);
c=imhist(o);
I=imshow(c,'parent',app.UIAxes2,...
'XData',[1 app.UIAxes2.Position(3)],...
'YData',[1 app.UIAxes2.Position(4)]);
app.UIAxes2.XLim=[0 I.XData(2)];
app.UIAxes2.YLim=[0 I.YData(2)];
Walter Roberson
Walter Roberson 2023년 1월 10일
histforrgbbutton has imhist() with no output and no axes.

댓글을 달려면 로그인하십시오.

추가 답변 (1개)

Image Analyst
Image Analyst 2022년 12월 23일
DON'T use input for the name of a variable because it's already the name of a function that asks the user for a variable. Call it userInput or something. What does this show in the command window
whos a
I'd like to know if the badly-named "a" is actually a gray scale image, an RGB image, or a character array (string).
  댓글 수: 4
jana
jana 2023년 1월 10일
its now writtenas a =app.Image;
o=im2gray(a);
c=imhist(o);
I=imshow(c,'parent',app.UIAxes2,...
'XData',[1 app.UIAxes2.Position(3)],...
'YData',[1 app.UIAxes2.Position(4)]);
app.UIAxes2.XLim=[0 I.XData(2)];
app.UIAxes2.YLim=[0 I.YData(2)];
still nothing shows up
Image Analyst
Image Analyst 2023년 1월 10일
imshow() works on an image, not a histogram object or counts of pixels. Don't use imshow at all. If you want to see the histogram, just use imhist(o) by itself
imhist(o); % "o" is a horrible name for a variable!

댓글을 달려면 로그인하십시오.

카테고리

Help CenterFile Exchange에서 Images에 대해 자세히 알아보기

태그

Community Treasure Hunt

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

Start Hunting!

Translated by