Code covered by the BSD License  

Highlights from
Polygon2Voxel

5.0

5.0 | 6 ratings Rate this file 32 Downloads (last 30 days) File Size: 15.06 KB File ID: #24086
image thumbnail

Polygon2Voxel

by Dirk-Jan Kroon

 

12 May 2009 (Updated 19 Dec 2011)

Convert a triangulated mesh into a voxel volume

| Watch this File

File Information
Description

This function polygon2function will convert a Triangulated Mesh into a Voxel Volume which will contain the discretized mesh.

Discretization of a polygon is done by splitting the polygon in smaller polygons, until the longest edge is smaller than 0.5 voxel, then the voxel beneath the vertice coordinates is set to one.

The function is fast because the main function is implemented in c-code /mex file (takes seconds on a core 2 duo with function compiled by Microsoft Visual Studio 2008.).

Try the example.

Bugs, successes and other comments are welcome!

MATLAB release MATLAB 7.8 (R2009a)
Tags for This File  
Everyone's Tags
Tags I've Applied
Add New Tags Please login to tag files.
Comments and Ratings (13)
13 Aug 2009 Siyi Deng

very helpful. Good job.

18 Aug 2009 Óscar J. Rubio Martín

Incredible performance! Very good

06 May 2010 Siyi Deng

THis is indeed fantastic, however I would suggest to change the output Volume from datatype double to uint8 in c file and eventually to logical in m file; this will save lots of memory and make it faster, especially when volumeSize is large;

27 May 2010 Dirk-Jan Kroon

*Siyi Deng
I have updated the code today with an new version which outputs a logical volume.

12 Nov 2010 Yuanming Suo

Great tool. Just solve my need. Well documented.

09 Feb 2011 Rigo Trosendo

Great Job, Exactly what I needed. Is you algorithm based on any publication(s)?
Thanks

10 Feb 2011 Dirk-Jan Kroon

*Rigo Trosendo
Thanks you for your comment. The code is basic, thus not based on any publications.

25 Mar 2011 wall

GREAT

15 Aug 2011 leo

please check some kind of limitation.

I test a FV data,the data is from real CT images,so the range of object's x,y,z coordinate is about: 140:230 ,90:170, 725:820 , but in your code, I can not set the real range,only use [100 100 100], after test 'none','auto','center'.
only in 'auto', I can see the medical structure in the top left corner, but the structure is scaled down and original details can not be restored.

19 Dec 2011 Dirk-Jan Kroon

*leo,
Only integer volume sizes are supported

13 Mar 2012 Stefan Roth

Great job thanks!

On Mac OS compyling the mex file leads to undefined symbol errors.

Adding the macros helps:

#define min(X,Y) ((X) < (Y) ? (X) : (Y))
#define max(X,Y) ((X) > (Y) ? (X) : (Y))

28 Apr 2012 Vincent Jaouen

As Stefan Roth pointed out, there is a problem on UNIX platforms. I had the same problem when trying to compile under ubuntu 11.10. Adding the macros indeed helps.

16 May 2012 Vincent Jaouen  
Please login to add a comment or rating.
Updates
25 May 2009

Added center and resize options

01 Oct 2009

Linux Ubuntu Tested

12 Feb 2010

Small Bug fixed, for the case if all vertices are outside the volume. Only not draw the face if they are outside at the same side of the volume.

27 May 2010

Changed output to Logicals instead of Double datatype

12 Nov 2010

Now first index volume is 1,1,1 instead of 0,0,0, and YXZ dimensions as in Matlab convention (Thanks Yuanming SUO).

19 Dec 2011

Added boundary options

Tag Activity for this File
Tag Applied By Date/Time
discretization Dirk-Jan Kroon 12 May 2009 09:47:31
mesh Dirk-Jan Kroon 12 May 2009 09:47:31
polygons Dirk-Jan Kroon 12 May 2009 09:47:31
triangulated Dirk-Jan Kroon 12 May 2009 09:47:31
triangles Dirk-Jan Kroon 12 May 2009 09:47:31
voxels Dirk-Jan Kroon 12 May 2009 09:47:31
voxel volume Dirk-Jan Kroon 12 May 2009 09:47:31
voxel Dirk-Jan Kroon 12 May 2009 09:47:31
mesh Bhavik 05 Mar 2010 12:23:25
polygons Bhavik 05 Mar 2010 12:23:29
patch Dirk-Jan Kroon 04 Nov 2010 05:57:08
voxel volume Rigo Trosendo 10 Feb 2011 00:15:14

Contact us at files@mathworks.com