Slicing .vol 3D volume file into 2D images

4 ビュー (過去 30 日間)
Petr Miarka
Petr Miarka 2021 年 12 月 6 日
コメント済み: Petr Miarka 2021 年 12 月 21 日
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

採用された回答

yanqi liu
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
  1 件のコメント
Petr Miarka
Petr Miarka 2021 年 12 月 21 日
Thank you very much, this works perfectly!

サインインしてコメントする。

その他の回答 (0 件)

カテゴリ

Help Center および File Exchange3-D Volumetric Image Processing についてさらに検索

製品


リリース

R2021b

Community Treasure Hunt

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

Start Hunting!

Translated by