Writing imagesc image to a tiff stack

1 次查看(过去 30 天)
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
clf(FIG)
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')
else
saveas(gcf,fullfile(DIR,['CSfood_HeatMapMov']),'tif') %append to stack
end
sliding_win = sliding_win(1)+shift:sliding_win(1)+shift+win_sz;
continue
end
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?
Thanks!
  1 个评论
Walter Roberson
Walter Roberson 2018-2-16
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.

请先登录,再进行评论。

回答(1 个)

Komal Gaikwad
Komal Gaikwad 2018-2-16
what does WIN_sz=750 mean?

Community Treasure Hunt

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

Start Hunting!

Translated by