Discussion:
redering a 3d image from an intensity stack
(too old to reply)
AntLee29
2006-10-18 08:40:08 UTC
Permalink
I have raw integer data that is stored in a 3-d array of size 256x256x100.  It's very easy to get LabVIEW to display each 2-d image one at a time on an intensity graph, however I would like to generate a solid 3d model using this data.  Is there a way for LabVIEW to display a rotatable 3d model from this stack?
 
Thanks,
Anthony
unclebump
2006-10-19 14:10:11 UTC
Permalink
Is this what you want??
<a href="http://zone.ni.com/devzone/cda/epd/p/id/468" target="_blank">http://zone.ni.com/devzone/cda/epd/p/id/468</a>
Ben
2006-10-19 20:10:08 UTC
Permalink
Anthony,
Could you please post a VI with the 3-d data saved as default along with an image to remind me what those looked like?
We may be better able to help with a little more info.
Trying to help,
Ben
I'm thinking we can do this with cliping or transparency.Message Edited by Ben on 10-19-2006 02:49 PM
AntLee29
2006-10-19 21:10:09 UTC
Permalink
The 3d stack is stored in the "Mouse Tendon Data" array.&nbsp; As of right now, the vi will simply scroll through each layer of the 3d stack and display the 2d results.&nbsp; See the&nbsp;attached vi.&nbsp; Thanks for the help everyone. :)
&nbsp;
Thanks,
Anthony
&nbsp;
&nbsp;
P.S.
I already know about the high intensity noise in a few of the images and also the triangular distortions in the top right and bottom left of each image.&nbsp; Just ignore that. :P


3d stack.vi:
http://forums.ni.com/attachments/ni/170/211229/1/3d stack.vi
Ben
2006-10-20 01:40:08 UTC
Permalink
I don't know if this helps but I did have fun looking at the data. :smileyvery-happy:
The images below illustrate the results of running your data through the code shown.
Warning!
You do NOT&nbsp;want to watch the FP as the plot is built... so... minimize the FP before running this VI.
With the FP open it took about 38 minutes on a 2GHz laptop with 1G memory.
With the FP closed, the code runs in about a minute!
Zooming, dragging&nbsp;and rotating also takes about a minute.
A top of the line multi-core processor would probably fair better.
<img src="Loading Image...">
<img src="Loading Image...">
<img src="Loading Image...">
<img src="Loading Image...">
<img src="Loading Image...">
<img src="Loading Image...">
&nbsp;
<img src="Loading Image...">
Ben
Message Edited by Ben on 10-19-2006 08:26 PMMessage Edited by Ben on 10-19-2006 08:27 PM
Ben
2006-10-20 16:40:09 UTC
Permalink
Now that I see these images in the light of day...
&nbsp;
I have to say that they looked much better on my laptop in the dark.
&nbsp;
If I get a chance I may toss in a custom color scale to bring out the features.
&nbsp;
Ben
AntLee29
2006-10-20 17:40:07 UTC
Permalink
Very nice Ben!&nbsp; I managed to recreate this vi, but I still have a few questions.&nbsp; You're using a lot of unfamiliar functions so I'm not sure exactly how to go about making changes.
&nbsp;
1. How do I rotate the image?
2. How do I zoom in/out and export the image nicely in the way you have on the forum post.
3. How do I adjust the intensity scale and corresponding color map?
&nbsp;
Thanks a bunch,
Anthony
Ben
2006-10-20 19:40:14 UTC
Permalink
Thanks Anthony,
I am glad this may help.
&nbsp;
1. How do I rotate the image?
&nbsp;
Using the operate tool (little hand with pointing finger) to drag left-right or up-down on the 3d plot.
&nbsp;
2. How do I zoom in/out and export the image nicely in the way you have on the forum post.
&nbsp;
Still using the operate tool do a "shift-right-click" to drag image in graph. "Alt-right-click" to zoom in or out.

