Writing imagesc image to a tiff stack

2 views (last 30 days)
Pavlov on 5 Nov 2014
Commented: Walter Roberson on 16 Feb 2018
Hey guys,
What I'm trying to do here is take some number of frames across a large movie, average them together, and use imagesc to visualize a heat map. I'm using a sliding window to average successive chunks of frames, and I want to concatenate these heat maps into a tiff stack, e.g. so I can watch a movie of how the data is evolving. Here's how I have started:
win_sz = 750;
shift = 100;
sliding_win = 1:win_sz;
FIG = figure;
DIR = 'E:\Behavioral_Conditioning\VIDEO\NJ30\141010_NJ30_1_T';
while sliding_win < FOI(end)-shift
B = bsxfun(@rdivide, sum(output.animalmask(:,:,FOI(sliding_win)),3), x);
%B = bsxfun(@minus, B, 255);
imagesc(B); axis off
if sliding_window(1) == 1
saveas(gcf,fullfile(DIR,['CSfood_HeatMapMov']),'tif') %append to stack
sliding_win = sliding_win(1)+shift:sliding_win(1)+shift+win_sz;
So, output.animalmask is the full movie. The variable B is an average across win_sz = 750 frames. So, I want to use imagesc to visualize the heat map for frames 1:750, then shift this window by ~100 frames, make the next heat map, and so on. For each imagesc image, I want to append it to a tiff stack. Normally I would use imwrite or something for making a stack, but it doesn't seem like I can use imwrite and the nice imagesc colors I want my heat map to have. Is this true? Or should I be somehow using a save function with '-append' or something to stick each new image onto what I have already saved?
  1 Comment
Walter Roberson
Walter Roberson on 16 Feb 2018
In the code posted, sliding_win is a vector, and that vector is being used in the test of a "while". if and while only consider the test to be true if every element being tested is nonzero -- if they are all true. I have to wonder if the original poster knew about that. If the code was deliberate then it would be recommended to code an all() around the test to make it clear what was being tested.

Sign in to comment.

Answers (1)

Komal Gaikwad
Komal Gaikwad on 16 Feb 2018
what does WIN_sz=750 mean?
  1 Comment
Walter Roberson
Walter Roberson on 16 Feb 2018
It is the size of the sliding window that was being used.

Sign in to comment.

Community Treasure Hunt

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

Start Hunting!