Discover MakerZone

MATLAB and Simulink resources for Arduino, LEGO, and Raspberry Pi

Learn more

Discover what MATLAB® can do for your career.

Opportunities for recent engineering grads.

Apply Today

Thread Subject:
Create a tiff stack from multiple figure

Subject: Create a tiff stack from multiple figure

From: Sébastien MAILFERT

Date: 9 Jun, 2011 14:18:05

Message: 1 of 3

Hi,

I have a problem to save figures in a multiple tiff stack.
I generate different figures of microscopy and I plot also squares on it.
I would like to know how to save these different figures into only one tiff file.
I've tried the imwrite function without success...

Here is my simplified code:

for j=Deb:Fin
    
    figure(j);
    im_1 = read_stk4spec(name_image, j);% im_1 is my raw data
    imageHandle=imagesc(im_1);
    colormap(gray);
    
    % I draw a square at a precise coordinate
    offset=5;% 1/2 square size
     x=[Coord_I-offset Coord_I+offset Coord_I+offset Coord_I-offset Coord_I-offset];
     y=[Coord_J-offset Coord_J-offset Coord_J+offset Coord_J+offset Coord_J-offset];
     hold on;
     axis manual;
     plot(x,y,'color','w');
                         
end%for
 
numColors = 256; % Valeur maximale à ne pas dépasser
im_1 = im_1-min(im_1(:));
im_1 = im_1./max(im_1(:));
im_1 = uint8(im_1*(numColors-1));

if(j==Deb)% if first image, erase previous file if it exists
       imwrite(im_1,[PathName,'test.tif'],'tif','WriteMode','overwrite');
else
    imwrite(im_1,[PathName,'test.tif'],'tif','WriteMode','append');
end
    
end%for


This code save the raw data but not the figure because I don't use the handle of the figure. How can I use this handle?


Thanks for your help

Subject: Create a tiff stack from multiple figure

From: Oliver Woodford

Date: 9 Jun, 2011 14:26:04

Message: 2 of 3

"Sébastien MAILFERT" wrote:
> I have a problem to save figures in a multiple tiff stack.
> I generate different figures of microscopy and I plot also squares on it.
> I would like to know how to save these different figures into only one tiff file.

Your code is not saving the figures, only the images. Save the figures using export_fig (on the file exchange) - it has an -append option which works with the tiff format. Use it as follows:

% Generate first figure here
export_fig test.tif
% Generate second figure here
export_fig test.tif -append
% Generate third figure here
export_fig test.tif -append
% And so on...

Regards,
Oliver

Subject: Create a tiff stack from multiple figure

From: Sébastien MAILFERT

Date: 10 Jun, 2011 06:44:05

Message: 3 of 3

"Oliver Woodford" wrote in message <isql5s$71m$1@newscl01ah.mathworks.com>...
> "Sébastien MAILFERT" wrote:
> > I have a problem to save figures in a multiple tiff stack.
> > I generate different figures of microscopy and I plot also squares on it.
> > I would like to know how to save these different figures into only one tiff file.
>
> Your code is not saving the figures, only the images. Save the figures using export_fig (on the file exchange) - it has an -append option which works with the tiff format. Use it as follows:
>
> % Generate first figure here
> export_fig test.tif
> % Generate second figure here
> export_fig test.tif -append
> % Generate third figure here
> export_fig test.tif -append
> % And so on...
>
> Regards,
> Oliver




Hi Olivier,

I'm a little bit stupid, you have solved my problem with just the good function!
Thanks and sorry for the question.

Sébastien

Tags for this Thread

What are tags?

A tag is like a keyword or category label associated with each thread. Tags make it easier for you to find threads of interest.

Anyone can tag a thread. Tags are public and visible to everyone.

Contact us