What I posted where just screen shots cropped down in paint and saved as jpg.
See reply #7 of this thread to learn how to import activeX object into PowerPoint
&nbsp;
<a href="http://forums.ni.com/ni/board/message?board.id=170&amp;message.id=117389&amp;jump=true" target="_blank">http://forums.ni.com/ni/board/message?board.id=170&amp;message.id=117389&amp;jump=true</a>
&nbsp;
3. How do I adjust the intensity scale and corresponding color map?
&nbsp;
Starting with reply #7 of this thread
<a href="http://forums.ni.com/ni/board/message?board.id=170&amp;message.id=143663&amp;jump=true" target="_blank">http://forums.ni.com/ni/board/message?board.id=170&amp;message.id=143663&amp;jump=true</a>
to see an example that uses custom color mapping.
What I posted where just screen shots cropped down in paint and saved as jpg.
I hope this helps!
&nbsp;
Ben
Roberto83
2007-11-02 05:40:06 UTC
Permalink
I have a large data set (647[x ] x 266[y ] x 300[z ]) that I want to plot in 3D. I have tried to build a 3D array but so far I haven?t been able to do so. I am using two for loops and one while loop)

&nbsp;

I have used in the past intensity plots and the data looks very good, but this time I have many intensity plots that I want to visualize. I want all my frames to be displayed at the same time and in this way reconstruct a solid.

&nbsp;

I found in the NI forum this link posted by Antony (AntLee29); I think he is working in a project that is very similar to mine. I built the vi suggested by Ben. Unfortunately, I have not been able to make this vi work; the last invoke node appears to have an error.

The error message is: ?One or more required inputs to this function are not wired or are wired incorrectly?

I checked the help file for this item and it says that the following parameters are needed:

&nbsp;

xMatrix As <a href="mk:@MSITStore:C:\Program%20Files\National%20Instruments\MeasurementStudio\Help\cw3dgrph.chm::/html/DataTypes.htm" target="_blank"> Variant</a>

2D array of X data

yMatrix As <a href="mk:@MSITStore:C:\Program%20Files\National%20Instruments\MeasurementStudio\Help\cw3dgrph.chm::/html/DataTypes.htm" target="_blank"> Variant</a>

2D array of Y data

zMatrix As <a href="mk:@MSITStore:C:\Program%20Files\National%20Instruments\MeasurementStudio\Help\cw3dgrph.chm::/html/DataTypes.htm" target="_blank"> Variant</a>

2D array of Z data

wMatrix As <a href="mk:@MSITStore:C:\Program%20Files\National%20Instruments\MeasurementStudio\Help\cw3dgrph.chm::/html/DataTypes.htm" target="_blank"> Variant</a>

&nbsp;

I have a variant type as the input into these matrices but the error is not cleared. Can anyone give me some assistance on this issue?

Thanks in advance,

Roberto

&nbsp;
Ben
2007-11-02 12:40:09 UTC
Permalink
Hi Roberto,
Please post your code along with the data you are trying to plot.
We could go back and forth for days if we stick just talking.
But if you post your code (and data) we should be able to get you moving.
Thanks,
Ben
Roberto83
2007-11-02 15:40:11 UTC
Permalink
The 3D parametric surface plot vi contains the code suggested by you Ben. I have not been able to construct the 3D array so I am reading (or trying to I should say) the data available from Anthony (Mouse data, 256 x 256 x 100 array). I posted this figure because even the compressed file of the vi is 7MB so it is more than the mail system allows me to post

I am also including in the 5 frames and mouse data vi some data that I got from five different frames. Each frame is a 266 x 647 array, I am only showing 5 frames but I can have up to 300 frames in order to reconstruct the solid.

&nbsp;

Thanks,

Roberto

&nbsp;

&nbsp;

&nbsp;

3D parametric surface plot vi

&nbsp;

&nbsp;


3D parametric surface plot vi.jpg:
http://forums.ni.com/attachments/ni/170/282054/1/3D parametric surface plot vi.jpg


