How can I color encode depth information of a greyscale 3-D image?
11 visualizaciones (últimos 30 días)
% Get useful information about the stack
[height, width, depth] = size(stack);
% Useful for Color encoding the stack in 3D
colorMap = jet(depth); % This is a 121x3 matrix of RGB values
% Convert each frame in the stack into a unit8 image with each frame corresponding to the colorMap values
stack_color = stack;
for i = 1:depth
maxVal = max(max(stack_color(:,:,i))); % Find the maximum value in the frame
minVal = min(min(stack_color(:,:,i))); % Find the minimum value in the frame
% Normalize the frame to the range [0,1]
stack_color(:,:,i) = (stack_color(:,:,i) - minVal)/(maxVal - minVal);
% Color encode the stack to a unit8 image
stackRGB(:,:,1,i) = uint8(colorMap(i,1)*255*stack_color(:,:,i)); % Red channel
stackRGB(:,:,2,i) = uint8(colorMap(i,2)*255*stack_color(:,:,i)); % Green channel
stackRGB(:,:,3,i) = uint8(colorMap(i,3)*255*stack_color(:,:,i)); % Blue channel
% Create maximum intensity projections
stackMIP = max(stackRGB,,4); % This is the MIP of the color encoded stack
MIP = max(stack,,3); % This is the MIP of the grayscale stack
This is the code I've writen but I have an issue with it.
The output is this.
Dark intensity values seem to just go away entiirely. How can change this code, so that the brightness of each slice becomes a brightness for that color? Essentially I want to create something like the depth encoding feature in ImageJ.
Walter Roberson el 12 de Oct. de 2022
Suppose you were to take the furthest slice and select a Hue for it and use the grayscale information as the Saturation, and use a constant Value, and image() that with an AlphaData property that is less than 1. Then likewise for the second furthest with a different hue, image() it on top of the previous image, and so on onto you have overlaid all of the images. Or, instead of constructing so many image() objects, you could mathematically calculate the result of overlaying the images and then image() only the final result. As a modification of the process you might do some kind of background detection on each slice and set the alpha information to 0 for the background locations.
Or instead of using image(), you could use a surface() with texture mapping; warp makes that convenient. If you do that with different Z values for the different slices, the result you get would be something you could rotate in 3 space. (You cannot rotate image() objects in 3-space, they will disappear.)
Image Analyst el 12 de Oct. de 2022
Editada: Image Analyst el 13 de Oct. de 2022
If the "stack" image is a volumetric image with zeros except where there is material, you can use min() to find the slice number of the first non-zero slice by setting zeros to inf and using
volumetricImage3d(volumetricImage3d==0) = inf;
[values, topSlices] = min(volumetricImage3d, , 3);
Now it's simply an indexed image and you can apply a colormap as usual.