在 3D 图像上创建球体(作为蒙版)
creating a sphere (as a mask) on a 3D image
我正在使用 3D 原始图像(PET 图像(浮动)的大小为 [84*71*103],间距大小为 4.07*4.07*3 毫米)。
我想:
- 使用对应于肿瘤中心(由我定义)的体素坐标
[116,177,86]
,并创建一个与肿瘤中心同心的球体。
- 将球体的直径更改为比肿瘤本身大一点。
所以球体将作为覆盖在图像上的遮罩,我可以获得该球形内图像值的统计信息。
我希望我说得够清楚了。我将衷心感谢您的帮助。我的代码无法正常工作,我不知道如何继续。
fid_1 = fopen('I:\PatientData\patient3\case1\DIR_CT1toCT2\New-
crop\PET1FEM_PET2_DIFF.img','r','l');
pet1fem_pet2_diff = fread(fid_1,'float32');
pet1fem_pet2_diff = reshape(pet1fem_pet2_diff, [84 71 103]);
% interpolation is nearest neighbour, and 'crop' Makes output the same size as the input image
pet1fem_pet2_diff = imrotate(pet1fem_pet2_diff,90,'nearest','crop');
% create the image
imageSizeX = 84;
imageSizeY = 71;
imageSizeZ = 103;
% columns are in the x direction and, rows are in the y direction
[columnsInImage rowsInImage pagesInImage] = meshgrid(1:imageSizeX, 1:imageSizeY,1:imageSizeZ);
% Next create the sphere in the image.
centerX = 29;
centerY = 26;
centerZ = 74;
radius = 5;
nonSphereVoxels = (rowsInImage - centerY).^2 ...
+ (columnsInImage - centerX).^2 + (pagesInImage - centerZ).^2 > radius.^2;
pet1fem_pet2_diff(nonSphereVoxels) = 0;
figure(1);
imagesc(pet1fem_pet2_diff(:,:,30));
title('PET1FEM-PET2-DIFF');
我已经解决了您问题的简化二维版本,希望这有助于回答您的问题。对于初学者,让我们创建一个输入
A = rand(128,128); % this is your pet1_diff data
% you can plot it like this:
clf reset
imagesc(A)
daspect([1 1 1])
接下来,我们应用截断:
[x,y] = meshgrid(1:128,1:128);
r2 = ((x-40).^2 + (y-40).^2) > 10^2; % radius 10 cutoff from position (40,40)
A(r2) = 0; % delete pixels outside the cutoff radius
% plot the filtered data
clf reset
imagesc(A)
daspect([1 1 1])
这是您想要的结果吗?
我正在使用 3D 原始图像(PET 图像(浮动)的大小为 [84*71*103],间距大小为 4.07*4.07*3 毫米)。
我想:
- 使用对应于肿瘤中心(由我定义)的体素坐标
[116,177,86]
,并创建一个与肿瘤中心同心的球体。 - 将球体的直径更改为比肿瘤本身大一点。
所以球体将作为覆盖在图像上的遮罩,我可以获得该球形内图像值的统计信息。
我希望我说得够清楚了。我将衷心感谢您的帮助。我的代码无法正常工作,我不知道如何继续。
fid_1 = fopen('I:\PatientData\patient3\case1\DIR_CT1toCT2\New-
crop\PET1FEM_PET2_DIFF.img','r','l');
pet1fem_pet2_diff = fread(fid_1,'float32');
pet1fem_pet2_diff = reshape(pet1fem_pet2_diff, [84 71 103]);
% interpolation is nearest neighbour, and 'crop' Makes output the same size as the input image
pet1fem_pet2_diff = imrotate(pet1fem_pet2_diff,90,'nearest','crop');
% create the image
imageSizeX = 84;
imageSizeY = 71;
imageSizeZ = 103;
% columns are in the x direction and, rows are in the y direction
[columnsInImage rowsInImage pagesInImage] = meshgrid(1:imageSizeX, 1:imageSizeY,1:imageSizeZ);
% Next create the sphere in the image.
centerX = 29;
centerY = 26;
centerZ = 74;
radius = 5;
nonSphereVoxels = (rowsInImage - centerY).^2 ...
+ (columnsInImage - centerX).^2 + (pagesInImage - centerZ).^2 > radius.^2;
pet1fem_pet2_diff(nonSphereVoxels) = 0;
figure(1);
imagesc(pet1fem_pet2_diff(:,:,30));
title('PET1FEM-PET2-DIFF');
我已经解决了您问题的简化二维版本,希望这有助于回答您的问题。对于初学者,让我们创建一个输入
A = rand(128,128); % this is your pet1_diff data
% you can plot it like this:
clf reset
imagesc(A)
daspect([1 1 1])
接下来,我们应用截断:
[x,y] = meshgrid(1:128,1:128);
r2 = ((x-40).^2 + (y-40).^2) > 10^2; % radius 10 cutoff from position (40,40)
A(r2) = 0; % delete pixels outside the cutoff radius
% plot the filtered data
clf reset
imagesc(A)
daspect([1 1 1])
这是您想要的结果吗?