Depth color coding using Volumeviewer/ Volshow

8 ビュー (過去 30 日間)
MechenG
MechenG 2025 年 6 月 2 日
コメント済み: MechenG 2025 年 6 月 4 日
Hi,
I am uisng the below script to display focal stacks in 3D. May I know how to include colormap for depth?
filePattern = fullfile(fileFolder, '*.png');
all_images = dir(filePattern);
I = imread(all_images(1).name);
I= rgb2ind(I,256);
W=365;
H=365;
D = numel(all_tiff);
stack = zeros(W,H,D);
stack(:,:,1) = first_image;
for i = 2:D
II = imread(all_tiff(i).name);
II = rgb2ind(II,256);
stack(:,:,i) = II;
end
volumeViewer(stack);
I also tried below tutorial which involves Volshow(), However I got the below shown graphics error while running
Error using images.ui.graphics3d.Volume/validateData
Expected input to be finite.
Error in images.ui.graphics3d.Volume/setData
Error in images.ui.graphics3d.GraphicsContainer/set.Data
Error in images.ui.graphics3d.internal.AbstractContainer/set
Error in images.ui.graphics3d.GraphicsContainer
Error in images.ui.graphics3d.Volume
Error in volshow (line 32)
hVolume = images.ui.graphics3d.Volume(viewer, 'Data', V, remainingInputs{:});
Error in depthVolumeColorCoder (line 83)
V = volshow(arr,...
clear; close all; clc;
%% Display Grayscale Spiral
%set colormap to use for depth coding
colormap = hsv;
%load data from MATLAB
load('spiralVol.mat');
vol = spiralVol;
%display grayscale volume
volshow(vol)
%snap pic of the grayscale volume for publishing
snapnow
close;
%% Display Color Coded Spiral
%colorcode the spiral
depthVolumeColorCoder(vol,colormap)
  3 件のコメント
MechenG
MechenG 2025 年 6 月 3 日
Thanks for the suggestion. Unfortunately, it didn't solve the issue. I am getting the same error.. Here is the tutorial (https://uk.mathworks.com/matlabcentral/fileexchange/92208-depth-volume-color-coder) I have tried out.
Walter Roberson
Walter Roberson 2025 年 6 月 3 日
Did all three lines return 0?

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

採用された回答

Gayathri
Gayathri 2025 年 6 月 3 日
To view the volume with the colormap, please use the following lines of code
clear; close all; clc;
%% Display Grayscale Spiral
%set colormap to use for depth coding
colormap = hsv;
%load data from MATLAB
load('spiralVol.mat');
vol = spiralVol;
%display grayscale volume
volshow(vol,Colormap=colormap)
I hope this is your expectation. Let me know if you need something more!
Please refer to the below example, which illustrates the usage of 'volshow' funtion with 'Colormap' argument.
openExample('images/VisualizeVolumeOfMRIDataExample')
  1 件のコメント
MechenG
MechenG 2025 年 6 月 4 日
Thank you very much! It's working now.

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

その他の回答 (0 件)

カテゴリ

Help Center および File ExchangeColor and Styling についてさらに検索

Community Treasure Hunt

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

Start Hunting!

Translated by