Chan-Vese Segmentation
|
Utilities for creating a command line interface. More...
#include <ctype.h>
#include <math.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include "cliio.h"
Go to the source code of this file.
Functions | |
int | AllocImageObj (image *f, int Width, int Height, int NumChannels) |
void | FreeImageObj (image f) |
int | ReadImageObj (image *f, const char *FileName) |
int | ReadImageObjGrayscale (image *f, const char *FileName) |
int | WriteImageObj (image f, const char *FileName, int JpegQuality) |
int | IsGrayscale (num *Data, int Width, int Height) |
Check whether all three channels in a color image are the same. | |
int | GetStrToken (char *Token, const char *Start, int MaxLength, const char *Delim) |
Extract a token from a null-terminated string. More... | |
int | ParseDouble (double *Num, const char *String) |
Read a floating-point number from a string. More... | |
int | CliParseArglist (const char **Param, const char **Value, char *TokenBuf, int MaxLength, int k, const char *Start, int argc, const char *argv[], const char *Delimiters) |
Parse an arg list for param-value pairs. More... | |
int | CliGetNum (num *Value, const char *String, const char *Param) |
Strictly read a num value. | |
int | ReadMatrixFromTextFile (image *f, const char *FileName) |
Read a matrix from a text file. | |
int | ReadMatrixFromFile (image *f, const char *FileName, int(*RescaleFun)(image *f)) |
Read a matrix from a text or image file. | |
Variables | |
const image | NullImage = {NULL, 0, 0, 0} |
Utilities for creating a command line interface.
Definition in file cliio.c.
int CliParseArglist | ( | const char ** | Param, |
const char ** | Value, | ||
char * | TokenBuf, | ||
int | MaxLength, | ||
int | k, | ||
const char * | Start, | ||
int | argc, | ||
const char * | argv[], | ||
const char * | Delimiters | ||
) |
Parse an arg list for param-value pairs.
Param | where to store the parameter pointer |
Value | where to store the value pointer |
TokenBuf | token buffer with space for at least MaxLength+1 chars |
MaxLength | token buffer size |
k | starting arg |
Start | starting character position in argv[k] |
argc,argv | the arg list |
Delimiters | characters that delimit parameters from values |
For example, with Delimiters = ":", the routine parses arg lists of the form {"param1:value1", "param2:value2", "param3:value3"}. It is flexible to allow argument breaks around the delimiter, including any of the following syntaxes: {"param", "value"}, {"param:", "value"}, {"param", ":", "value"}, {"param", ":", "", "value"}.
The routine can be used as
int GetStrToken | ( | char * | Token, |
const char * | Start, | ||
int | MaxLength, | ||
const char * | Delim | ||
) |
Extract a token from a null-terminated string.
Token | destination buffer (with space for at least MaxLength+1 chars) |
Start | pointer to the source string |
MaxLength | maximum length of the token, not including null terminator |
Delim | delimiter characters |
int ParseDouble | ( | double * | Num, |
const char * | String | ||
) |
Read a floating-point number from a string.
Num | is a pointer to where to store the result |
String | is a pointer to the source string to parse |
The function strtod does not seem to work on some systems. We use the following routine instead.
The routine reads as many characters as possible to form a valid floating-point number in decimal or scientific notation. A return value of zero indicates that no valid number was found.