Project 3 grayscale images into a single RGB image, as done with "stack to RGB" in ImageJ
3 次查看(过去 30 天)
显示 更早的评论
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
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?
回答(2 个)
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.
0 个评论
另请参阅
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!