Writing imagesc image to a tiff stack
조회 수: 2(최근 30일)
표시 이전 댓글
Pavlov 2014년 11월 5일
댓글: Walter Roberson 2018년 2월 16일
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
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.
Komal Gaikwad 2018년 2월 16일
what does WIN_sz=750 mean?
댓글 수: 1
Find more on Images in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!Start Hunting!