HOW TO CHANGE BINARY IMAGES TO 3D ARRAY (CONVERT TO 3D DIMENSION)

24 ビュー (過去 30 日間)
mohd akmal masud
mohd akmal masud 2021 年 10 月 7 日
コメント済み: Image Analyst 2021 年 10 月 8 日
Hi all, I have 41 binary images.
Anyone know how convert it into 3D?
I means now my binary images just have dimension(let say 256 x 256). Then how to add thickness (as example thickness: 2.332) into that binary images?
So that my binary images now in 3D, (example 256x256x2.332)
Anyone can help me?
  6 件のコメント
Image Analyst
Image Analyst 2021 年 10 月 8 日
No, that just overwrites I every iteration.
mohd akmal masud
mohd akmal masud 2021 年 10 月 8 日
Hi sir Image Analyst, can you help me, maybe you can write the code?
Please help me sir?

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

採用された回答

DGM
DGM 2021 年 10 月 8 日
As per Rik's suggestion:
% ...
% assuming that your dicom images and binary images have same page geometry
numframes = 41;
s = [size(P,1) size(P,2)];
maskstack = zeros(s(1),s(2),numframes);
for f = 1:numframes
if f == 1
cast(maskstack,class(readimage(imds,f)));
end
maskstack(:,:,f) = readimage(imds,f);
end
% build location arrays
[X Y Z] = ndgrid(1:s(1),1:s(2),0:2.332:(numframes-1)*2.332);
Or something like that.
  1 件のコメント
mohd akmal masud
mohd akmal masud 2021 年 10 月 8 日
yah, dicom images and binary images have same page geometry.
but after that, how to develop it into 4D?
is it like this?
% to view as 4D
p = patch(isosurface(X, Y, Z));
axis equal
set(p,'FaceColor','c','EdgeColor','none');
alpha(p,1)
hold

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

その他の回答 (1 件)

Image Analyst
Image Analyst 2021 年 10 月 8 日
If you want, just consider your 256x256 image as having a thickness of 2.332 millimeters or centimeters or whatever. There is nothing to do to the image. However if you compute something like area of some region and want the volume in 3-D you have to multiply the area by the square of the lateral pixelsPerMm and then by the z-direction slice spacing of 2.332 to get the volume in mm.
  2 件のコメント
mohd akmal masud
mohd akmal masud 2021 年 10 月 8 日
yah..you are right sir. that is to get the volume,
but my problem is how to paste the binary image that have value 1 into the origional images (dicom images that have pixel value).
ok let me explain,
let say my origional images is
K = dicomread('image1.dcm');
note: let say the dimension is 256x256x2.332
after i do the segmentation, the binary image become binary images that have value 1 and 0. It is became 2D images because the method of segmentation have to do so.
then, i want mark it, the value 1 is foreground, and the value 0 background. because the origional image (dicom image) have pixel number each voxel.
below is the code that Ihave tried.
% For 3D images
clc
clear all
myFolder = ('C:\Users\Akmal\Desktop\I-131 256 28.02.2020\I-131 SPECT NEMA VALIDATION 01112019 256X256 26.09.2021 petang\dcmoriextract');
filePattern = fullfile(myFolder, '*.dcm'); % Change to whatever pattern you need.
theFiles = dir(filePattern);
for K = 1 : length(theFiles)
baseFileName = theFiles(K).name;
fullFileName = fullfile(theFiles(K).folder, baseFileName);
fprintf(1, 'Now reading %s\n', fullFileName);
% Now do whatever you want with this file name,
% such as reading it in as an image array with imread()
P(:,:,K) = dicomread(fullFileName);
end
% For binary images
dataSetDir = fullfile('C:\Users\Akmal\Desktop\I-131 256 28.02.2020\I-131 SPECT NEMA VALIDATION 01112019 256X256 26.09.2021 petang');
imageDir = fullfile(dataSetDir,'bnwaftersegmentation');
imds = imageDatastore(imageDir);
for i = 1:41
% subplot(6,7,i)
I = readimage(imds,i);
end
% to view as 4D
p = patch(isosurface((P(I==1))));
axis equal
set(p,'FaceColor','c','EdgeColor','none');
alpha(p,1)
hold
but ihave problem in my binary images is 2D, so I got error like below
Error using smooth3 (line 51) V must be a 3D array.
THIS IS IMAGE THAT SUPPOSELY I WANT like below
can you help me sir?? Please..
Image Analyst
Image Analyst 2021 年 10 月 8 日
Again, you're overwriting I on each iteration so it will only have the last image in it. I don't see where you're calling smooth3 but if you're passing it I, and if I is only a 2-D array, you'll get that error.

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

カテゴリ

Help Center および File ExchangeExplore and Edit Images with Image Viewer App についてさらに検索

Community Treasure Hunt

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

Start Hunting!

Translated by