creating a 3d sphere (as a mask) on a 3D image
10 views (last 30 days)
Show older comments
I am using a 3D raw image (size of PET image(float) is [84*71*103] with spacing size of 4.07*4.07*3 mm). what I want to do is, using the voxel coordinates that correspond to center of the tumor(defined by me) [116,177,86], create a sphere in which the center of a sphere will be the same as the center of the tumor. The diameter of the sphere I want to change to a maximum of a little bigger than the tumor itself. So the sphere is basically going to be serving as a mask which is overlaid with the image and I can get the statistics of the values of the image within that spherical shape. I hope I have made it clear enough. I would really appreciate your help.My code is not working correctly, I am very confused in how to proceed. {
fid_1 = fopen('I:\PatientData\PET1_DIFF.img','r','l');
pet1_diff = fread(fid_1,'float32');
pet1_diff = reshape(pet1_diff, [84 71 103]);
pet1_diff = imrotate(pet1_diff,90,'nearest','crop');
figure(1);
imagesc(pet1_diff(:,:,30)); title('PET1_DIFF');
fclose(fid_1);
imageSizeX = 84;
imageSizeY = 71;
imageSizeZ = 103;
[columnsInImage rowsInImage pagesInImage] = meshgrid(1:imageSizeX, 1:imageSizeY, 1:imageSizeZ);
%creating the sphere in the image.coordinates of sphere center(tumor center)
centerX = 116;
centerY = 177;
centerZ = 86;
radius = 5;
sphereVoxels = (rowsInImage - centerY).^2 ...
+ (columnsInImage - centerX).^2 + (pagesInImage - centerZ).^2 <= radius.^2;
% sphereVoxels is a 3D "logical" array.
% Now, display it using an isosurface and a patch
fv = isosurface(sphereVoxels,0);
patch(fv,'FaceColor',[0 0 .7],'EdgeColor',[0 0 1]);
view(45,45);
axis equal;
title('Binary volume of a sphere')
}
0 Comments
Answers (0)
See Also
Categories
Find more on Surface and Mesh Plots in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!