GRASS GIS 8 Programmer's Manual  8.4.0dev(2024)-535c39c9fc
sigset.c File Reference
#include <string.h>
#include <stdlib.h>
#include <grass/gis.h>
#include <grass/glocale.h>
#include <grass/imagery.h>
Include dependency graph for sigset.c:

Go to the source code of this file.

Macros

#define eq(a, b)   strcmp(a, b) == 0
 

Functions

int I_SigSetNClasses (struct SigSet *S)
 
struct ClassDataI_AllocClassData (struct SigSet *S, struct ClassSig *C, int npixels)
 
int I_InitSigSet (struct SigSet *S, int nbands)
 Initialize struct SigSet before use. More...
 
struct ClassSigI_NewClassSig (struct SigSet *S)
 
struct SubSigI_NewSubSig (struct SigSet *S, struct ClassSig *C)
 
int I_ReadSigSet (FILE *fd, struct SigSet *S)
 Read sigset signatures from file. More...
 
int I_SetSigTitle (struct SigSet *S, const char *title)
 
const char * I_GetSigTitle (const struct SigSet *S)
 
int I_SetClassTitle (struct ClassSig *C, const char *title)
 
const char * I_GetClassTitle (const struct ClassSig *C)
 
int I_WriteSigSet (FILE *fd, const struct SigSet *S)
 
char ** I_SortSigSetBySemanticLabel (struct SigSet *S, const struct Ref *R)
 Reorder struct SigSet to match imagery group member order. More...
 

Macro Definition Documentation

◆ eq

#define eq (   a,
  b 
)    strcmp(a, b) == 0

Definition at line 124 of file sigset.c.

Function Documentation

◆ I_AllocClassData()

struct ClassData* I_AllocClassData ( struct SigSet S,
struct ClassSig C,
int  npixels 
)

Definition at line 43 of file sigset.c.

◆ I_GetClassTitle()

const char* I_GetClassTitle ( const struct ClassSig C)

Definition at line 386 of file sigset.c.

References ClassSig::title.

Referenced by I_WriteSigSet().

◆ I_GetSigTitle()

const char* I_GetSigTitle ( const struct SigSet S)

Definition at line 367 of file sigset.c.

References SigSet::title.

Referenced by I_WriteSigSet().

◆ I_InitSigSet()

int I_InitSigSet ( struct SigSet S,
int  nbands 
)

Initialize struct SigSet before use.

No need to call before calling I_ReadSigSet.

Parameters
*Signatureto initialize
nbandsband (imagery group member) count

Definition at line 64 of file sigset.c.

References SigSet::ClassSig, G_malloc, SigSet::nbands, SigSet::nclasses, NULL, SigSet::semantic_labels, and SigSet::title.

Referenced by I_ReadSigSet().

◆ I_NewClassSig()

◆ I_NewSubSig()

struct SubSig* I_NewSubSig ( struct SigSet S,
struct ClassSig C 
)

◆ I_ReadSigSet()

int I_ReadSigSet ( FILE *  fd,
struct SigSet S 
)

Read sigset signatures from file.

File stream should be opened in advance by call to I_fopen_sigset_file_old() It is up to caller to fclose the file stream afterwards.

There is no need to initialise struct SigSet in advance, as this function internally calls I_InitSigSet.

Parameters
pointerto FILE*
pointerto struct SigSet *S
Returns
1 on success, -1 on failure

Definition at line 141 of file sigset.c.

References _, G_warning(), and I_InitSigSet().

◆ I_SetClassTitle()

int I_SetClassTitle ( struct ClassSig C,
const char *  title 
)

Definition at line 375 of file sigset.c.

References free(), G_store(), NULL, and ClassSig::title.

◆ I_SetSigTitle()

int I_SetSigTitle ( struct SigSet S,
const char *  title 
)

Definition at line 356 of file sigset.c.

References free(), G_store(), NULL, and SigSet::title.

◆ I_SigSetNClasses()

int I_SigSetNClasses ( struct SigSet S)

Definition at line 32 of file sigset.c.

References SigSet::ClassSig, count, SigSet::nclasses, and ClassSig::used.

◆ I_SortSigSetBySemanticLabel()

char** I_SortSigSetBySemanticLabel ( struct SigSet S,
const struct Ref R 
)

Reorder struct SigSet to match imagery group member order.

The function will check for semantic label match between sigset struct and imagery group.

In the case of a complete semantic label match, values of passed in struct SigSet are reordered to match the order of imagery group items. This reordering is done only for items present in the sigset file. Thus reordering should be done only after calling I_ReadSigSet.

If all semantic labels are not identical (in arbitrary order), function will return two dimensional array with comma separated list of:

  • [0] semantic labels present in the signature struct but absent in the imagery group
  • [1] semantic labels present in the imagery group but absent in the signature struct

If no mismatch of semantic labels for signatures or imagery group are detected (== all are present in the other list), a NULL value will be returned in the particular list of mismatches (not an empty string). For example:

if (ret && ret[1]) printf("List of imagery group bands without
signatures: %s\n, ret[1]);
Parameters
*SigSetexisting signatures to check & sort
*Refgroup reference
Returns
NULL successfully sorted
err_array two comma separated lists of mismatches

Definition at line 474 of file sigset.c.

References G_calloc, G_fatal_error(), G_malloc, SigSet::nbands, SigSet::nclasses, SubSig::R, and Rast_get_semantic_label_or_name().

◆ I_WriteSigSet()