How to obtain an intensity matrix from a surface object?

조회 수: 3 (최근 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 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