Email: helpdesk@telkomuniversity.ac.id

This Portal for internal use only!

  • My Download
  • Checkout
Application Package Repository Telkom University
All Categories

All Categories

  • IBM
  • Visual Paradigm
  • Adobe
  • Google
  • Matlab
  • Microsoft
    • Microsoft Apps
    • Analytics
    • AI + Machine Learning
    • Compute
    • Database
    • Developer Tools
    • Internet Of Things
    • Learning Services
    • Middleware System
    • Networking
    • Operating System
    • Productivity Tools
    • Security
    • VLS
      • Office
      • Windows
  • Opensource
  • Wordpress
    • Plugin WP
    • Themes WP
  • Others

Search

0 Wishlist

Cart

Categories
  • Microsoft
    • Microsoft Apps
    • Office
    • Operating System
    • VLS
    • Developer Tools
    • Productivity Tools
    • Database
    • AI + Machine Learning
    • Middleware System
    • Learning Services
    • Analytics
    • Networking
    • Compute
    • Security
    • Internet Of Things
  • Adobe
  • Matlab
  • Google
  • Visual Paradigm
  • WordPress
    • Plugin WP
    • Themes WP
  • Opensource
  • Others
More Categories Less Categories
  • Get Pack
    • Product Category
    • Simple Product
    • Grouped Product
    • Variable Product
    • External Product
  • My Account
    • Download
    • Cart
    • Checkout
    • Login
  • About Us
    • Contact
    • Forum
    • Frequently Questions
    • Privacy Policy
  • Forum
    • News
      • Category
      • News Tag

iconTicket Service Desk

  • My Download
  • Checkout
Application Package Repository Telkom University
All Categories

All Categories

  • IBM
  • Visual Paradigm
  • Adobe
  • Google
  • Matlab
  • Microsoft
    • Microsoft Apps
    • Analytics
    • AI + Machine Learning
    • Compute
    • Database
    • Developer Tools
    • Internet Of Things
    • Learning Services
    • Middleware System
    • Networking
    • Operating System
    • Productivity Tools
    • Security
    • VLS
      • Office
      • Windows
  • Opensource
  • Wordpress
    • Plugin WP
    • Themes WP
  • Others

Search

0 Wishlist

Cart

Menu
  • Home
    • Download Application Package Repository Telkom University
    • Application Package Repository Telkom University
    • Download Official License Telkom University
    • Download Installer Application Pack
    • Product Category
    • Simple Product
    • Grouped Product
    • Variable Product
    • External Product
  • All Pack
    • Microsoft
      • Operating System
      • Productivity Tools
      • Developer Tools
      • Database
      • AI + Machine Learning
      • Middleware System
      • Networking
      • Compute
      • Security
      • Analytics
      • Internet Of Things
      • Learning Services
    • Microsoft Apps
      • VLS
    • Adobe
    • Matlab
    • WordPress
      • Themes WP
      • Plugin WP
    • Google
    • Opensource
    • Others
  • My account
    • Download
    • Get Pack
    • Cart
    • Checkout
  • News
    • Category
    • News Tag
  • Forum
  • About Us
    • Privacy Policy
    • Frequently Questions
    • Contact
Home/Matlab/MATLAB’s volshow command displays gray pixels as the inverse RGB color of any colored pixels also present in the dataset

MATLAB’s volshow command displays gray pixels as the inverse RGB color of any colored pixels also present in the dataset

PuTI / 2025-04-27
MATLAB’s volshow command displays gray pixels as the inverse RGB color of any colored pixels also present in the dataset
Matlab News

I have a segmented 3D image dataset that I am trying to visualize. Because there are two segmented phases, I am exploring different colors for each phase to make them stand out from each other. In particular, I would like one of the phases to be blue (RGB [0, 0, 255]) and the other phase to be gray (RGB [128, 128, 128]). I have created a 4D uint8 dataset of the segmented images to allow for this, and when I load the image stack in MATLAB’s sliceViewer everything looks correct. However, when I then load the same dataset in MATLAB’s volshow, it colors the gray pixels yellow while the blue pixels remain blue. See pictures below:
SliceViewer Image Showing Gray = Gray with Blue Colored Phase

