I'd like to do a batch converison of 1400 .gif images into .off or .stl format files that'll be meshed images. Two sample .gif images are attached. How can I do this conversion possibly by a free software? I do have MATLAB 2017a installed, so a MATLAB code will be the best for my purpose. But if not, I'm open to anything else.

P.S. You can see more of the dataset at Shape Matching/Retrieval | dabi.temple.edu



  • 2
    $\begingroup$ What kind of algorithm are you thinking of for mesh conversion? Would it be an edge detection type algorithm, just putting one point for every pixel and connecting them together, a single textured plane, voxel meshing, or something else? $\endgroup$ – Scott Milner Nov 8 '17 at 1:27
  • 1
    $\begingroup$ Are these slices of the same object? So are you trying to in fact conver a voxel image to a mesh. $\endgroup$ – joojaa Nov 8 '17 at 7:39
  • $\begingroup$ @ScottMilner: thanks for your comment. I'm new to computer graphics and I need any simple algorithm that give me a meshed image representing the pictures like above. So, a meshed image of the apples (both the white boundary and interior, but not the black exterior) with specifically the vertices. The (geometric) framework I've will take the vertices of these meshes as a point cloud. I don't think it's a voxel meshing though-as voxels are for 3D, but my pictures are 2D images lying in the plane R². You can see more of the dataset at dabi.temple.edu/~shape/MPEG7/dataset.html $\endgroup$ – Mathmath Nov 8 '17 at 10:03
  • $\begingroup$ @joojaa: thanks for your comment. No, the images are slices of different objects. So it's not like I get these pictures when I take pictures of the same 3D apple from different angles. They're indeed 2D projection of possibly different apples. You can see more of the dataset at dabi.temple.edu/~shape/MPEG7/dataset.html $\endgroup$ – Mathmath Nov 8 '17 at 10:07
  • 1
    $\begingroup$ Something like this image? $\endgroup$ – joojaa Nov 8 '17 at 13:23

I think what you are looking for is called triangulated (2D) polygons.

I am not aware of any existing code which do so. Most likely you would need to code it yourself. Following are potential steps for it.

  1. Sample the boundary. This is pretty easy as you have binary images. Calculating and thresholding the gradient would do. After detecting the boundary you need to sample points in it with certain density.

  2. Next you need to triangulate the points sampled in step 1. Use something like constrained Delaunay triangulation would give you a nice looking triangulation.

  3. Now you got a 2D mesh defined in term if points and triangles. Writing the mesh in ASCII OFF format is not difficult: just iterate through points and triangles and write out the values according to the OFF format

| improve this answer | |
  • $\begingroup$ Yes, that's exactly what I'm looking for, triangulated 2D polygons. Thanks for the steps! $\endgroup$ – Mathmath Nov 13 '17 at 22:16

Short answer:

Theoretically you can, if you have an advanced degree in machine vision, but not directly.

Long answer:

You cannot, but there are web apps and matlab code which can give you a keen approximation of what you want (I dont know what goes on under the hood exactly but I think that they just generate false 3D data from your images, the matlab code generates false surfaces using clustering to generate 'iso' surfaces which I think are okay for 3D printers).

Why you cannot?

Any 3D model (.off, .stl) is a point cloud model, that is, it is a collection of 3D point data. It can be generated via many techniques, for eg. LiDAR scanning is one of them and even then you have to set up a machine to scan an area continuously (sometimes from many viewpoints /orientatons depending on your method and accuracy required) to obtain approximate 3D information. I'm trying to tell you just how difficult it is to acquire 3D data.

Now a gif image (like any other image file) only has 2D image data in form of pixel intensities. There are ways to get exact 3D point clouds from single images but this is itself an area which is still under research

The web apps I spoke of:



Matlab Code:




For JPEG to GIF conversion (as an intermediate step), I dont know if you're on linux or Windows, but in linux you can use imagemagik to simply batch convert as:

convert  *.gif *.jpeg


convert *.gif *.jpg

For windows:


If you read in the reference below you can write an m file with the given library to do all the intermediate conversions within matlab itself.



| improve this answer | |

Not the answer you're looking for? Browse other questions tagged or ask your own question.