Hello,
I am trying to take this binary 3D plot and color code the layers by depth. For example if z =1, all pixels are red; if z = 25, all pixels are orange, etc...I would like the color scale to be continuous. Any help on this would be appreciated. This is what I have thus far:
stack = tiff(:,:,:);
T = adaptthresh(stack, 0.57,'neigh', [99 99 99], 'ForegroundPolarity', 'dark');
bw = imbinarize(stack,T); %applies adaptive threshold to image
x = 1:size(stack,2);
y = 1:size(stack,1);
z = 1:size(stack,3);
figure(1),isosurface(x,y,z,stack,0.5)
pores.png

1 件のコメント

Brian Hart
Brian Hart 2019 年 1 月 22 日
You can probably do this by changing the figure color map. It would help to have the input TIFF file to play with.

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

 採用された回答

Walter Roberson
Walter Roberson 2019 年 1 月 22 日

0 投票

See https://www.mathworks.com/help/matlab/ref/isosurface.html#bq349vy-1 for an example of coloring by x. In the isosurface() call in that example, you would replace the final x by z to color by z.

5 件のコメント

Emily Pendleton
Emily Pendleton 2019 年 1 月 22 日
I tried this, and my code now looks like this, but I'm getting the error 'COLORS array must be the same size as V.' I am not sure how to get around this issue. Any advice?
stack = tiff(:,:,:);
T = adaptthresh(stack, 0.57,'neigh', [99 99 99], 'ForegroundPolarity', 'dark');
bw = imbinarize(stack,T); %applies adaptive threshold to image
x = 1:size(stack,2);
y = 1:size(stack,1);
z = 1:size(stack,3);
[faces,verts,colors] = isosurface(x,y,z,bw2,0.5,z);
patch('Vertices',verts,'Faces',faces,'FaceVertexCData',colors,...
'FaceColor','interp','EdgeColor','interp')
view(30,-15)
axis vis3d
colormap jet
Walter Roberson
Walter Roberson 2019 年 1 月 22 日
What is bw2 ? You create bw here but not bw2.
[X, Y, Z] = meshgrid(X, Y, Z);
[faces,verts,colors] = isosurface(X, Y, Z, bw, 0.5, Z);
Emily Pendleton
Emily Pendleton 2019 年 1 月 22 日
sorry...
bw2 is the same as stack. I copied an abreviated version of my code here for simplicity. It should read:
stack = tiff(:,:,:);
T = adaptthresh(stack, 0.57,'neigh', [99 99 99], 'ForegroundPolarity', 'dark');
bw = imbinarize(stack,T); %applies adaptive threshold to image
x = 1:size(stack,2);
y = 1:size(stack,1);
z = 1:size(stack,3);
[faces,verts,colors] = isosurface(x,y,z,stack,0.5,z);
patch('Vertices',verts,'Faces',faces,'FaceVertexCData',colors,...
'FaceColor','interp','EdgeColor','interp')
view(30,-15)
axis vis3d
colormap jet
Walter Roberson
Walter Roberson 2019 年 1 月 22 日
Then the two lines I suggested should probably work.
Emily Pendleton
Emily Pendleton 2019 年 1 月 23 日
It does, thank you!

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

その他の回答 (0 件)

カテゴリ

Community Treasure Hunt

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

Start Hunting!

Translated by