필터 지우기
필터 지우기

Trying to 3d plot binary cubes

조회 수: 13 (최근 30일)
Simon Penninag
Simon Penninag 2021년 2월 6일
댓글: Simon Penninag 2021년 2월 9일
Hi all,
I'm trying to generate a 32x32x32 image but I cannot manage to visualize it.
I'm using matlab R2020b with the image processing toolbox, and I want to place cubes at 32x32x32 indices with a value of either 1 or 0.
Below you can see the example in 2D, first the random gaussian noise is generated in a 32x32 grid, then filtered and cut-off.
The code I have to generate this is very straight-forward but visualizing seems to be the difficult part as this has to be a 4D plot, where 3 dimensions are simply indices and the 4th is the binary value (or greyscale). Can anyone help me plot this? I have tried things like surf, plot3, scatter3, but I couldn't get any of them to work.
I can validate that the correct data is there through montage(BW) but this gives me slices rather than a 3D image.
%%
sigma = 2;
vertice = 32;
level = 0.5;
image = rand(vertice,vertice,vertice);
filtered = imgaussfilt3(image,sigma);
BW = imbinarize(filtered,level);
montage(BW)
  댓글 수: 2
KALYAN ACHARJYA
KALYAN ACHARJYA 2021년 2월 7일
"3d plot binary cubes"
Can you attach any reference image or replication drawing to undestand the question?
What type of the data you have, dimentions and data type?
Simon Penninag
Simon Penninag 2021년 2월 7일
Hi Kalyan,
there are images on the original post, i hope you can see them. The data is generated in the code that is shown (its just random 32x32x32 doubles of noise). All im trying to produce is a 3D plot of this 32x32x32 cube of random noise.
A reference image:

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

채택된 답변

Kiran Felix Robert
Kiran Felix Robert 2021년 2월 9일
편집: Kiran Felix Robert 2021년 2월 9일
Hi Simon,
Use the slice command and specify the slice position as vector argument.
The following is an example,
colormap gray
sigma = 2;
vertice = 32;
level = 0.5;
image = rand(vertice,vertice,vertice);
filtered = imgaussfilt3(image,sigma);
BW = double(imbinarize(filtered,level)); % Convert to double
slice(BW,1:32,1:32,1:32) % 3D Plot for 32x32x32 image
  댓글 수: 1
Simon Penninag
Simon Penninag 2021년 2월 9일
Thanks, this is exactly what I was after!

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

추가 답변 (0개)

카테고리

Help CenterFile Exchange에서 Images에 대해 자세히 알아보기

제품


릴리스

R2020b

Community Treasure Hunt

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

Start Hunting!

Translated by