set opacity to M x N x P grayscale matrix

I have a matrix define as data = rand(M,N,P) where M = 262, N = 359, P = 562. Each element in the matrix gets assigned an intensity value for 0 - 255 depending on input scan data.
E.g. data(200,220,232) = 32 or data(200,220,233) = 156
How can i assign transparency to each element in the matrix based on the intensity value. For example: all intensities below 128 have 0.8 transparency, and every value between 128-255 has linear opacity from 0.1-0.4
This is all in Matlab.
Thank you

 채택된 답변

Youssef  Khmou
Youssef Khmou 2014년 1월 25일

0 개 추천

Logical operations can divide the elements, here is the starting point :
M=rand(262,359,562);
Threshold=0.45; % an example
E=M ;% matrix of transparency
E(E<Threshold)=0.8;
E(E>Threshold)=0.4;

댓글 수: 2

So if I understand the solution correctly, I should have two matrices. One with transparency and the other with actual intensities between 0-255.
Does this mean, when I place this a 3D grid. I should overlay the two matrices?
Right now i have a matrix mapped_3d(282,359,562) that gets passed to
vol3d('Cdata',mapped_3d);view(3);
function and it generates this figure.
However, if I want to make all dark points in the volume transparent, should I just pass the transparency matrix to vol3d function?
Youssef  Khmou
Youssef Khmou 2014년 1월 25일
편집: Youssef Khmou 2014년 1월 25일
I can not understand your approach, the proposition i posted is from mathematical viewpoint, but making the transparency in 3D plot is something that needs more details

댓글을 달려면 로그인하십시오.

추가 답변 (1개)

Walter Roberson
Walter Roberson 2014년 1월 25일

0 개 추천

Transparency is a property of images, not of matrices. And there is no build-in method in MATLAB to create a 4-dimensional plot (three axis plus value at each point = 4 dimensions.) You have to define how you are planning to display the data, and then we can talk about transparency.

댓글 수: 2

I suspected that was the case. To visualize the matrix I am using vol3d function found at: http://www.mathworks.com/matlabcentral/fileexchange/22940-vol3d-v2
An example of how the data is shown here in this image. (Same as the one i answered in another answer).
It is generated by this line of code.
vol3d('cdata',mapped_3d);
where mapped_3d is the 3 dimensional matrix
I would have to look more closely at the program some time. I think it is creating patch objects with 3D volume areas (marching cubes algorithm I seem to recall.) If it is, then a patch() would have been generated; try
findobj(gca, 'type', 'patch')
Once you find that patch object, you can adjust it's AlphaCData property

댓글을 달려면 로그인하십시오.

질문:

2014년 1월 25일

편집:

2014년 1월 25일

Community Treasure Hunt

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

Start Hunting!

Translated by