5 Frames and Mouse data.zip:
http://forums.ni.com/attachments/ni/170/282054/2/5 Frames and Mouse data.zip
Ben
2007-11-05 22:10:41 UTC
Permalink
By replacing all meassurements below 16 with NaN and adjusting the color scale you get this.
<img src="Loading Image...">
<img src="Loading Image...">
BenMessage Edited by Ben on 11-04-2007 02:17 PMMessage Edited by Ben on 11-04-2007 02:18 PM


NaN_for_0_16.PNG:
http://forums.ni.com/attachments/ni/170/282238/1/NaN_for_0_16.PNG


NaN_for_0_16_2.PNG:
http://forums.ni.com/attachments/ni/170/282238/2/NaN_for_0_16_2.PNG
Ben
2007-11-05 22:10:44 UTC
Permalink
Thanks CC but I was just playing with the NaN" trick I learned after I answered the original Q of this thread.
Although I won't have time for this (for another year or so) What I wanted to do was write something that bins the measurelemtns and compose plots of denisity regions.
I just couldn't firure out real fast how to automatically adapt the bins to teh data.
That way regions of high denisty culd be ploted wih low transparency adn vise versa.
The idea would be tht that the less dense stuf would be easier to see through.
Well maybe next year at this time. <img src="Loading Image...">
Ben
&nbsp;
chilly charly
2007-11-05 22:10:42 UTC
Permalink
Ben,
You are undoubtedly the 3D graph master (proved more than once !!!) <img src="Loading Image...">.
How should I react when you call me graph Master ? <img src="Loading Image...">&nbsp; I feel depressed when looking at your demonstration ! ;)
Chapeau l'Artiste !
Roberto83
2007-11-05 22:10:49 UTC
Permalink
Thank you very much for your assistance Ben,
&nbsp;
This is what I wanted to visualize the data in&nbsp;a 3D graph.
With regard to the 3D array. I kept trying and finally was able to build a 3d array programatically. Now I can run different cases and have a 266x647 by n, n is the number of frames I need to construct the solid. The down side of it is that I can only have 78 frames, at that point my computer runs out of memeory.
for now I will keep on trying to make labView run until I get the 300 frames I need. I will post my code later if I have more questions.
&nbsp;
Thank again for your help.
Roberto
&nbsp;
Ben
2007-11-05 22:11:10 UTC
Permalink
Again, without your code and dat its hard to comment.
1) Make sure you only save the VI with no plts showing in the graph (CC taught me this years ago).
2) Excluding plotted points by substituting "NaN" for the most frequently occuring values also reduces memory demands.
3) If you read each "slice" from a sperate file (or take othe action to reduce the total amount of memeory required) and then close the file before opening the file for the next slice, this will also reduce memory req's.
Could you post a screen-shot of what 78 frames looks like?
and
Are you allowed to tell us what we are seeing?
Again, thank you for the data Roberto!
Ben
Roberto83
2007-11-06 15:10:33 UTC
Permalink
Here are the vi's. I am only allowed to attach 3 files per message.
Roberto


3d stack_as_82_w_5_frames.zip:
http://forums.ni.com/attachments/ni/170/282543/1/3d stack_as_82_w_5_frames.zip


IMAGE Proc and 3D array.vi:
http://forums.ni.com/attachments/ni/170/282543/2/IMAGE Proc and 3D array.vi
Roberto83
2007-11-06 15:10:35 UTC
Permalink
This is my latest update to the Image processing vi Ben,
I added a dispose image icon. I used the dispose all images option (TRUE) yet&nbsp;I am only able to process 99 images&nbsp;The memory of my computer is 1GB and the size of each&nbsp;image is 1MB.
I think I should be able to process more images than that, unless I am doing something wrong that I am not taking into account.
Roberto


