Slicing .vol 3D volume file into 2D images
4 次查看(过去 30 天)
显示 更早的评论
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
0 个评论
采纳的回答
yanqi liu
2021-12-7
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
更多回答(0 个)
另请参阅
类别
在 Help Center 和 File Exchange 中查找有关 3-D Volumetric Image Processing 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!