필터 지우기
필터 지우기

see a 2d plane from a 3d image

조회 수: 2 (최근 30일)
Marcelo hernandez
Marcelo hernandez 2018년 10월 27일
댓글: Image Analyst 2018년 10월 27일
The code to form a sphere of 100x100x10 pixels is the following
%
imageSizeX = 100;
imageSizeY = 100;
imageSizeZ = 100;
[X,Y,Z] = ndgrid(1:imageSizeX, 1:imageSizeY, 1:imageSizeZ);
% Next create the circle in the image.
centerX = 50;
centerY = 50;
centerZ = 50;
radius = 25;
circlePixels = (Z-centerZ).^2 + (Y-centerY).^2 + (X-centerX).^2 <= radius.^2;
I would like to visualize a horizontal plane 2d in some position z of the sphere in a square of 100x100 pixels, obviously this image would be a circle.
How would that be done, thank you very much.

채택된 답변

Image Analyst
Image Analyst 2018년 10월 27일
Try slice().
  댓글 수: 2
Marcelo hernandez
Marcelo hernandez 2018년 10월 27일
matlab says that Input grid is not valid MESHGRID. i try
%
xslice = 10;
yslice = [];
zslice = [];
slice(X,Y,Z,circlePixels,xslice,yslice,zslice,'nearest')
Image Analyst
Image Analyst 2018년 10월 27일
Try this:
imageSizeX = 100;
imageSizeY = 100;
imageSizeZ = 100;
[X,Y,Z] = ndgrid(1:imageSizeX, 1:imageSizeY, 1:imageSizeZ);
% Next create the circle in the image.
centerX = 50;
centerY = 50;
centerZ = 50;
radius = 25;
circlePixels = (Z-centerZ).^2 + (Y-centerY).^2 + (X-centerX).^2 <= radius.^2;
circlePixels = double(circlePixels);
zslice = 50;
slice(circlePixels,[],[],zslice,'nearest')

댓글을 달려면 로그인하십시오.

추가 답변 (0개)

카테고리

Help CenterFile Exchange에서 Surface and Mesh Plots에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!

Translated by