How to obtain an intensity matrix from a surface object?

1 次查看(过去 30 天)
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 CenterFile Exchange 中查找有关 Lighting, Transparency, and Shading 的更多信息

标签

Community Treasure Hunt

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

Start Hunting!

Translated by