Slicing .vol 3D volume file into 2D images

9 visualizaciones (últimos 30 días)
Petr Miarka
Petr Miarka el 6 de Dic. de 2021
Comentada: Petr Miarka el 21 de Dic. de 2021
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

Respuesta aceptada

yanqi liu
yanqi liu el 7 de Dic. de 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

Más respuestas (0)

Productos


Versión

R2021b

Community Treasure Hunt

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

Start Hunting!

Translated by