Project 3 grayscale images into a single RGB image, as done with "stack to RGB" in ImageJ

8 ビュー (過去 30 日間)
Pavlov
Pavlov 2014 年 8 月 26 日
回答済み: Image Analyst 2014 年 9 月 4 日
So, I have three different tiff stacks that are gray scale. I loop through each image of each stack, concatenating them together. I then want to something like "Stack to RGB in ImageJ, where these three grayscale images are converted into a single image that's color-coded according the the similarity between the three images. Ultimately, I will be writing a tiff stack that has the same number of frames as each of the three original grayscale tiff stacks, but colored to show differences in an animal's behavior across three conditions. My approach is below, showing how I loop through the number of frames in the tiff stacks, concatenate, and then attempt to write the RGB image.
for frame = 1:num_frames
if frame == 1 && exist([video_dir '\Peristim_RGB_mov.tif'])
display('Peristim_RGB_mov already exists. Delete in order to proceed.');
end
grey = [];
grey = cat(3,grey,imread([video_dir '\CS_shock_MovMean'],'tif',frame));
grey = cat(3,grey,imread([video_dir '\CS_neutral_MovMean'],'tif',frame));
grey = cat(3,grey,imread([video_dir '\CS_food_MovMean'],'tif',frame));
%rgb = repmat(double(grey)./255,1);
RGB_frame = mean(rgb,3);
try
imwrite(RGB_frame,'Peristim_RGB_mov.tif','WriteMode','append', ...
'Compression','none');
catch err
pause(0.1);
imwrite(RGB_frame,'Peristim_RGB_mov.tif','WriteMode','append', ...
'Compression','none');
end
end
  4 件のコメント
Image Analyst
Image Analyst 2014 年 8 月 26 日
546 grayscale frames, or color frames? When you say "each frame of the three originals will be smooshed into a single RGB image" do you mean that each frame the 3 movies is a gray scale image that supposed to be one color channel of the output frame, so it takes one frame from each stack to create one frame of the RGB output movie?
Pavlov
Pavlov 2014 年 8 月 26 日
Yes, 546 grayscale frames. I am looping through each frame for each of the three tiff stacks, concatenating, then trying to convert to single RGB frame so that the final movie is also 546 frames. The idea is to do something equivalent to "Stack to RGB" in ImageJ. So, for example, if you take frame #1 for each of the three grayscale movies, you concatenate, then convert to a single RGB image such that MOre red colors signify areas of teh image unique to the first grayscale frame of the three, more green for the second, and more blue for the third.

サインインしてコメントする。

回答 (2 件)

Pavlov
Pavlov 2014 年 9 月 4 日
Haven't thought about this since last week, but will attempt to make it work again this afternoon. Any ideas?

Image Analyst
Image Analyst 2014 年 9 月 4 日
Read in images 1-3, concatenate them into an rgb image, and make a video frame. Then read in images 2-4 and do the same thing, then images 3-5, etc. Attached is a demo for how to create a movie from individual RGB images.

カテゴリ

Help Center および File ExchangeImages についてさらに検索

Community Treasure Hunt

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

Start Hunting!

Translated by