Alpha mapping using 'surf'

조회 수: 17 (최근 30일)
Jakob Sørensen
Jakob Sørensen 2012년 4월 27일
Hey,
I'm trying to make part of a surface, created using the 'surf' function, transparent. Its a 300x300 image that is surfed as following:
% --- AZ-PLANE ---
Y = linspace(-boxSize/2, boxSize/2, viewInf.resolution);
Z = linspace(0, boxSize, viewInf.resolution);
Y = repmat(Y , [viewInf.resolution 1]);
Z = repmat(Z', [1 viewInf.resolution]);
X = xPush*ones(viewInf.resolution);
% Draw plane
azSurf = surf(X,Y,Z, azPlane.Image);
% Set properties
set(azSurf, 'EdgeColor', 'none');
Since some of the values are NaN, they are already transparent, but i need more than that. The code below has a constant alpha map, but that's just for testing purposes, its gonna be changed later on. The alpha map is made and applied like this
alphaMapAz = 0.1*ones(size(azPlane.Image));
set(azSurf, 'AlphaData', alphaMapAz, 'AlphaDataMapping', 'none');
Yet no transparency occurs. What the duck am I doing wrong here?
  댓글 수: 1
Daniel Shub
Daniel Shub 2012년 4월 27일
It would be helpful if you included a MWE, what you see, and what you expect to see. That way we could easily run your example and see what is happening. In this case it is probably useful to know what OS and renderer (e.g., OPEN GL or painters) you are using.

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

채택된 답변

Daniel Shub
Daniel Shub 2012년 4월 27일
From the MWE add
set(azSurf, 'FaceAlpha', 'flat');
you may also want to look at
doc alpha
  댓글 수: 1
Jakob Sørensen
Jakob Sørensen 2012년 4월 27일
I could have sworn I already tried that... But thanks!

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

추가 답변 (1개)

Jakob Sørensen
Jakob Sørensen 2012년 4월 27일
OS is Ubuntu 10.04 LTS. And it can do opacity using a single fixed value, its only when trying to use a map, that im struggling.
Minimal working example inc:
% --- AZ-PLANE ---
Y = linspace(-5, 5, 500);
Z = linspace(0, 10, 500);
Y = repmat(Y , [500 1]);
Z = repmat(Z', [1 500]);
X = -2*ones(500);
% Draw plane
azSurf = surf(X,Y,Z, magic(500));
% Set properties
set(azSurf, 'EdgeColor', 'none');
% Set alpha map
alphaMapAz = 0.1*ones(size(azPlane.Image));
set(azSurf, 'AlphaData', alphaMapAz, 'AlphaDataMapping', 'none');
  댓글 수: 1
Daniel Shub
Daniel Shub 2012년 4월 27일
you need to change azPlane.Image to X

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

카테고리

Help CenterFile Exchange에서 Surface and Mesh Plots에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!

Translated by