Edges
detect edges in an image
Defines | Functions | Variables
edges.c File Reference

Edge detector. More...

#include <config.h>
#include <stdlib.h>
#include <stdio.h>
#include <assert.h>
#include <math.h>
#include <jwsc/base/error.h>
#include <jwsc/base/option.h>
#include <jwsc/matrix/matrix.h>
#include <jwsc/image/image.h>
#include <jwsc/image/image_io.h>
#include <jwsc/image/edge.h>

Go to the source code of this file.

Defines

#define DEFAULT_BEGIN_MAG_THRESH   0.05f
#define DEFAULT_END_MAG_THRESH   0.025f
#define DEFAULT_BREAK_DP_THRESH   -1.0f
#define DEFAULT_BREAK_DP_NUM_AVG   1
#define DEFAULT_SIGMA   1.0f
#define DEFAULT_SAMPLE_RATE   1.0f
#define DEFAULT_MIN_LEN   1
#define DEFAULT_SEED   289375
#define DEFAULT_RANDOM_COLOR   0
#define NUM_OPTS_NO_ARG   3
#define NUM_OPTS_WITH_ARG   12

Functions

static void print_usage (void)
 Prints the usage of the program.
static Errorprocess_help_opt (void)
 Processes the 'help' program options.
static Errorprocess_version_opt (void)
 Processes the 'version' program options.
static Errorprocess_random_color_opt (void)
 Processes the 'random-color' program options.
static Errorprocess_color_out_opt (Option_arg arg)
 Processes the 'color-out' program options.
static Errorprocess_map_out_opt (Option_arg arg)
 Processes the 'map-out' program options.
static Errorprocess_edges_in_opt (Option_arg arg)
 Processes the 'edges-in' program options.
static Errorprocess_edges_out_opt (Option_arg arg)
 Processes the 'edges-out' program options.
static Errorprocess_begin_mag_thresh_opt (Option_arg arg)
 Processes the 'begin-mag-thresh' program options.
static Errorprocess_end_mag_thresh_opt (Option_arg arg)
 Processes the 'end-mag-thresh' program options.
static Errorprocess_break_dp_thresh_opt (Option_arg arg)
 Processes the 'break-dp-thresh' program options.
static Errorprocess_break_dp_num_avg_opt (Option_arg arg)
 Processes the 'break-dp-num-avg' program options.
static Errorprocess_sigma_opt (Option_arg arg)
 Processes the 'sigma' program options.
static Errorprocess_sample_rate_opt (Option_arg arg)
 Processes the 'sample-rate' program options.
static Errorprocess_min_len_opt (Option_arg arg)
 Processes the 'min-len' program options.
static Errorprocess_seed_opt (Option_arg arg)
 Processes the 'seed' program options.
int main (int argc, const char **argv)
 Main function for the edge_detector program.

Variables

static Option_no_arg opts_no_arg [NUM_OPTS_NO_ARG]
 Program options taking no argument.
static Option_with_arg opts_with_arg [NUM_OPTS_WITH_ARG]
 Program options taking an argument.
static const char * map_fname = NULL
 Name of the edge map image to output.
static const char * color_fname = NULL
 Name of the image with edges colored to output.
static const char * edges_in_fname = NULL
 Name of the file to read the edge set from in ASCII.
static const char * edges_out_fname = NULL
 Name of the file to write the edge set to in ASCII.
static float begin_mag_thresh = DEFAULT_BEGIN_MAG_THRESH
 Gradient magnitude edge detection threshold for beginning hysterisis.
static float end_mag_thresh = DEFAULT_END_MAG_THRESH
 Gradient magnitude edge detection threshold for ending hysterisis.
static float break_dp_thresh = DEFAULT_BREAK_DP_THRESH
 Gradient vector dot product threshold for breaking edges.
static uint32_t break_dp_num_avg = DEFAULT_BREAK_DP_NUM_AVG
 Number of gradient vectors to average when computing the dot product threshold for breaking edges.
static float sigma = DEFAULT_SIGMA
 Sigma for smoothing the image.
static float sample_rate = DEFAULT_SAMPLE_RATE
 Percentage of detected edge points to randomly sample from.
static uint32_t min_len = DEFAULT_MIN_LEN
 Minimum edge length.
static uint32_t seed = DEFAULT_MIN_LEN
 Random seed.
static uint8_t random_color = DEFAULT_RANDOM_COLOR
 Boolean whether to randomly color edges.

Detailed Description

Edge detector.

Author:
Joseph Schlecht
License:
Creative Commons BY-NC-SA 3.0

Definition in file edges.c.


Define Documentation

#define DEFAULT_BEGIN_MAG_THRESH   0.05f

Definition at line 103 of file edges.c.

#define DEFAULT_END_MAG_THRESH   0.025f

Definition at line 104 of file edges.c.

#define DEFAULT_BREAK_DP_THRESH   -1.0f

Definition at line 105 of file edges.c.

#define DEFAULT_BREAK_DP_NUM_AVG   1

Definition at line 106 of file edges.c.

#define DEFAULT_SIGMA   1.0f

Definition at line 107 of file edges.c.

#define DEFAULT_SAMPLE_RATE   1.0f

