How to display a 2D square as a 3D cube

How can i display the attached 2D square input as a 3D cube from?
I used the same image in all slice. But the display is not clear.
Please can someone help me with displaying

 Accepted Answer

Use volshow function :
thisSlice = dicomread('IMG-0004-00079.dcm');
thisSlice = double(thisSlice);
thisSlice = (thisSlice-min(thisSlice(:)))/(max(thisSlice(:))-min(thisSlice(:)));
thisSlice = uint8(255*thisSlice);
volSlice = repmat(thisSlice,[1,1,100]);
queryPoints = 0:255;
alpha = [0 0.01 0.02 .05 0.9];
intensity = linspace(0,255,5);
alphamap = interp1(intensity,alpha,queryPoints)';
volshow(volSlice,'Alphamap',alphamap)
change Alphamap and Colormap option of volshow to have better representation for your application. there is a simple example in documentation of dicomreadvolume in MATLAB documentation.
the image in final step :
3D volumetric plot :

4 Comments

Sir, thank you for the answer.
One more doubt from the output image how can i measure the height, width and length of the cube?
about the height. it will show your stacked data. for example here i stack 100 image together.so for that you should have information about sample distance between each slice of your real example.
for width and length it is possible to measure them in pixel from image. you can use imdistline or select corner pixels (or with corner detection automatically detect them) and compute distance of them. but all this results would be in pixel unit. you should have minimum information about sensors and experiment setup to translate this distances to metric units.
Sir, is it possible to view the 3D image as the same texture of 2D image (that is as the image you have displayed under the image in final step)
Is it possible to do so?
as i said earlier, you can change alphamap and colormap to see what is best illustration for your work.
for example if you don't use any option even dark pixels have intensity in volumentric figure:
volshow(volSlice)
but for example a little more precise number would be this: (i see that most pixel in box have intensity grater than 130 in 8bit image so i did this:)
queryPoints = 0:255;
alpha = [0 0.01 0.02 .6 1 1];
intensity = [0 50 100 130 200 255];
alphamap = interp1(intensity,alpha,queryPoints)';
volshow(volSlice,'Alphamap',alphamap)

Sign in to comment.

More Answers (0)

Tags

Community Treasure Hunt

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

Start Hunting!