IMAGE Proc and 3D array.vi:
http://forums.ni.com/attachments/ni/170/282549/1/IMAGE Proc and 3D array.vi
Ben
2007-11-06 15:10:58 UTC
Permalink
Hi Roberto,
Thank you very much for the images and the explanation of what we are seeing.
<img src="Loading Image...">
<img src="Loading Image...">
Thoughts;
1) In the code I posted there is a case structure used to replace the "0" values with NaN. Try modifying the case so it replace "0..16" or there-abouts. This will reduce the number of points plotted and will also help to "clear the fog" since your bubble region has higher values.
2) You may want to filter and down sample your data. Since you are not looking for single point info but rather regions you may be able to clean-up the graininess while also reduce the size of teh data set being plotted.
Again, thank you for the images.
I (and many others here ) are engineers and scientists and there is nothing like new and unique views of the world to keep us entertained.
Thank you!
Ben

Roberto83
2007-11-06 15:10:32 UTC
Permalink
Hello Ben,

&nbsp;

Thank you for your suggestions for my code.

&nbsp;

Here is the vi I use to process the image and create the 3D array. I included 5 images, so you can see how it works. I was able to process 107 frames. I also included a shot of the frames processed (107 this time) that you asked me.

&nbsp;

I am not a programmer; however, I have found LabView very useful in my research, so please forgive me if my style is not very efficient. &nbsp;

&nbsp;

Yes, I am allowed to tell you what I?m seeing. I am doing experiments in a pipe. The camera is located almost parallel to the pipe (inclined 10 degrees), viewing the cross section of the pipe. In the pipe there is water and different amounts of air (10 % approx by volume). The last frame shows 2 ellipses. The large one shows the contour of the pipe. The small ellipse shows a dark region, that is air, (an elongated bubble). In these experiments I am trying to visualize the shape of the some of the deformed bubbles in 3D by putting all the frames together.&nbsp; In fact in previous messages I mentioned I was trying to construct a solid, it is actually not a solid but a bubble (gas).

&nbsp;

The image 107 frames 2nd.jpeg shows a red ellipse in the region where the bubble is located. It is hard to see the bubble. I have modified the vi you suggested (<a href="http://forums.ni.com/attachments/ni/170/282237/3/3d%20stack_as_82_w_5_frames.vi" target="_blank"> 3d stack_as_82_w_5_frames.vi</a>) on Nov 4th but so far I have not been able to have two transparency values, one for the liquid region and one for the bubble. I am trying to have the entire liquid region with a transparency of 95% and the bubble region with a transparency value of 25%. In this way the bubble can be better visualized. You mentioned something about this in your message of Nov 4th.

Could you please give me some ideas about this?

&nbsp;

If you have any questions about my codes or the images just let me know. Thanks again,

&nbsp;

Roberto


f_000820.zip:
http://forums.ni.com/attachments/ni/170/282541/1/f_000820.zip


107 Frames.jpg:
http://forums.ni.com/attachments/ni/170/282541/2/107 Frames.jpg


107 Frames 2nd.jpg:
http://forums.ni.com/attachments/ni/170/282541/3/107 Frames 2nd.jpg
Ben
2007-11-05 22:10:41 UTC
Permalink
The attached is a mod of your attempt to build the array.
<img src="Loading Image...">
I just used a "build array" to create the 3d array we needed to represent multiple slices.
I also used it to duplicate you slices to test this out.
I also added a custom color scale.
This example requirese a lot of memory and a lot of CPU. Try running it with the front panel minimized to spedd it up a bit.
Post your code with any folow-up questions.
BenMessage Edited by Ben on 11-04-2007 01:24 PMMessage Edited by Ben on 11-04-2007 01:25 PM


Convert_LV_Color_to_CW.vi:
http://forums.ni.com/attachments/ni/170/282237/1/Convert_LV_Color_to_CW.vi


5 Frames and Mouse data.vi:
http://forums.ni.com/attachments/ni/170/282237/2/5 Frames and Mouse data.vi


3d stack_as_82_w_5_frames.vi:
http://forums.ni.com/attachments/ni/170/282237/3/3d stack_as_82_w_5_frames.vi


3d_solid_From_Stack.PNG:
http://forums.ni.com/attachments/ni/170/282237/4/3d_solid_From_Stack.PNG
Loading...