next up previous contents index
Next: Point with a type Up: Shapes Previous: Related file (external) types   Contents   Index


Functions Summary

The following is a description of all the functions related to the Shapes type. The list is in alphabetical order.

$ \bigcirc$Name


mw_alloc_shapes - Allocate the fields of a Shapes structure




$ \bigcirc$Summary


Shapes mw_alloc_shapes(shs, nrow, ncol, value)

Shapes shs;

int nrow, ncol;

float value; /* gray level value of the root */




$ \bigcirc$Description


This function takes as argument a Shapes structure and returns it after having allocated all necessary fields. The input nrow and ncol are the dimensions of the image. The field the_shapes is allocated to contain nrow×ncol+1 shapes, which is the maximal number of shapes extracted by the FLST (see module flst). In fact, only one shape is put, the root of the tree, supposed to be extracted at gray level value. The field smallest_shape is also allocated and initialized, each pixel having as smallest shape the root.

The function returns shs, or NULL if not enough memory is available to do the allocation.




$ \bigcirc$Example

Shapes shs;
Fimage image; /* Assume image is allocated */

/*
  Define the structure
*/
shs = mw_new_shapes();
if (!shs) mwerror(FATAL,1,"Not enough memory to define the shapes !\n");

/* 
  At that time, the structure exists but fields are empty : alloc them
  to handle the Fimage image.
*/
if (!mw_alloc_shapes(shs, image->nrow, image->ncol, image->gray[0]))
  mwerror(FATAL,1,"Not enough memory to alloc the shapes !\n");

$ \bigcirc$Name


mw_change_shapes - (Re)alloc the fields of a Shapes structure




$ \bigcirc$Summary


Shapes mw_change_shapes(shs, nrow, ncol, value)

Shapes shs;

int nrow, ncol;

float value; /* gray level value of the root */




$ \bigcirc$Description


If the input pointer shs is NULL, create a new structure, otherwise delete the currently allocated fields (if any) and call mw_alloc_shapes().

The function returns the new structure or shs, or NULL if not enough memory is available to do the allocation.




$ \bigcirc$Example

Shapes shs=NULL;
Fimage image; /* Assume image is allocated */

/*
  Define the structure and alloc the field to handle the Fimage image.
*/
shs = mw_change_shapes(shs, image->nrow, image->ncol, image->gray[0]);
if (!shs) mwerror(FATAL,1,"Not enough memory to alloc the shapes !\n");

$ \bigcirc$Name


mw_delete_shapes - Delete a Shapes structure




$ \bigcirc$Summary


void mw_delete_shapes(shs)

Shapes shs;




$ \bigcirc$Description


This function frees the allocated fields and the structure itself. After this call, the memory pointed to by shs must not be accessed any longer. Warning : in the contrary to mw_delete_shape(), the memory of the user-defined field data is not freed. If this field has been allocated, you should free it before calling mw_delete_shapes().




$ \bigcirc$Example

Shapes shs=NULL;
Fimage image; /* Assume image is allocated */

/*
  Define the structure and alloc the field to handle the Fimage image.
*/
shs = mw_change_shapes(shs, image->nrow, image->ncol, image->gray[0]);
if (!shs) mwerror(FATAL,1,"Not enough memory to alloc the shapes !\n");

/*
  ... (do the computation) ...
*/

/* 
  Delete the shapes
*/
if (!shs->data) free(shs->data);
mw_delete_shapes(shs);

$ \bigcirc$Name


mw_new_shapes - Create a Shapes structure




$ \bigcirc$Summary


Shapes mw_new_shapes()




$ \bigcirc$Description


This function creates a new Shapes structure. The fields are initialized to 0 or NULLvalue. The function returns the address of the new structure, or NULL if not enough memory is available.




$ \bigcirc$Example

Shapes shs;

/*
  Define the structure
*/
shs = mw_new_shapes();
if (!shs) mwerror(FATAL,1,"Not enough memory to define the shapes !\n");

/* 
  At that time, the structure exists but is empty.
*/


next up previous contents index
Next: Point with a type Up: Shapes Previous: Related file (external) types   Contents   Index
mw 2004-05-05