Definition at line 108 of file edges.c.

#define DEFAULT_MIN_LEN   1

Definition at line 109 of file edges.c.

#define DEFAULT_SEED   289375

Definition at line 110 of file edges.c.

#define DEFAULT_RANDOM_COLOR   0

Definition at line 111 of file edges.c.

#define NUM_OPTS_NO_ARG   3

Definition at line 113 of file edges.c.

#define NUM_OPTS_WITH_ARG   12

Definition at line 114 of file edges.c.


Function Documentation

static void print_usage ( void  ) [static]

Prints the usage of the program.

Definition at line 172 of file edges.c.

static Error* process_help_opt ( void  ) [static]

Processes the 'help' program options.

Definition at line 181 of file edges.c.

static Error* process_version_opt ( void  ) [static]

Processes the 'version' program options.

Definition at line 189 of file edges.c.

static Error* process_random_color_opt ( void  ) [static]

Processes the 'random-color' program options.

Definition at line 197 of file edges.c.

static Error* process_color_out_opt ( Option_arg  arg) [static]

Processes the 'color-out' program options.

Definition at line 204 of file edges.c.

static Error* process_map_out_opt ( Option_arg  arg) [static]

Processes the 'map-out' program options.

Definition at line 215 of file edges.c.

static Error* process_edges_in_opt ( Option_arg  arg) [static]

Processes the 'edges-in' program options.

Definition at line 226 of file edges.c.

static Error* process_edges_out_opt ( Option_arg  arg) [static]

Processes the 'edges-out' program options.

Definition at line 237 of file edges.c.

static Error* process_begin_mag_thresh_opt ( Option_arg  arg) [static]

Processes the 'begin-mag-thresh' program options.

Definition at line 248 of file edges.c.

static Error* process_end_mag_thresh_opt ( Option_arg  arg) [static]

Processes the 'end-mag-thresh' program options.

Definition at line 262 of file edges.c.

static Error* process_break_dp_thresh_opt ( Option_arg  arg) [static]

Processes the 'break-dp-thresh' program options.

Definition at line 276 of file edges.c.

static Error* process_break_dp_num_avg_opt ( Option_arg  arg) [static]

Processes the 'break-dp-num-avg' program options.

Definition at line 291 of file edges.c.

static Error* process_sigma_opt ( Option_arg  arg) [static]

Processes the 'sigma' program options.

Definition at line 305 of file edges.c.

static Error* process_sample_rate_opt ( Option_arg  arg) [static]

Processes the 'sample-rate' program options.

Definition at line 319 of file edges.c.

static Error* process_min_len_opt ( Option_arg  arg) [static]

Processes the 'min-len' program options.

Definition at line 334 of file edges.c.

static Error* process_seed_opt ( Option_arg  arg) [static]

Processes the 'seed' program options.

Definition at line 348 of file edges.c.

int main ( int  argc,
const char **  argv 
)

Main function for the edge_detector program.

Definition at line 365 of file edges.c.


Variable Documentation

Option_no_arg opts_no_arg[NUM_OPTS_NO_ARG] [static]

Program options taking no argument.

Definition at line 118 of file edges.c.

Option_with_arg opts_with_arg[NUM_OPTS_WITH_ARG] [static]

Program options taking an argument.

Definition at line 121 of file edges.c.

const char* map_fname = NULL [static]

Name of the edge map image to output.

Definition at line 125 of file edges.c.

const char* color_fname = NULL [static]

Name of the image with edges colored to output.

Definition at line 128 of file edges.c.

const char* edges_in_fname = NULL [static]

Name of the file to read the edge set from in ASCII.

Definition at line 131 of file edges.c.

const char* edges_out_fname = NULL [static]

Name of the file to write the edge set to in ASCII.

Definition at line 134 of file edges.c.

float begin_mag_thresh = DEFAULT_BEGIN_MAG_THRESH [static]

Gradient magnitude edge detection threshold for beginning hysterisis.

Definition at line 139 of file edges.c.

float end_mag_thresh = DEFAULT_END_MAG_THRESH [static]

Gradient magnitude edge detection threshold for ending hysterisis.

Definition at line 144 of file edges.c.

float break_dp_thresh = DEFAULT_BREAK_DP_THRESH [static]

Gradient vector dot product threshold for breaking edges.

Definition at line 147 of file edges.c.

uint32_t break_dp_num_avg = DEFAULT_BREAK_DP_NUM_AVG [static]

Number of gradient vectors to average when computing the dot product threshold for breaking edges.

Definition at line 153 of file edges.c.

float sigma = DEFAULT_SIGMA [static]

Sigma for smoothing the image.

Definition at line 156 of file edges.c.

float sample_rate = DEFAULT_SAMPLE_RATE [static]

Percentage of detected edge points to randomly sample from.

Definition at line 159 of file edges.c.

uint32_t min_len = DEFAULT_MIN_LEN [static]

Minimum edge length.

Definition at line 162 of file edges.c.

uint32_t seed = DEFAULT_MIN_LEN [static]

Random seed.

Definition at line 165 of file edges.c.

uint8_t random_color = DEFAULT_RANDOM_COLOR [static]

Boolean whether to randomly color edges.

Definition at line 168 of file edges.c.