Volshow Image Showing Gray = Yellow with Blue Colored Phase

I thought that perhaps there was an issue with the lighting option being colored and casting a color onto gray pixels, but I have the lighting option turned off. I then thought that perhaps there was an issue with grayscale pixels in volshow, but when I convert the gray pixels to white (RGB [255, 255, 255]) they appear white in volshow. The same exact effect is achieved if the blue pixels are reduced in intensity to RGB [0, 0, 128] while leaving the gray pixels as RGB [128, 128, 128] (the sliceViewer will look different showing a darker blue but the volshow looks identical to the picture below with a bright blue and white-colored gray pixels). See pictures below:
SliceViewer Image Showing White = White with Blue Colored Phase

Volshow Image Showing White = White with Blue Colored Phase

I then explored other colors to see if there is a specific issue with the blue/gray combination and found interesting results. When I converted the blue pixels to red (RGB [255, 0, 0]), the gray pixels remained gray in sliceViewer but now display as cyan in volshow. See pictures below:
SliceViewer Image Showing Gray = Gray with Red Colored Phase

Volshow Image Showing Gray = Cyan with Red Colored Phase

The blue/gray and red/gray tests demonstrate that volshow will replace gray pixels with the inverse RGB color of any colored pixels in the dataset (yellow is the opposite RGB of blue ([255, 255, 0] vs. [0, 0, 255]) and cyan is the opposite RGB of red ([0, 255, 255] vs. [255, 0, 0])). However, the yellow and cyan colors do not appear to be their full intensity versions ([255, 255, 0] for yellow and [0, 255, 255] for cyan) and they may have some degree of their typically absent color present, but I cannot tell as these pixels do not actually have these intensity values in the image data so I cannot tell to what the true color is that they are creating. Thus, I cannot determine to what degree the opposite colors are added and the main color is substracted from the gray pixels.
I then tried substituting the colored phase for white to see if that maintained the gray pixels, and this worked (note that it may be difficult to see the difference between white and gray in the volShow, but I turned the volume around, zoomed in, and was able to verify that this was the case). See pictures below:
SliceViewer Image Showing Gray = Gray with White Colored Phase

Volshow Image Showing Gray = Gray with White Colored Phase

I was then curious as to what would happen to the gray pixels if I added a third, differently-colored phase. So, I added a red strip down one side of the blue/gray volume. Now, the gray pixels turned green (again, to what degree the blue and red intensities were added vs. substracted and how much of the green intensity was added, I cannot know). See pictures below:
SliceViewer Image Showing Gray = Gray with Blue and Red Colored Phases

Volshow Image Showing Gray = Green with Blue and Red Colored Phases

I don’t know if I am doing something wrong, so I have provided a snippet of code that will re-create all of this as well as a google drive link (the file is >5 MB so I can’t upload it) to the dataset I am using to investigate this. The code will let you select the data and automatically load it for you and then produce all of the images I have included here in there sliceViewer and volshow formats so that you can explore them). Here is the link to the dataset and here is the code:
%% Test Case %%
close all
clear
clc

% Select image file
fprintf(‘Select an image file.nn’)
[file_name, path_intro] = uigetfile(‘*.*’, ‘Select an image file’);
file_path = sprintf(‘%s%s’, path_intro, file_name);

% Import image message
clc
fprintf(‘Importing image stack…nn’)

% Create tiff
stack_tiff = Tiff(file_path);

% Determine number of images in stack
info = imfinfo(file_path);
no_slice = numel(info);

% Determine necessary tags from tiff
bits = getTag(stack_tiff, ‘BitsPerSample’);
long = getTag(stack_tiff, ‘ImageLength’);
wide = getTag(stack_tiff, ‘ImageWidth’);
samples = getTag(stack_tiff, ‘SamplesPerPixel’);

% Pre-allocate volume array
volume = zeros(long, wide, no_slice, samples, ‘uint8’);

