next up previous contents index
Next: Unstructured material or raw Up: Morphological image Previous: Related file (external) types   Contents   Index


Functions Summary

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

$ \bigcirc$Name


mw_change_mimage - Define a morphological image, if not already defined




$ \bigcirc$Summary


Mimage mw_change_mimage(mi)

Mimage mi;




$ \bigcirc$Description


This function returns a Mimage structure if the input mi = NULL. It is provided despite the
mw_new_mimage() function for global coherence with other memory types.

The function mw_change_mimage returns NULL if not enough memory is available to allocate the structure. Your code should check this return value to send an error message in the NULL case, and do appropriate statement.

Since the MegaWave2 compiler allocates structures for input and output objects (See Volume one: ``MegaWave2 User's Guide''), this function is normally used only for internal objects. Do not forget to deallocate the internal structures before the end of the module, except if they are part of an input or output chain.




$ \bigcirc$Example

/* Copy the morpho lines only of a morphological image into another morphological image */

Mimage in,out=NULL;

out=mw_change_mimage(out);
if (!out) mwerror(FATAL,1,"Not enough memory !\n");
out->nrow = in->nrow;
out->ncol = in->ncol;
out->minvalue=in->minvalue;
out->maxvalue=in->maxvalue;
if (in->firstml) 
  {
    out->firstml=mw_copy_morpho_line(in->firstml, out->firstml);
    if (!out->firstml) mwerror(FATAL, 1,"Not enough memory !\n");
  }

$ \bigcirc$Name


mw_copy_mimage - Copy a morphological image into another one




$ \bigcirc$Summary


Mimage mw_copy_mimage(in,out)

Mimage in, out;




$ \bigcirc$Description


This function copies the Mimage in into out. All fields are copied, including the chains of Morpho_sets, Morpho_line and Fmorpho_line. The result is put in out, which may not be a predefined structure : in case of out=NULL, the out structure is allocated.

The function mw_copy_mimage returns NULL if not enough memory is available to perform the copy, or out elsewhere. Your code should check this return value to send an error message in the NULL case, and do appropriate statement.




$ \bigcirc$Example

mimage in; /* Predefined mimage */
mimage out=NULL; 

out=mw_copy_mimage(in,out);
if (!out) mwerror(FATAL,1,"Not enough memory.\n");

$ \bigcirc$Name


mw_delete_mimage - Deallocate a morphological image




$ \bigcirc$Summary


void mw_delete_mimage(mi)

mimage mi;




$ \bigcirc$Description


This function deallocates the Mimage mi structure, including the chains of Morpho_sets, Morpho_line and Fmorpho_line. You should line mi = NULL after this call since the address pointed by mi is no longer valid.




$ \bigcirc$Example

Mimage mi; /* Internal use: no Input neither Output of module */

Morpho_line ml; 
Point_curve pt;
Fmorpho_line fml; 
Point_fcurve fpt;
Morpho_sets mss;
Hsegment seg;
Morpho_set ms;


/* Define a morpho line containing the point (0,0) only */

if (!(pt=mw_new_point_curve()) ||
    !(ml=mw_new_morpho_line())) mwerror(FATAL,1,"Not enough memory.\n");
pt->x=pt->y=0;
ml->first_point=pt;

/* Define a fmorpho line containing the point (0.5,0.5) only */

if (!(fpt=mw_new_point_fcurve()) ||
    !(fml=mw_new_fmorpho_line())) mwerror(FATAL,1,"Not enough memory.\n");
fpt->x=fpt->y=0.5;
fml->first_point=fpt;

/* Define a morpho sets containing one morpho set */

if (!(seg=mw_new_hsegment()) ||
    !(ms=mw_new_morpho_set()) ||
    !(mss=mw_new_morpho_sets())) mwerror(FATAL,1,"Not enough memory.\n");
seg->xstart=0; 
seg->xend=200;
seg->y=10;
ms->first_segment=seg; ms->minvalue=0.0; ms->maxvalue = 1.0; ms->area=201;
mss->morphoset=ms;

/* Define a morphological image made by one morpho line, one fmorpho line and
   one morpho sets.
*/

if (!(mi=mw_new_morpho_line())) mwerror(FATAL,1,"Not enough memory.\n");
mi->first_ml=ml;
mi->first_fml=fml;
mi->first_ms=ms;

/* .
   .
   (statement)
   .
   .
*/


/* Deallocate the mimage, including ml, fml and ms */
mw_delete_mimage(mi);

$ \bigcirc$Name


mw_length_fml_mimage - Return the number of morpho lines a morphological image contains




$ \bigcirc$Summary


unsigned int mw_length_fml_mimage(mi)

Mimage mi;




$ \bigcirc$Description


This function returns the number of fmorpho lines contained in the input mi. It returns 0 if the structure is empty or undefined.




$ \bigcirc$Example

See example page [*].

$ \bigcirc$Name


mw_length_ml_mimage - Return the number of morpho lines a morphological image contains




$ \bigcirc$Summary


unsigned int mw_length_ml_mimage(mi)

Mimage mi;




$ \bigcirc$Description


This function returns the number of morpho lines contained in the input mi. It returns 0 if the structure is empty or undefined.




$ \bigcirc$Example

Mimage mi; /* Internal use: no Input neither Output of module */

Morpho_line ml; 
Point_curve pt;
Fmorpho_line fml; 
Point_fcurve fpt;
Morpho_sets mss;
Hsegment seg;
Morpho_set ms;


/* Define a morpho line containing the point (0,0) only */

if (!(pt=mw_new_point_curve()) ||
    !(ml=mw_new_morpho_line())) mwerror(FATAL,1,"Not enough memory.\n");
pt->x=pt->y=0;
ml->first_point=pt;

/* Define a fmorpho line containing the point (0.5,0.5) only */

if (!(fpt=mw_new_point_fcurve()) ||
    !(fml=mw_new_fmorpho_line())) mwerror(FATAL,1,"Not enough memory.\n");
fpt->x=fpt->y=0.5;
fml->first_point=fpt;

/* Define a morpho sets containing one morpho set */

if (!(seg=mw_new_hsegment()) ||
    !(ms=mw_new_morpho_set()) ||
    !(mss=mw_new_morpho_sets())) mwerror(FATAL,1,"Not enough memory.\n");
seg->xstart=0; 
seg->xend=200;
seg->y=10;
ms->first_segment=seg; ms->minvalue=0.0; ms->maxvalue = 1.0; ms->area=201;
mss->morphoset=ms;

/* Define a morphological image made by one morpho line, one fmorpho line and
   one morpho sets.
*/

if (!(mi=mw_new_morpho_line())) mwerror(FATAL,1,"Not enough memory.\n");
mi->first_ml=ml;
mi->first_fml=fml;
mi->first_ms=ms;


/* This will print 1 */
printf("%d",mw_length_ml_mimage(mi));
/* This will print 1 */
printf("%d",mw_length_fml_mimage(mi));
/* This will print 1 */
printf("%d",mw_length_ms_mimage(mi));

$ \bigcirc$Name


mw_length_ms_mimage - Return the number of morpho sets a morphological image contains




$ \bigcirc$Summary


unsigned int mw_length_ms_mimage(mi)

Mimage mi;




$ \bigcirc$Description


This function returns the number of morpho sets contained in the input mi. It returns 0 if the structure is empty or undefined.




$ \bigcirc$Example

See example page [*].

$ \bigcirc$Name


mw_new_mimage - Create a new morphological image




$ \bigcirc$Summary


Mimage mw_new_mimage()




$ \bigcirc$Description


This function returns a new Mimage structure, or NULL if not enough memory is available to allocate the structure. Your code should check this return value to send an error message in the NULL case, and do appropriate statement.

The new structure is created with fields set to 0 or NULL.




$ \bigcirc$Example

/* Copy the morpho lines only of a morphological image into another morphological image */

Mimage in,out;

out=mw_new_mimage();
if (!out) mwerror(FATAL,1,"Not enough memory !\n");
out->nrow = in->nrow;
out->ncol = in->ncol;
out->minvalue=in->minvalue;
out->maxvalue=in->maxvalue;
if (in->firstml) 
  {
    out->firstml=mw_copy_morpho_line(in->firstml, out->firstml);
    if (!out->firstml) mwerror(FATAL, 1,"Not enough memory !\n");
  }


next up previous contents index
Next: Unstructured material or raw Up: Morphological image Previous: Related file (external) types   Contents   Index
mw 2004-05-05