Plot image in 3D and ignore certain values

I’d like to visualise the following image (see the image) in 3D without showing the blue part (see the 3D plot). The image is basically a plane where the white part has intensity values ranging from 247 to 252. The black part has intensity value 0. Please find the image in the attachment.
Image:
3D plot:
Here is the code I am using to visualize the image in 3D:
Img_8Bit = imread('Image-1.png');
figure
surf(Img_8Bit,'EdgeColor','none');
Any suggestions?

 採用された回答

Rik
Rik 2018 年 8 月 6 日

0 投票

If you switch to double, you can set the zeros to NaN, which will be hidden by surf. You'll then have to adjust the axis limits and color axis limits.
Img_8Bit = imread('Image-1.png');
Img_double=double(Img_8Bit);
Img_double(Img_double==0)=NaN;
figure(1),clf(1)
surf(Img_double,'EdgeColor','none');
axlims=[1 size(Img_double,2) 1 size(Img_double,1) 0 255];
caxis([0 255]),axis(axlims)

1 件のコメント

Tariqul
Tariqul 2018 年 8 月 6 日
Great, works nicely!

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

その他の回答 (0 件)

カテゴリ

ヘルプ センター および File ExchangeImages についてさらに検索

タグ

質問済み:

2018 年 8 月 6 日

コメント済み:

2018 年 8 月 6 日

Community Treasure Hunt

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

Start Hunting!

Translated by