Define a Region Using Boundary Points Read From a File

CLOUD, a FreeFem++ script which defines a region using boundary points read from a file.

In this particular example, the computation begins with a PNG image of a cloud, which consists of a white region surrounded by a black region, and nothing else. (This simplicity is important, in order for MATLAB to detect just one continuous boundary. If this is not the case, then you can still do this, but it takes some human intervention.)

A MATLAB function from the image toolbox is able to report a list of pixel locations corresponding to the black/white border. These pairs of coordinates can be written to a file, preceded by a single line listing the number of such coordinates. (In fact, we have to thin the data, and we have to reverse its order, and we have to make sure that the first point is repeated at the end so that FreeFem++ can tell that the border closes up.)

FreeFem++ can read the file, and can be instructed to regard the data as defining the border of a region. To show that this is true, we go ahead and mesh the region and solve some hokey PDE on it.


The computer code and data files described and made available on this web page are distributed under the GNU LGPL license.

You can go up one level to the FreeFem++ web page.

Last revised on 02 August 2015.