JWS C Library
C language utility library
|
Declarations for an image edge detector. More...
#include <jwsc/config.h>
#include <stdlib.h>
#include <inttypes.h>
#include "jwsc/base/error.h"
#include "jwsc/image/image.h"
#include "jwsc/matrix/matrix.h"
Go to the source code of this file.
Data Structures | |
struct | Edge_point_f |
Edge point in an image or matrix (single-sampled image). More... | |
struct | Edge_set_f |
Set of edges composed of edge points. More... | |
Functions | |
detect_image_edge_set | |
Detects a set of edges in each sample of an image. | |
Error * | detect_image_edge_set_f (Edge_set_f **edges_out, const Image_f *img, float sigma, float begin_thresh, float end_thresh, uint32_t padding) |
Detects a set of edges in each sample of a single precision image. | |
Error * | DEPRECATED_detect_image_edge_set_f (Edge_set_f **r_edges_out, Edge_set_f **g_edges_out, Edge_set_f **b_edges_out, const Image_f *img, float sigma, float begin_thresh, float end_thresh, uint32_t padding) |
Detects a set of edges in each sample of a single precision image. | |
detect_matrix_edge_set | |
Detects a set of edges in a matrix (single-sample image). | |
Error * | detect_matrix_edge_set_f (Edge_set_f **edges_out, const Matrix_f *m, float sigma, float begin_thresh, float end_thresh, uint32_t padding) |
Detects a set of edges in a single precision matrix (single-sample image). | |
free_edge_set | |
Frees a set of edges. | |
void | free_edge_set_f (Edge_set_f *edges) |
Frees a set of single precision edges. | |
remove_short_edges | |
Removes edges with a number of points less than a specified minimum. | |
void | remove_short_edges_f (Edge_set_f *edges, uint32_t min_len) |
Removes single precision edges with a number of points less than a specified minimum. | |
break_edges_at_corners | |
Finds the edge point with the largest gradient difference on either side, breaks the edge, and recurses on the two newly created edges. | |
void | break_edges_at_corners_f (Edge_set_f *edges, float thresh, uint32_t num_avg) |
Breaks apart single precision edges where the gradient direction changes significantly. | |
sample_edge_set | |
Randomly samples edge points from a set of them. | |
void | sample_edge_set_f (Edge_set_f **edges_out, const Edge_set_f *edges_in, float p) |
Randomly samples single precision edge points from a set of them. | |
color_edge_set | |
Colors a set of edges in an image. | |
Error * | color_edge_set_f (Image_f **img_out, const Image_f *img_in, const Edge_set_f *edges, const Pixel_f *pxl) |
Colors single precision set of edges in an image. | |
randomly_color_edge_set | |
Colors a set of edges in an image with randomly selected colors. | |
Error * | randomly_color_edge_set_f (Image_f **img_out, const Image_f *img_in, const Edge_set_f *edges) |
Colors single precision set of edges in an image with randomly selected colors. | |
color_edge_points | |
Colors edge points in an image. | |
Error * | color_edge_points_f (Image_f **img_out, const Image_f *img_in, const Edge_point_f *pts, uint32_t num_pts, const Pixel_f *pxl) |
Colors single precision edge points in an image. | |
randomly_color_edge_points | |
Colors edge points in an image with a randomly selected color. | |
Error * | randomly_color_edge_points_f (Image_f **img_out, const Image_f *img_in, const Edge_point_f *pts, uint32_t num_pts) |
read_edge_set | |
Reads a set of edges in ASCII format from a file. | |
Error * | read_edge_set_f (Edge_set_f **edges_out, const char *fname) |
Reads a set of single precision edges in ASCII format from a file. | |
write_edge_set | |
Writes a set of edges in ASCII format to a file. | |
Error * | write_edge_set_f (const Edge_set_f *edges, const char *fname) |
Writes a set of single precision edges in ASCII format to a file. |
Declarations for an image edge detector.
The edge detection algorithm is a variation of the standard Canny algorithm: the image is convolved with the gradiant of Gaussian, then non-maximal suppression and hysterisis are applied to the resulting gradient map.
Definition in file edge.h.
Error* detect_image_edge_set_f | ( | Edge_set_f ** | edges_out, |
const Image_f * | img, | ||
float | sigma, | ||
float | begin_thresh, | ||
float | end_thresh, | ||
uint32_t | padding | ||
) |
Detects a set of edges in each sample of a single precision image.
Smoothed partial derivative kernels, non-maximal suppression, and hysteresis are used to trace out the edge points from the input image.
edges_out | Result parameter. If *r_edges_out is NULL, an array of edge points is allocated; otherwise its space is re-used. |
img | Image to get the edge points of. |
sigma | Parameter for the Gaussian kernel used for smoothing and edge detection. |
begin_thresh | Used when scanning the image to look for gradient magnitudes to follow under non-maximal suppression. |
end_thresh | Once an edge is found under non-maximal suppression, it is followed (perpendicular to the gradient) until the gradient magnitude falls below this threshold. |
padding | Amount of padding to use around the border of the image. The padding is created by extending the image. |
Error* DEPRECATED_detect_image_edge_set_f | ( | Edge_set_f ** | r_edges_out, |
Edge_set_f ** | g_edges_out, | ||
Edge_set_f ** | b_edges_out, | ||
const Image_f * | img, | ||
float | sigma, | ||
float | begin_thresh, | ||
float | end_thresh, | ||
uint32_t | padding | ||
) |
Detects a set of edges in each sample of a single precision image.
Smoothed partial derivative kernels, non-maximal suppression, and hysteresis are used to trace out the edge points from the input image.
r_edges_out | Result parameter. If *r_edges_out is NULL, an array of edge points is allocated; otherwise its space is re-used. |
g_edges_out | Result parameter. If *g_edges_out is NULL, an array of edge points is allocated; otherwise its space is re-used. |
b_edges_out | Result parameter. If *b_edges_out is NULL, an array of edge points is allocated; otherwise its space is re-used. |
img | Image to get the edge points of. |
sigma | Parameter for the Gaussian kernel used for smoothing and edge detection. |
begin_thresh | Used when scanning the image to look for gradient magnitudes to follow under non-maximal suppression. |
end_thresh | Once an edge is found under non-maximal suppression, it is followed (perpendicular to the gradient) until the gradient magnitude falls below this threshold. |
padding | Amount of padding to use around the border of the image. The padding is created by extending the image. |
Error* detect_matrix_edge_set_f | ( | Edge_set_f ** | edges_out, |
const Matrix_f * | m, | ||
float | sigma, | ||
float | begin_thresh, | ||
float | end_thresh, | ||
uint32_t | padding | ||
) |
Detects a set of edges in a single precision matrix (single-sample image).
Smoothed partial derivative kernels, non-maximal suppression, and hysteresis are used to trace out the edge points from the input image.
edges_out | Result parameter. If *edges_out is NULL, an array of edge points is allocated; otherwise its space is re-used. |
m | Matrix to get the edge points of. |
sigma | Parameter for the Gaussian kernel used for smoothing and edge detection. |
begin_thresh | Used when scanning the image to look for gradient magnitudes to follow under non-maximal suppression. |
end_thresh | Once an edge is found under non-maximal suppression, it is followed (perpendicular to the gradient) until the gradient magnitude falls below this threshold. |
padding | Amount of padding to use around the border of the matrix. The padding is created by extending the matrix. |
void free_edge_set_f | ( | Edge_set_f * | edges | ) |
void remove_short_edges_f | ( | Edge_set_f * | edges, |
uint32_t | min_len | ||
) |
void break_edges_at_corners_f | ( | Edge_set_f * | edges, |
float | thresh, | ||
uint32_t | num_avg | ||
) |
Breaks apart single precision edges where the gradient direction changes significantly.
edges | Edge set to break apart. |
thresh | If the dot product of the averaged vectors is less than this threshold, the edge is broken. |
num_avg | Number of gradient vectors to average into one when computing the dot product. |
void sample_edge_set_f | ( | Edge_set_f ** | edges_out, |
const Edge_set_f * | edges_in, | ||
float | p | ||
) |
Randomly samples single precision edge points from a set of them.
edges_out | Result parameter. If *edges_out is NULL, a set of edges is allocated; otherwise its space is re-used. |
edges_in | Set of edges to sample from. |
p | Bernoulli parameter; probability of sampling an edge point. |
Error* color_edge_set_f | ( | Image_f ** | img_out, |
const Image_f * | img_in, | ||
const Edge_set_f * | edges, | ||
const Pixel_f * | pxl | ||
) |
Colors single precision set of edges in an image.
img_out | Result parameter. If *img_out is NULL, an image is allocated; otherwise its space is re-used. |
img_in | Image to color the edge points on. |
edges | Edge set to use. |
pxl | Pixel to use for coloring the edge points. |
Error* randomly_color_edge_set_f | ( | Image_f ** | img_out, |
const Image_f * | img_in, | ||
const Edge_set_f * | edges | ||
) |
Colors single precision set of edges in an image with randomly selected colors.
img_out | Result parameter. If *img_out is NULL, an image is allocated; otherwise its space is re-used. |
img_in | Image to color the edge points on. |
edges | Edge set to use. |
Error* color_edge_points_f | ( | Image_f ** | img_out, |
const Image_f * | img_in, | ||
const Edge_point_f * | pts, | ||
uint32_t | num_pts, | ||
const Pixel_f * | pxl | ||
) |
Colors single precision edge points in an image.
img_out | Result parameter. If *img_out is NULL, an image is allocated; otherwise its space is re-used. |
img_in | Image to color the edge points on. |
pts | Edge points to use. |
num_pts | Number of elements in pts. |
pxl | Pixel to use for coloring the edge points. |
Error* randomly_color_edge_points_f | ( | Image_f ** | img_out, |
const Image_f * | img_in, | ||
const Edge_point_f * | pts, | ||
uint32_t | num_pts | ||
) |
Colors single precision edge points in an image with a randomly selected color.
img_out | Result parameter. If *img_out is NULL, an image is allocated; otherwise its space is re-used. |
img_in | Image to color the edge points on. |
pts | Edge points to use. |
num_pts | Number of elements in pts. |
Error* read_edge_set_f | ( | Edge_set_f ** | edges_out, |
const char * | fname | ||
) |
Reads a set of single precision edges in ASCII format from a file.
The first line of the file must contains the number of edges, the second has the total number of edge points and the following lines have the number of points in each edge followed by the actual points. For example,
num_rows=100 num_cols=100 num_edges=2 total_num_points=5 num_pts=3 col=0 row=0 dcol=1 drow=1 mag=1 col=9 row=8 dcol=4 drow=1 mag=1 col=1 row=2 dcol=2 drow=1 mag=1 num_pts=2 col=9 row=8 dcol=4 drow=1 mag=1 col=1 row=2 dcol=2 drow=1 mag=1
edges_out | Result parameter. If *edges_out is NULL, an edge set is allocated; otherwise its space is re-used. |
fname | Name of the file to read from. |
Error* write_edge_set_f | ( | const Edge_set_f * | edges, |
const char * | fname | ||
) |
Writes a set of single precision edges in ASCII format to a file.
The first line of the file contains the number of edges, the second has the total number of edge points and the following lines have the number of points in each edge followed by the actual points. For example,
num_rows=100 num_cols=100 num_edges=2 total_num_points=5 num_pts=3 col=0 row=0 dcol=1 drow=1 mag=1 col=9 row=8 dcol=4 drow=1 mag=1 col=1 row=2 dcol=2 drow=1 mag=1 num_pts=2 col=9 row=8 dcol=4 drow=1 mag=1 col=1 row=2 dcol=2 drow=1 mag=1
edges | Edge set to write. |
fname | Name of the file to write to. |