Filter löschen
Filter löschen

Saved histogram figures appears blank after I open them.

11 Ansichten (letzte 30 Tage)
Prachi Sharma
Prachi Sharma am 17 Jul. 2017
Kommentiert: Prachi Sharma am 19 Jul. 2017
Hi,I have this code
%function hst(v,h,m)
ve=imread('v.png');
he=imread('h.png');
m=imread('i.png');
vr=ve(:,:,1);
imhist(ve(:,:,1))
title('Red Channel Histogram of vertical')
saveas(gcf,'RCV.png');
figure
vg=ve(:,:,2);
imhist(ve(:,:,2))
title('Green Channel Histogram of vertical')
saveas(gcf,'GCV.png')
figure
vb=ve(:,:,3);
imhist(ve(:,:,3))
title('Blue Channel Histogram of vertical')
figure
saveas(gcf,'BCV.png');
hr=he(:,:,1);
imhist(he(:,:,1))
title('Red Channel Histogram of horizontal')
figure
saveas(gcf,'RCH.png');
hg=he(:,:,2);
imhist(he(:,:,2))
title('Green Channel Histogram of horizontal')
figure
saveas(gcf,'GCH.png');
hb=he(:,:,3);
imhist(he(:,:,3))
title('Blue Channel Histogram of horizontal')
figure
saveas(gcf,'BCH.png');
mr=m(:,:,1);
imhist(m(:,:,1))
title('Red Channel Histogram of Intersection ')
figure
saveas(gcf,'RCI.png');
mg=m(:,:,2);
imhist(m(:,:,2))
title('Green Channel Histogram of Intersection')
figure
saveas(gcf,'GCI.png');
mb=m(:,:,3);
imhist(m(:,:,3))
title('Blue Channel Histogram of Intersection ')
saveas(gcf,'BCI.png');
In this, I am trying to find histograms of RGB channels of different images and then save them.When I run the code the histograms appear but when I open the saved images of histograms most of them give a blank figure and I can't understand why?
Can someone help me with this, please?
I have also attached the images I am using in the code.
  1 Kommentar
Jan
Jan am 17 Jul. 2017
Please post your code in a compact form: Use the "{} Code" button and no blank line after each line of code. Thanks.

Melden Sie sich an, um zu kommentieren.

Akzeptierte Antwort

Jan
Jan am 17 Jul. 2017
Bearbeitet: Jan am 17 Jul. 2017
Of course the saved figure are blank, if you use this code:
figure
saveas(gcf,'RCI.png'); % <-- Not here
mg=m(:,:,2);
imhist(m(:,:,2))
title('Green Channel Histogram of Intersection')
% <-- but save here!
This opens a new figure, saves the contents and create the histogram afterwards. You have to call saveas after the contents of the figure is drawn.
  1 Kommentar
Prachi Sharma
Prachi Sharma am 19 Jul. 2017
Thanks a lot.I didn't realize that I have messed up the position of saveas.

Melden Sie sich an, um zu kommentieren.

Weitere Antworten (0)

Community Treasure Hunt

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

Start Hunting!

Translated by