Multiple volshows with same colormap

조회 수: 4 (최근 30일)
Martin Vrátný
Martin Vrátný 2022년 7월 25일
답변: aditi bagora 2023년 10월 5일
Hello,
I'm trying to display two 3D images using Matlabs volshow function. The code looks like this.
First i load my config from mat file. Then i prepare the data and inicialize figure with UIpanels. After that i create a M by N by L (3D) matrix which i'm trying to visualize using volshow with loaded config. At the end im saving these as a gif, but that works fine and is not my concern. My problem is that each volshow in each UIpanel have its own color map. See image down below.
function volshow_spatial_map_compare(map,map2,VoxIdx,dimensions,camView,fileName)
config = load("volshow_config_fmri.mat"); % <- volshow config exported from Volume Viewer
fileName = join([fileName,'.gif']);
IM = zeros(dimensions);
% map = data(:,idx);
map = map-min(map(:));
map = map*50;
IM2 = zeros(dimensions);
map2 = map2-min(map2(:));
map2 = map2*50;
% bottom = min(map(:));
% top = max(map(:));
% clim([bottom top]);
% gcf
% caxis([-1 1]);
f = figure;
p1 = uipanel(f,'Position',[0,0,0.5,1]);
p2 = uipanel(f,'Position',[0.5,0,0.5,1]);
for idx = 1:size(map,2)
IM(VoxIdx) = map(:,idx);
IM2(VoxIdx) = map2(:,idx);
% if strcmp('front',camView)
% h = volshow(IM,config.config);
% h.CameraPosition = [4, 0, 0]; % odkud se dívám -> kde stojí kamera
% h.CameraUpVector = [0, 0, 1]; % rotace kolem osy
% end
if strcmp('top',camView)
h = volshow(IM,config.config, 'Parent',p1);
h.CameraPosition = [0, 0, 4];
h.CameraUpVector = [-1, 0, 0];
h2 = volshow(IM2,config.config, 'Parent',p2);
h2.CameraPosition = [0, 0, 4];
h2.CameraUpVector = [-1, 0, 0];
end
% if strcmp('side',camView)
% h = volshow(IM,config.config);
% h.CameraPosition = [0, -4, 0];
% h.CameraUpVector = [0, 0, 1];
% end
% Use getframe to capture image.
I = getframe(gcf);
[indI,cm] = rgb2ind(I.cdata,256);
% Write frame to the GIF File.
if idx == 1
imwrite(indI, cm, fileName, 'gif', 'Loopcount', inf, 'DelayTime', 0.5);
else
imwrite(indI, cm, fileName, 'gif', 'WriteMode', 'append', 'DelayTime', 0.5);
end
end
end
When i call this function with these inputs
volshow_spatial_map_compare(x(1,:)',x(1,:)'/100,VoxIdx,map_dimensions,'top','compare_test');
i get this output
First picture looks okey, but the second one should be 100x less color intense -> almost "invisible". I have no idea where is my mistake.
For clarification, i need to see the difference of intensity between these two images.
Thanks in advance.

답변 (1개)

aditi bagora
aditi bagora 2023년 10월 5일
Hello Martin,
I understand that despite applying different colormaps, both images still appear similar.
This could be because the configuration exported from Volume Viewer app has colormap property also in the structure. Since, you are passing same configuration object to both the functions same colormap is applied for both the panels.
To resolve this issue, you can update the “Colormap in the configuration object “config to apply different colormap to the images. You can also use the “Colormap” parameter of “volshow()“ function to apply the maps directly.
Here are two approaches you can use to address the issue:
  1. Update the colormap in the configuration object by assigning the desired colormap. Then, pass the modified configuration object to the “volshow()” function.
config.Colormap = map;
2. Alternatively, you can use the Colormap parameter of the “volshow()” function to assign the desired colormap directly:
volshow(IM, config.config, 'Colormap', map, 'Parent', p1);
For more details, please refer to the following link:
I hope the approaches help you solving the issue.

카테고리

Help CenterFile Exchange에서 Red에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!

Translated by