% Import first image
volume(:, :, 1, 🙂 = read(stack_tiff);

% Import loop
for n = 2:no_slice

% Update current directory
nextDirectory(stack_tiff);

% Add current slice to volume
volume(:, :, n, 🙂 = read(stack_tiff);

end

% Close tiff
close(stack_tiff)

% Create transformation matrix
T = [1.31 0 0 0; 0 1.31 0 0; 0 0 1.31 0; 0 0 0 1];
tform = affinetform3d(T);

% Create viewer parameters structure
view_struct = struct;

% Populate viewer parameters structure
view_struct.BackgroundColor = [1 1 1];
view_struct.BackgroundGradient = ‘off’;
view_struct.Lighting = ‘off’;

% Load first slice viewer
clc
fprintf(‘Loading first slice viewer…nn’)
f1 = figure(‘Name’, ‘Gray = Gray in Slice Viewer with Blue Colored Phase’);
sliceViewer(volume, parent = f1);

% Load first volume viewer
clc
fprintf(‘Loading first volume viewer…nn’)
uif1 = uifigure(‘Name’, ‘Gray = Yellow in Volume Viewer with Blue Colored Phase’);
viewer1 = viewer3d(view_struct, parent = uif1);
V1 = volshow(volume, ‘Transformation’, tform, parent = viewer1);

% Convert gray to white in second volume
clc
fprintf(‘Converting gray to white…nn’)
g2w_vol = volume;
g2w_vol(volume == 128) = 255;

% Load second slice viewer
clc
fprintf(‘Loading second slice viewer…nn’)
f2 = figure(‘Name’, ‘White = White in Slice Viewer with Blue Colored Phase’);
sliceViewer(g2w_vol, parent = f2);

% Load second volume viewer
clc
fprintf(‘Loading second volume viewer…nn’)
uif2 = uifigure(‘Name’, ‘White = White in Volume Viewer with Blue Colored Phase’);
viewer2 = viewer3d(view_struct, parent = uif2);
V2 = volshow(g2w_vol, ‘Transformation’, tform, parent = viewer2);

% Convert blue to red in third volume
clc
fprintf(‘Converting blue to red…nn’)
b2r_vol = volume;
b2r_vol(:, :, :, 1) = volume(:, :, :, 3);
b2r_vol(:, :, :, 3) = volume(:, :, :, 1);

% Load third slice viewer
clc
fprintf(‘Loading third slice viewer…nn’)
f3 = figure(‘Name’, ‘Gray = Gray in Slice Viewer with Red Colored Phase’);
sliceViewer(b2r_vol, parent = f3);

% Load third volume viewer
clc
fprintf(‘Loading third volume viewer…nn’)
uif3 = uifigure(‘Name’, ‘Gray = Cyan in Volume Viewer with Red Colored Phase’);
viewer3 = viewer3d(view_struct, parent = uif3);
V3 = volshow(b2r_vol, ‘Transformation’, tform, parent = viewer3);

% Convert blue to white in fourth volume
clc
fprintf(‘Converting blue to white…nn’)
b2w_vol = volume;
b2w_vol(:, :, :, 1) = volume(:, :, :, 3);
b2w_vol(:, :, :, 2) = volume(:, :, :, 3);

% Load fourth slice viewer
clc
fprintf(‘Loading fourth slice viewer…nn’)
f4 = figure(‘Name’, ‘Gray = Gray in Slice Viewer with White Colored Phase’);
sliceViewer(b2w_vol, parent = f4);

% Load fourth volume viewer
clc
fprintf(‘Loading fourth volume viewer…nn’)
uif4 = uifigure(‘Name’, ‘Gray = Gray in Volume Viewer with White Colored Phase’);
viewer4 = viewer3d(view_struct, parent = uif4);
V4 = volshow(b2w_vol, ‘Transformation’, tform, parent = viewer4);

% Add red strip in fifth volume
clc
fprintf(‘Adding red strip…nn’)
br_vol = volume;
br_vol(:, 1:25, :, 1) = 255;
br_vol(:, 1:25, :, 2:3) = 0;

% Load fifth slice viewer
clc
fprintf(‘Loading fifth slice viewer…nn’)
f5 = figure(‘Name’, ‘Gray = Gray in Slice Viewer with White Colored Phase’);
sliceViewer(br_vol, parent = f5);

% Load fifth volume viewer
clc
fprintf(‘Loading fifth volume viewer…nn’)
uif5 = uifigure(‘Name’, ‘Gray = Gray in Volume Viewer with White Colored Phase’);
viewer5 = viewer3d(view_struct, parent = uif5);
V5 = volshow(br_vol, ‘Transformation’, tform, parent = viewer5);

% End message
clc
fprintf(‘Finished!nn’)I have a segmented 3D image dataset that I am trying to visualize. Because there are two segmented phases, I am exploring different colors for each phase to make them stand out from each other. In particular, I would like one of the phases to be blue (RGB [0, 0, 255]) and the other phase to be gray (RGB [128, 128, 128]). I have created a 4D uint8 dataset of the segmented images to allow for this, and when I load the image stack in MATLAB’s sliceViewer everything looks correct. However, when I then load the same dataset in MATLAB’s volshow, it colors the gray pixels yellow while the blue pixels remain blue. See pictures below:
SliceViewer Image Showing Gray = Gray with Blue Colored Phase

Volshow Image Showing Gray = Yellow with Blue Colored Phase

I thought that perhaps there was an issue with the lighting option being colored and casting a color onto gray pixels, but I have the lighting option turned off. I then thought that perhaps there was an issue with grayscale pixels in volshow, but when I convert the gray pixels to white (RGB [255, 255, 255]) they appear white in volshow. The same exact effect is achieved if the blue pixels are reduced in intensity to RGB [0, 0, 128] while leaving the gray pixels as RGB [128, 128, 128] (the sliceViewer will look different showing a darker blue but the volshow looks identical to the picture below with a bright blue and white-colored gray pixels). See pictures below:
SliceViewer Image Showing White = White with Blue Colored Phase

Volshow Image Showing White = White with Blue Colored Phase

I then explored other colors to see if there is a specific issue with the blue/gray combination and found interesting results. When I converted the blue pixels to red (RGB [255, 0, 0]), the gray pixels remained gray in sliceViewer but now display as cyan in volshow. See pictures below:
SliceViewer Image Showing Gray = Gray with Red Colored Phase

Volshow Image Showing Gray = Cyan with Red Colored Phase

The blue/gray and red/gray tests demonstrate that volshow will replace gray pixels with the inverse RGB color of any colored pixels in the dataset (yellow is the opposite RGB of blue ([255, 255, 0] vs. [0, 0, 255]) and cyan is the opposite RGB of red ([0, 255, 255] vs. [255, 0, 0])). However, the yellow and cyan colors do not appear to be their full intensity versions ([255, 255, 0] for yellow and [0, 255, 255] for cyan) and they may have some degree of their typically absent color present, but I cannot tell as these pixels do not actually have these intensity values in the image data so I cannot tell to what the true color is that they are creating. Thus, I cannot determine to what degree the opposite colors are added and the main color is substracted from the gray pixels.
I then tried substituting the colored phase for white to see if that maintained the gray pixels, and this worked (note that it may be difficult to see the difference between white and gray in the volShow, but I turned the volume around, zoomed in, and was able to verify that this was the case). See pictures below:
SliceViewer Image Showing Gray = Gray with White Colored Phase

Volshow Image Showing Gray = Gray with White Colored Phase

I was then curious as to what would happen to the gray pixels if I added a third, differently-colored phase. So, I added a red strip down one side of the blue/gray volume. Now, the gray pixels turned green (again, to what degree the blue and red intensities were added vs. substracted and how much of the green intensity was added, I cannot know). See pictures below:
SliceViewer Image Showing Gray = Gray with Blue and Red Colored Phases

Volshow Image Showing Gray = Green with Blue and Red Colored Phases

I don’t know if I am doing something wrong, so I have provided a snippet of code that will re-create all of this as well as a google drive link (the file is >5 MB so I can’t upload it) to the dataset I am using to investigate this. The code will let you select the data and automatically load it for you and then produce all of the images I have included here in there sliceViewer and volshow formats so that you can explore them). Here is the link to the dataset and here is the code:
%% Test Case %%
close all
clear
clc

% Select image file
fprintf(‘Select an image file.nn’)
[file_name, path_intro] = uigetfile(‘*.*’, ‘Select an image file’);
file_path = sprintf(‘%s%s’, path_intro, file_name);

% Import image message
clc
fprintf(‘Importing image stack…nn’)

% Create tiff
stack_tiff = Tiff(file_path);

% Determine number of images in stack
info = imfinfo(file_path);
no_slice = numel(info);

% Determine necessary tags from tiff
bits = getTag(stack_tiff, ‘BitsPerSample’);
long = getTag(stack_tiff, ‘ImageLength’);
wide = getTag(stack_tiff, ‘ImageWidth’);
samples = getTag(stack_tiff, ‘SamplesPerPixel’);

% Pre-allocate volume array
volume = zeros(long, wide, no_slice, samples, ‘uint8’);

% Import first image
volume(:, :, 1, 🙂 = read(stack_tiff);

% Import loop
for n = 2:no_slice

% Update current directory
nextDirectory(stack_tiff);

% Add current slice to volume
volume(:, :, n, 🙂 = read(stack_tiff);

end

% Close tiff
close(stack_tiff)

% Create transformation matrix
T = [1.31 0 0 0; 0 1.31 0 0; 0 0 1.31 0; 0 0 0 1];
tform = affinetform3d(T);

% Create viewer parameters structure
view_struct = struct;

% Populate viewer parameters structure
view_struct.BackgroundColor = [1 1 1];
view_struct.BackgroundGradient = ‘off’;
view_struct.Lighting = ‘off’;

% Load first slice viewer
clc
fprintf(‘Loading first slice viewer…nn’)
f1 = figure(‘Name’, ‘Gray = Gray in Slice Viewer with Blue Colored Phase’);
sliceViewer(volume, parent = f1);

% Load first volume viewer
clc
fprintf(‘Loading first volume viewer…nn’)
uif1 = uifigure(‘Name’, ‘Gray = Yellow in Volume Viewer with Blue Colored Phase’);
viewer1 = viewer3d(view_struct, parent = uif1);
V1 = volshow(volume, ‘Transformation’, tform, parent = viewer1);

% Convert gray to white in second volume
clc
fprintf(‘Converting gray to white…nn’)
g2w_vol = volume;
g2w_vol(volume == 128) = 255;

% Load second slice viewer
clc
fprintf(‘Loading second slice viewer…nn’)
f2 = figure(‘Name’, ‘White = White in Slice Viewer with Blue Colored Phase’);
sliceViewer(g2w_vol, parent = f2);

% Load second volume viewer
clc
fprintf(‘Loading second volume viewer…nn’)
uif2 = uifigure(‘Name’, ‘White = White in Volume Viewer with Blue Colored Phase’);
viewer2 = viewer3d(view_struct, parent = uif2);
V2 = volshow(g2w_vol, ‘Transformation’, tform, parent = viewer2);

% Convert blue to red in third volume
clc
fprintf(‘Converting blue to red…nn’)
b2r_vol = volume;
b2r_vol(:, :, :, 1) = volume(:, :, :, 3);
b2r_vol(:, :, :, 3) = volume(:, :, :, 1);

% Load third slice viewer
clc
fprintf(‘Loading third slice viewer…nn’)
f3 = figure(‘Name’, ‘Gray = Gray in Slice Viewer with Red Colored Phase’);
sliceViewer(b2r_vol, parent = f3);

% Load third volume viewer
clc
fprintf(‘Loading third volume viewer…nn’)
uif3 = uifigure(‘Name’, ‘Gray = Cyan in Volume Viewer with Red Colored Phase’);
viewer3 = viewer3d(view_struct, parent = uif3);
V3 = volshow(b2r_vol, ‘Transformation’, tform, parent = viewer3);

% Convert blue to white in fourth volume
clc
fprintf(‘Converting blue to white…nn’)
b2w_vol = volume;
b2w_vol(:, :, :, 1) = volume(:, :, :, 3);
b2w_vol(:, :, :, 2) = volume(:, :, :, 3);

% Load fourth slice viewer
clc
fprintf(‘Loading fourth slice viewer…nn’)
f4 = figure(‘Name’, ‘Gray = Gray in Slice Viewer with White Colored Phase’);
sliceViewer(b2w_vol, parent = f4);

% Load fourth volume viewer
clc
fprintf(‘Loading fourth volume viewer…nn’)
uif4 = uifigure(‘Name’, ‘Gray = Gray in Volume Viewer with White Colored Phase’);
viewer4 = viewer3d(view_struct, parent = uif4);
V4 = volshow(b2w_vol, ‘Transformation’, tform, parent = viewer4);

% Add red strip in fifth volume
clc
fprintf(‘Adding red strip…nn’)
br_vol = volume;
br_vol(:, 1:25, :, 1) = 255;
br_vol(:, 1:25, :, 2:3) = 0;

% Load fifth slice viewer
clc
fprintf(‘Loading fifth slice viewer…nn’)
f5 = figure(‘Name’, ‘Gray = Gray in Slice Viewer with White Colored Phase’);
sliceViewer(br_vol, parent = f5);

% Load fifth volume viewer
clc
fprintf(‘Loading fifth volume viewer…nn’)
uif5 = uifigure(‘Name’, ‘Gray = Gray in Volume Viewer with White Colored Phase’);
viewer5 = viewer3d(view_struct, parent = uif5);
V5 = volshow(br_vol, ‘Transformation’, tform, parent = viewer5);

% End message
clc
fprintf(‘Finished!nn’) I have a segmented 3D image dataset that I am trying to visualize. Because there are two segmented phases, I am exploring different colors for each phase to make them stand out from each other. In particular, I would like one of the phases to be blue (RGB [0, 0, 255]) and the other phase to be gray (RGB [128, 128, 128]). I have created a 4D uint8 dataset of the segmented images to allow for this, and when I load the image stack in MATLAB’s sliceViewer everything looks correct. However, when I then load the same dataset in MATLAB’s volshow, it colors the gray pixels yellow while the blue pixels remain blue. See pictures below:
SliceViewer Image Showing Gray = Gray with Blue Colored Phase

Volshow Image Showing Gray = Yellow with Blue Colored Phase

I thought that perhaps there was an issue with the lighting option being colored and casting a color onto gray pixels, but I have the lighting option turned off. I then thought that perhaps there was an issue with grayscale pixels in volshow, but when I convert the gray pixels to white (RGB [255, 255, 255]) they appear white in volshow. The same exact effect is achieved if the blue pixels are reduced in intensity to RGB [0, 0, 128] while leaving the gray pixels as RGB [128, 128, 128] (the sliceViewer will look different showing a darker blue but the volshow looks identical to the picture below with a bright blue and white-colored gray pixels). See pictures below:
SliceViewer Image Showing White = White with Blue Colored Phase

Volshow Image Showing White = White with Blue Colored Phase

I then explored other colors to see if there is a specific issue with the blue/gray combination and found interesting results. When I converted the blue pixels to red (RGB [255, 0, 0]), the gray pixels remained gray in sliceViewer but now display as cyan in volshow. See pictures below:
SliceViewer Image Showing Gray = Gray with Red Colored Phase

Volshow Image Showing Gray = Cyan with Red Colored Phase

The blue/gray and red/gray tests demonstrate that volshow will replace gray pixels with the inverse RGB color of any colored pixels in the dataset (yellow is the opposite RGB of blue ([255, 255, 0] vs. [0, 0, 255]) and cyan is the opposite RGB of red ([0, 255, 255] vs. [255, 0, 0])). However, the yellow and cyan colors do not appear to be their full intensity versions ([255, 255, 0] for yellow and [0, 255, 255] for cyan) and they may have some degree of their typically absent color present, but I cannot tell as these pixels do not actually have these intensity values in the image data so I cannot tell to what the true color is that they are creating. Thus, I cannot determine to what degree the opposite colors are added and the main color is substracted from the gray pixels.
I then tried substituting the colored phase for white to see if that maintained the gray pixels, and this worked (note that it may be difficult to see the difference between white and gray in the volShow, but I turned the volume around, zoomed in, and was able to verify that this was the case). See pictures below:
SliceViewer Image Showing Gray = Gray with White Colored Phase

Volshow Image Showing Gray = Gray with White Colored Phase

I was then curious as to what would happen to the gray pixels if I added a third, differently-colored phase. So, I added a red strip down one side of the blue/gray volume. Now, the gray pixels turned green (again, to what degree the blue and red intensities were added vs. substracted and how much of the green intensity was added, I cannot know). See pictures below:
SliceViewer Image Showing Gray = Gray with Blue and Red Colored Phases

Volshow Image Showing Gray = Green with Blue and Red Colored Phases

I don’t know if I am doing something wrong, so I have provided a snippet of code that will re-create all of this as well as a google drive link (the file is >5 MB so I can’t upload it) to the dataset I am using to investigate this. The code will let you select the data and automatically load it for you and then produce all of the images I have included here in there sliceViewer and volshow formats so that you can explore them). Here is the link to the dataset and here is the code:
%% Test Case %%
close all
clear
clc

% Select image file
fprintf(‘Select an image file.nn’)
[file_name, path_intro] = uigetfile(‘*.*’, ‘Select an image file’);
file_path = sprintf(‘%s%s’, path_intro, file_name);

% Import image message
clc
fprintf(‘Importing image stack…nn’)

% Create tiff
stack_tiff = Tiff(file_path);

% Determine number of images in stack
info = imfinfo(file_path);
no_slice = numel(info);

% Determine necessary tags from tiff
bits = getTag(stack_tiff, ‘BitsPerSample’);
long = getTag(stack_tiff, ‘ImageLength’);
wide = getTag(stack_tiff, ‘ImageWidth’);
samples = getTag(stack_tiff, ‘SamplesPerPixel’);

% Pre-allocate volume array
volume = zeros(long, wide, no_slice, samples, ‘uint8’);

% Import first image
volume(:, :, 1, 🙂 = read(stack_tiff);

% Import loop
for n = 2:no_slice

% Update current directory
nextDirectory(stack_tiff);

% Add current slice to volume
volume(:, :, n, 🙂 = read(stack_tiff);

end

% Close tiff
close(stack_tiff)

% Create transformation matrix
T = [1.31 0 0 0; 0 1.31 0 0; 0 0 1.31 0; 0 0 0 1];
tform = affinetform3d(T);

% Create viewer parameters structure
view_struct = struct;

% Populate viewer parameters structure
view_struct.BackgroundColor = [1 1 1];
view_struct.BackgroundGradient = ‘off’;
view_struct.Lighting = ‘off’;

% Load first slice viewer
clc
fprintf(‘Loading first slice viewer…nn’)
f1 = figure(‘Name’, ‘Gray = Gray in Slice Viewer with Blue Colored Phase’);
sliceViewer(volume, parent = f1);

% Load first volume viewer
clc
fprintf(‘Loading first volume viewer…nn’)
uif1 = uifigure(‘Name’, ‘Gray = Yellow in Volume Viewer with Blue Colored Phase’);
viewer1 = viewer3d(view_struct, parent = uif1);
V1 = volshow(volume, ‘Transformation’, tform, parent = viewer1);

% Convert gray to white in second volume
clc
fprintf(‘Converting gray to white…nn’)
g2w_vol = volume;
g2w_vol(volume == 128) = 255;

% Load second slice viewer
clc
fprintf(‘Loading second slice viewer…nn’)
f2 = figure(‘Name’, ‘White = White in Slice Viewer with Blue Colored Phase’);
sliceViewer(g2w_vol, parent = f2);

% Load second volume viewer
clc
fprintf(‘Loading second volume viewer…nn’)
uif2 = uifigure(‘Name’, ‘White = White in Volume Viewer with Blue Colored Phase’);
viewer2 = viewer3d(view_struct, parent = uif2);
V2 = volshow(g2w_vol, ‘Transformation’, tform, parent = viewer2);

% Convert blue to red in third volume
clc
fprintf(‘Converting blue to red…nn’)
b2r_vol = volume;
b2r_vol(:, :, :, 1) = volume(:, :, :, 3);
b2r_vol(:, :, :, 3) = volume(:, :, :, 1);

% Load third slice viewer
clc
fprintf(‘Loading third slice viewer…nn’)
f3 = figure(‘Name’, ‘Gray = Gray in Slice Viewer with Red Colored Phase’);
sliceViewer(b2r_vol, parent = f3);

% Load third volume viewer
clc
fprintf(‘Loading third volume viewer…nn’)
uif3 = uifigure(‘Name’, ‘Gray = Cyan in Volume Viewer with Red Colored Phase’);
viewer3 = viewer3d(view_struct, parent = uif3);
V3 = volshow(b2r_vol, ‘Transformation’, tform, parent = viewer3);

% Convert blue to white in fourth volume
clc
fprintf(‘Converting blue to white…nn’)
b2w_vol = volume;
b2w_vol(:, :, :, 1) = volume(:, :, :, 3);
b2w_vol(:, :, :, 2) = volume(:, :, :, 3);

% Load fourth slice viewer
clc
fprintf(‘Loading fourth slice viewer…nn’)
f4 = figure(‘Name’, ‘Gray = Gray in Slice Viewer with White Colored Phase’);
sliceViewer(b2w_vol, parent = f4);

% Load fourth volume viewer
clc
fprintf(‘Loading fourth volume viewer…nn’)
uif4 = uifigure(‘Name’, ‘Gray = Gray in Volume Viewer with White Colored Phase’);
viewer4 = viewer3d(view_struct, parent = uif4);
V4 = volshow(b2w_vol, ‘Transformation’, tform, parent = viewer4);

% Add red strip in fifth volume
clc
fprintf(‘Adding red strip…nn’)
br_vol = volume;
br_vol(:, 1:25, :, 1) = 255;
br_vol(:, 1:25, :, 2:3) = 0;

% Load fifth slice viewer
clc
fprintf(‘Loading fifth slice viewer…nn’)
f5 = figure(‘Name’, ‘Gray = Gray in Slice Viewer with White Colored Phase’);
sliceViewer(br_vol, parent = f5);

% Load fifth volume viewer
clc
fprintf(‘Loading fifth volume viewer…nn’)
uif5 = uifigure(‘Name’, ‘Gray = Gray in Volume Viewer with White Colored Phase’);
viewer5 = viewer3d(view_struct, parent = uif5);
V5 = volshow(br_vol, ‘Transformation’, tform, parent = viewer5);

% End message
clc
fprintf(‘Finished!nn’) volshow, image processing, image segmentation MATLAB Answers — New Questions

​

Tags: matlab

Share this!

Related posts

How to debug C# .NET assembly called from MATLAB?
2025-05-15

How to debug C# .NET assembly called from MATLAB?

How do I set the size of a tile from tiledlayout?
2025-05-15

How do I set the size of a tile from tiledlayout?

Communicate with worker through client
2025-05-15

Communicate with worker through client

Leave a Reply Cancel reply

Your email address will not be published. Required fields are marked *

Search

Categories

  • Matlab
  • Microsoft
  • News
  • Other
Application Package Repository Telkom University

Tags

matlab microsoft opensources
Application Package Download License

Application Package Download License

Adobe
Google for Education
IBM
Matlab
Microsoft
Wordpress
Visual Paradigm
Opensource

Sign Up For Newsletters

Be the First to Know. Sign up for newsletter today

Application Package Repository Telkom University

Portal Application Package Repository Telkom University, for internal use only, empower civitas academica in study and research.

Information

  • Telkom University
  • About Us
  • Contact
  • Forum Discussion
  • FAQ
  • Helpdesk Ticket

Contact Us

  • Ask: Any question please read FAQ
  • Mail: helpdesk@telkomuniversity.ac.id
  • Call: +62 823-1994-9941
  • WA: +62 823-1994-9943
  • Site: Gedung Panambulai. Jl. Telekomunikasi

Copyright © Telkom University. All Rights Reserved. ch

  • FAQ
  • Privacy Policy
  • Term

This Application Package for internal Telkom University only (students and employee). Chiers... Dismiss