How to obtain an intensity matrix from a surface object?

2 ビュー (過去 30 日間)
wals
wals 2020 年 4 月 21 日
編集済み: Ameer Hamza 2020 年 4 月 21 日
Hi,
I've sliced a set of volumetric data (V) using the function sl = slice(V,xslice,yslice,zslice).
I end up with a surface object like the one in the image. I need to get a 2D matrix that matches in size the area of my surface and has value 0 where the surface is dark and value 1 where the surface is yellow. In practice, i need to map the position of the yellow circles by having the coordinates of every yellow pixel. Can you please help me?

採用された回答

Mehmed Saad
Mehmed Saad 2020 年 4 月 21 日
This might work for your case (it is not necessary that this works for every condition)
[X,Y,Z] = meshgrid(-2:.2:2);
V = X.*exp(-X.^2-Y.^2-Z.^2);
xslice = [];
yslice = [];
zslice = 1;
h= slice(X,Y,Z,V,xslice,yslice,zslice);
mat_2d = h.CData;
figure,surf(mat_2d)
  1 件のコメント
wals
wals 2020 年 4 月 21 日
Thanks for your help! Unfortunately I've tried that, and for some reason I always end up with an empty array, as if CData only contained zeros.. I'm attaching the slice i get, maybe looking at it direcly helps finding a solution

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

その他の回答 (1 件)

Ameer Hamza
Ameer Hamza 2020 年 4 月 21 日
編集済み: Ameer Hamza 2020 年 4 月 21 日
Try this. It extracts color value from the surface and find the center of each circle, using the functions from image processing toolbox.
load('sl.mat');
im = sl(3).CData;
im = imbinarize(im);
reg = regionprops(im);
centers = reshape([reg.Centroid], 2, [])';
x_center = centers(:,1);
y_center = centers(:,2);
figure;
imshow(im);
hold on;
plot(x_center, y_center, 'r+');

カテゴリ

Help Center および File ExchangeLighting, Transparency, and Shading についてさらに検索

タグ

Community Treasure Hunt

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

Start Hunting!

Translated by