Drawing Multiple surf Plots with Different Color Map and Different Transparencies
6 visualizaciones (últimos 30 días)
Mostrar comentarios más antiguos
Arda Kayaalp
el 7 de Oct. de 2022
Comentada: Arda Kayaalp
el 17 de Oct. de 2022
Hello MATLAB Community! I've been working on CT slice visualising. I've extracted CT slices from DICOM file and plotted RT contours on top of it using the hold on. I used surf function to generete slice view and plot function to plot contours on top. Right now the view is something like this,
![](https://www.mathworks.com/matlabcentral/answers/uploaded_files/1148425/image.png)
This is the main viewing angle, from the side plot looking like this,
![](https://www.mathworks.com/matlabcentral/answers/uploaded_files/1148430/image.png)
I used surf function to plot the slice because the geometry manupulation of the CT geometry is easier and its working well so far. What I like to do now is to overlay dose map on top of this. Without CT, surf dose looking like this,
![](https://www.mathworks.com/matlabcentral/answers/uploaded_files/1148435/image.png)
From the side,
![](https://www.mathworks.com/matlabcentral/answers/uploaded_files/1148440/image.png)
The dose array has the same structure as the CT slices. I want to overlay this on top of the CT slice and when I looking from the 90 angle (like in the main viewing angle from the first picture) I want to see CT slice, the dose heatmap and contours as well. I tried changing alpha values with hold on but it did not work. How can I achieve such thing?
4 comentarios
Respuesta aceptada
DGM
el 13 de Oct. de 2022
Well, my network connection is super terrible, so I'm not going to be trying to download a bunch of stuff.
As given, the problem requires two (independently) colormapped objects in the same axes. That's not normally an option. There are possible ways around the issue:
- Merging all the colormaps into one long colormap and then trying to restrict the rendering of each object to a certain part of the composite colormap
- Converting one of the objects to an RGB image and then displaying it with image()/imagesc()/imshow(). Such an object is no longer colormapped, so that frees things up.
- Overlaying two axes objects atop each other, each with its own colormap.
Since you prefer the use something like surf() for handling the background image, I'm going to assume using image() or the like isn't an option. Tools like surf() and pcolor() can utilize full explicit XY data, whereas image() will always assume that XY coordinates are evenly spaced. If your XY data is evenly spaced, option 2 might be possible, though it would require changes to your existing work.
Following the third option, this might be one example.
% get an image with associated coordinates
imz = flipud(imread('cameraman.tif'));
[imx imy] = meshgrid(linspace(-200,200,256));
% get some placeholder dose map data
[X Y] = meshgrid(linspace(-100,100,100));
Z = exp(-(hypot(X,Y)/80).^2); % some Z data (a gaussian)
% get some placeholder boundary lines
boundaryxy = [3 -74;23 -22;86 -21;30 23;85 65;4 58;-9 101;
-35 44;11 37;-5 13;-84 21;-92 -32;-11 -17;-81 -59;3 -74];
% create two axes
hax1 = axes;
hax2 = axes;
% pcolor and surf have similar syntax and behavior
% draw the background image in the lower axes
hp1 = pcolor(hax1,imx,imy,imz);
hp1.LineStyle = 'none';
% and draw the overlay in the upper axes, set its alpha accordingly
hp2 = pcolor(hax2,X,Y,Z);
hp2.LineStyle = 'none';
hp2.FaceAlpha = 0.5;
% draw the boundary curves in the upper axes, atop the dose map
hold on;
plot(boundaryxy(:,1),boundaryxy(:,2),'g')
% set colormaps
colormap(hax1,gray(256));
colormap(hax2,jet(256));
% wrangle axes setup
linkaxes([hax1 hax2]);
axis(hax1,'equal','tight');
set(hax2,'visible','off','xtick',[],'ytick',[]) % hide top axes decorations
set(hax2,'position',hax1.Position,'xlim',hax1.XLim,'ylim',hax1.YLim, ...
'plotboxaspectratio',hax1.PlotBoxAspectRatio); % try to align both axes
Of course, trying to subsequently edit the axes positions or add things like legends or colorbars may provoke further alignment issues that will need to be resolved. In the thread linked above, there is some discussion of adding colorbars.
If it's desired to truncate the periphery of the dose map overlay, it should be possible to do that via the AlphaData property of hp2. You'd just need to generate a 2D map that describes which parts should be rendered.
Más respuestas (0)
Ver también
Categorías
Más información sobre Lighting, Transparency, and Shading en Help Center y File Exchange.
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!