Slicing .vol 3D volume file into 2D images

4 views (last 30 days)
Hello all,
I would like to ask you, if there is any possible way how to slice 3D volume to 2D images.
For example I have .vol file which I am able to load and open in Matlab and more I am able to start processing it in volumeSegmenter. However, creating mask for each defect by hand is very ineffective and I would like to automate this by using another fuction in ImageProcessing Toolbox.
More specifically, I would like to use function edge to help me find the different location based on grayscale intesity difference and then in 3D in might help me to render the defect in 3D.
Here is an example of my code (part of that is what I have found already here):
fid = fopen("CT.vol");
voxels = fread(fid, '*uint16'); %read as 16 bit unsigned. I'm assuming they're unsigned
fclose(fid);
sizes = {[1990,1305, 1700]};
voxels = reshape(voxels, sizes{1});
% openening in in volumeSegmenter app:
volumeSegmenter(voxels);
The code I am using basically does this for me (see the attached image), but I can't save any slice from the app into 2D image. Can you propose some method to do so, please? Futhermore, I would like to save slices along the y-axis from 500-1000 coordinates.
Thank you in advance,
Petr

Accepted Answer

yanqi liu
yanqi liu on 7 Dec 2021
yes,sir,may be upload the 3D file to do some analysis,or check the follow code
close all;
clear all;
clc;
fid = fopen("CT.vol");
voxels = fread(fid, '*uint16'); %read as 16 bit unsigned. I'm assuming they're unsigned
fclose(fid);
sizes = {[1990,1305, 1700]};
voxels = reshape(voxels, sizes{1});
if ~exist(fullfile(pwd, 'tmp'), 'dir')
mkdir(fullfile(pwd, 'tmp'));
end
for i = 1 : size(voxels, 3)
fi = fullfile(pwd, 'tmp', sprintf('%04d.png', i));
imwrite(mat2gray(voxels(:,:,i)), fi);
end

More Answers (0)

Products


Release

R2021b

Community Treasure Hunt

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

Start Hunting!