Slicing .vol 3D volume file into 2D images
5 vues (au cours des 30 derniers jours)
Afficher commentaires plus anciens
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
![](https://www.mathworks.com/matlabcentral/answers/uploaded_files/824985/image.png)
0 commentaires
Réponse acceptée
yanqi liu
le 7 Déc 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
Plus de réponses (0)
Voir également
Catégories
En savoir plus sur 3-D Volumetric Image Processing dans Help Center et File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!