why does whiteness show up ? !

I saved an image in my file using "saveas" and I have used those instructions
DirectoryPath =('C:\Users\Mayssa\Desktop\pfe\Matlab\interface');
whereToStore=fullfile(DirectoryPath,a);
saveas(gcf, whereToStore);
But when I try to read it (with imread) it shows up on a a white background, how can I get rid of it ? :(

Answers (3)

Star Strider
Star Strider on 21 Aug 2015
From the saveas documentation:
  • If you do not specify an extension, then saveas saves the figure to a FIG-file.
Instead of imread, see if openfig works.

6 Comments

I did specify an extension , it's png. I need imread because I have to use the image for other purposes, however, I can not affect openfig to a variable.
This works for me:
figure(1)
plot(-10:10, exp(-([-10:10]/5).^2))
saveas(gcf, '#TestSAVEAS.png');
A = imread('#TestSAVEAS.png');
figure(2)
image(A)
Well, what is in the string badly-named "a"? It is a string, isn't it?
Mayssa
Mayssa on 22 Aug 2015
Edited: Mayssa on 22 Aug 2015
it's a variable to which I affect the time of saving (clock) followed by the extension png
c = clock;
a=['MicroCercle','_',num2str(c(2)),'_',num2str(c(3)),'_',num2str(c(4)),'h',num2str(c(5)),'m',num2str(c(5)),'.png'];
Mayssa
Mayssa on 22 Aug 2015
Edited: Mayssa on 22 Aug 2015
@Star Strider, It does work for me too, but in my code I am plotting over an image texture than saving the whole in another image.
Try this:
figure(1)
plot(-10:10, exp(-([-10:10]/5).^2))
saveas(gcf, '#TestSAVEAS_01.png');
figure(2)
plot(-10:10, 1-exp(-([-10:10]/5).^2))
saveas(gcf, '#TestSAVEAS_02.png');
A = imread('#TestSAVEAS_01.png');
B = imread('#TestSAVEAS_02.png');
figure(2)
image(uint8((double(A)/2 + double(B)/2)))
hold on
hold off
title('Retrieved & Combined Images')
delete('#TestSAVEAS_01.png')
delete('#TestSAVEAS_02.png')

Sign in to comment.

Categories

Find more on Images in Help Center and File Exchange

Asked:

on 21 Aug 2015

Commented:

on 22 Aug 2015

Community Treasure Hunt

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

Start Hunting!