Subplot Histogram Plotting Mistake

Hello,
I am using that code at my project.
But I can't show histogram for my image. I added my result below too. Can you help me please?
Thank you
figure('Name','Org. Img + Histogram','NumberTitle','off');
subplot(2,1,1), imshow(org), title('Org. Img.');
subplot(2,1,2), imhist(org),title('Histogram of original image'), axis([0 270 0 8500]);

4 Comments

Also I am running a function at the background too. But function variables doesn't same with this figure.
I mean at function, there is a figure too but they haven't got same variables. Also if I close that figure at function it show histogram but if I run them together it shows like here
It worked for me in my test:
org = imresize(imread('cameraman.tif'), [100 100]);
subplot(2,1,1), imshow(org), title('Org. Img.');
subplot(2,1,2), imhist(org),title('Histogram of original image'), axis([0 270 0 8500]);
(The histogram for this test is not empty; the counts are just not nearly as much as the 8500 you set as the axis limits)
Thank you for your interest, but as I mentioned it can work if it only work with itself.
But when i tried with another figure it give only that result
I will write all the code maybe it can give you a clue
img = imread('jet.png');
org = img; % I use like this
org = imresize(img, [100 100]); %(This is your solution)
f1 = figure('Name','Org. Img + Histogram','NumberTitle','off');
% figure('Name','Org. Img + Histogram','NumberTitle','off'); % (I use sometimes this code part to)
subplot(2,2,1),imshow(org), title('Org. Img.');
subplot(2,2,2),imhist(org),title('Histogram of original image');
[his, yog] = histeq(img); %This my function at back
f2 = figure('Name','Histogram Equalize','NumberTitle','off');
% figure('Name','Histogram Equalize','NumberTitle','off');
subplot(2,2,1),imshow(his),title('Histogram equalize'); %This and below is output from my funciton and my plots
subplot(2,2,2),bar(yog),title('Histogram equalize');
axis([0 270 0 8500]); %This is boundary for the bar at upper code
Thank you for helping
Also I want to give an update :/
ıt is weird thing for me.
When I select codes from this part to the end.
[his, yog] = histeq(img); %This my function at back
and put them upsite to the
f1 = figure('Name','Org. Img + Histogram','NumberTitle','off');
this code part.
It worked as like I wanted.
But ı didn't understand why it worked when I change their locations

Sign in to comment.

Answers (0)

Tags

Asked:

on 20 May 2020

Edited:

on 20 May 2020

Community Treasure Hunt

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

Start Hunting!