how to get only the edges and make transparent the face on a superimposed cube

2 views (last 30 days)
Hello,
I have created a cube and superimposed to a dicom image. What I need to do now is to make transparent the faces of the cube, thus, only the edges of the cube are seen. The way that I create the cube and superimposed to the dicom image is:
[M,N,L] = size (imag);
cube = zeros(info_imag.Width, info_imag.Height, L);
cube(location(1,1)-10:(location(1,1)+9, (location(2,1)-10:(location(2,1)+9, (location(3,1)-10:(location(3,1)+9) = 0.3;
I = (int16(1000*cube))+imag;
Could someone suggest an idea on how to do that?
  2 Comments
Sreeja Banerjee
Sreeja Banerjee on 12 Jun 2015
Hi Isabel, Since we do not have access to your data and you have not explained the variables that you have used in your code, it is difficult to give you any specific suggestion. In the code I could not find how you are displaying the cube.
However, if your question is specifically on how you can make the faces of the cube transparent then have you considered using the function ALPHA ( documentation )
If you are using a surface or patch to draw the faces of the cube, then you can modify the 'FaceAlpha' property to make it transparent. ( documentation )
Isabel
Isabel on 15 Jun 2015
Edited: Isabel on 15 Jun 2015
Hi Sreeja,
I'll try to explain better myself. I have added an example of my data to dropbox so you can download https://www.dropbox.com/sh/h6zgec40ctsevog/AAAz7YaQ1uwlZwVCwPsDhCp3a?dl=0 . Once you read it, I called the variable "imag" to the volumetric data (512x512x511). After load the data, I applied the code that I wrote in my first entry. For visualization I use this viewer, by using SliceBrowser(I) http://www.mathworks.com/matlabcentral/fileexchange/20604-3d-slice-viewer, however you can use any other viewer.
As location you can use for example:
location = [190; 370; 210];
Then the cube will appear in the axial view between slice 180 and 199 (you can also see it in the other views, saggital and coronal, at the given location). So far I'm controlling the transparency with the third line of code from my first entry, thus, if I do = 0 the cube will be totally transparent and if I do =1 will be totally opaque.
The issue is that if I don't do totally transparent, the user can't see what is under the cube. However, when the cube is totally transparent, the edges of the cube are also, and then the user can't see anymore where the cube is located. So, what I want to do is to have the faces of the cube totally transparent but the edges are still visible.
I hope now it's more clear and you can help me.
Thank you in advance

Sign in to comment.

Accepted Answer

Isabel
Isabel on 16 Jun 2015
Ok, finally I solved my problem by applying shapeInserter in each slice. I leave here the code, in case it can be useful for someone else.
shapeInserter = vision.ShapeInserter;
rectangle = int32([location(i,2) location(i,1) 20 20]);
for r=1:size(imag,3)
if r==location(i,3)
for i=(location(i,3)-10):(location(i,3)+9)
I = (imag (:,:,i));
J(:,:,i)=step(shapeInserter, I, rectangle);
end
else
J(:,:,r)= imag (:,:,r);
end
end
Thank you Sreeja and Walter for your comments.

More Answers (1)

Walter Roberson
Walter Roberson on 15 Jun 2015
You indicate that you SliceBrowser(test) but you have not defined test in what you show, only cube.
SliceBrowser() is using imagesc() to do the work of drawing the slices. SliceBrowser does not manipulate transparency at all. If I read the source correctly the only edges it draws explicitly are crosshairs. I see no reason to say that assigning 0 or 1 affects transparency when using SliceBrowser: it just controls the data value that are put through colormap processing.
If you want to continue using SliceBrowser then you will need to set a thin shell of pixels around the outside of the area you want pointed out.
But really if you want to talk about faces and edges and transparency you should be using some other display mechanism such as patch() or surface().
  1 Comment
Isabel
Isabel on 15 Jun 2015
Edited: Isabel on 15 Jun 2015
Hi Walter,
Sorry, when I wrote "test" I wanted to say "I" from the code that I posted here. I will edit that for avoid confusions.
I just use SliceBrowser as viewer, however the cube is added to the volumetric image before hand (I=(int16(1000*cube))+imag;). I mean, I don't pretend that SliceBrowser modify the transparency of the cube. What I would like is that when I add the cube to the volumetric image, this cube already has the faces transparent and only the edges are visible.
I managed to do what I preted in 2D but I don't know how to extrapolate that to 3D. I add here the example in 2D, hopefully it helps to make clear what I pretend.
shapeInserter = vision.ShapeInserter;
I = (imag (:,:,210));
rectangle = int32([370 190 20 20]);
J = step(shapeInserter, I, rectangle);
imshow(J);
Thank you

Sign in to comment.

Community Treasure Hunt

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

Start Hunting!