JWS C Library
C language utility library
surface.h File Reference

Declarations for the image block surface detector. More...

#include <jwsc/config.h>
#include <stdlib.h>
#include <inttypes.h>
#include "jwsc/base/error.h"
#include "jwsc/vector/vector.h"
#include "jwsc/imgblock/imgblock.h"
#include "jwsc/matblock/matblock.h"
Include dependency graph for surface.h:

Go to the source code of this file.

Data Structures

struct  Surface_point_f
 Surface point in an image block or matrix block (single-sampled image). More...
struct  Surface_patch_f
 A patch of surface on a plane defined by the position and orientation of a Surface_point_f. More...

Functions

detect_imgblock_surface_points

Detects surface points in each sample of an image block.

Errordetect_imgblock_surface_points_f (Surface_point_f **r_pts_out, uint32_t *num_r_pts_out, Surface_point_f **g_pts_out, uint32_t *num_g_pts_out, Surface_point_f **b_pts_out, uint32_t *num_b_pts_out, const Imgblock_f *img, float sigma, float grad_img_weight, float grad_row_weight, float grad_col_weight, float begin_thresh, float end_thresh)
 Detects surface points in each sample of a single precision image block.
detect_matblock_surface_points

Detects surface points in a matrix block (single-sample image block).

Errordetect_matblock_surface_points_f (Surface_point_f **pts_out, uint32_t *num_pts_out, const Matblock_f *m, float sigma, float grad_mat_weight, float grad_row_weight, float grad_col_weight, float begin_thresh, float end_thresh)
 Detects surface points in a single precision matrix block (single-sample image block).
sample_surface_points

Randomly samples surface points from an array of them.

void sample_surface_points_f (Surface_point_f **pts_out, uint32_t *num_pts_out, const Surface_point_f *pts_in, uint32_t num_pts_in, float p)
 Randomly samples single precision surface points from an array of them.
color_surface_points

Colors surface points in an image block.

void color_surface_points_f (Imgblock_f **img_out, const Imgblock_f *img_in, const Surface_point_f *pts, uint32_t num_pts, const Pixel_f *pxl)
 Colors single precision surface points in an image block.
read_surface_points

Reads an array of surface points in ASCII format from a file.

Errorread_surface_points_f (Surface_point_f **pts_out, uint32_t *num_pts_out, const char *fname)
 Reads an array of single precision surface points in ASCII format from a file.
write_surface_points

Writes an array of surface points in ASCII format to a file.

Errorwrite_surface_points_f (const Surface_point_f *pts, uint32_t num_pts, const char *fname)
 Writes an array of single precision surface pionts in ASCII format to a file.
create_surface_patch

Creates a Surface_patch from a Surface_point.

void create_surface_patch_f (Surface_patch_f **patch_out, const Surface_point_f *point, float size, float x_scale, float y_scale, float z_scale)
 Creates a Surface_patch_f from a Surface_point_f.
free_surface_patch

Frees a Surface_patch from a Surface_point.

void free_surface_patch_f (Surface_patch_f *patch)
 Frees a Surface_patch_f.

Detailed Description

Declarations for the image block surface detector.

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

The surface detection algorithm is a variation of the standard Canny algorithm: the image block is convolved with the gradiant of Gaussian, then non-maximal suppression and hysterisis are applied to the resulting gradient map.

Definition in file surface.h.


Function Documentation

Error* detect_imgblock_surface_points_f ( Surface_point_f **  r_pts_out,
uint32_t *  num_r_pts_out,
Surface_point_f **  g_pts_out,
uint32_t *  num_g_pts_out,
Surface_point_f **  b_pts_out,
uint32_t *  num_b_pts_out,
const Imgblock_f img,
float  sigma,
float  grad_img_weight,
float  grad_row_weight,
float  grad_col_weight,
float  begin_thresh,
float  end_thresh 
)

Detects surface points in each sample of a single precision image block.

Smoothed partial derivative kernels, non-maximal suppression, and hysteresis are used to trace out the surface points from the input image block.

Parameters:
r_pts_outResult parameter. If *r_pts_out is NULL, an array of surface points is allocated; otherwise its space is re-used.
num_r_pts_outResult parameter. Number of surface points detected in the red sample.
g_pts_outResult parameter. If *g_pts_out is NULL, an array of surface points is allocated; otherwise its space is re-used.
num_g_pts_outResult parameter. Number of surface points detected in the green sample.
b_pts_outResult parameter. If *b_pts_out is NULL, an array of surface points is allocated; otherwise its space is re-used.
num_b_pts_outResult parameter. Number of surface points detected in the blue sample.
imgImage block to get the surface points of.
sigmaParameter for the Gaussian kernel used for smoothing and surface detection.
grad_img_weightGradient weight for the image component.
grad_row_weightGradient weight for the row component.
grad_col_weightGradient weight for the column component.
begin_threshUsed when scanning the image block to look for gradient magnitudes to follow under non-maximal suppression.
end_threshOnce a surface is found under non-maximal suppression, it is followed (perpendicular to the gradient) until the gradient magnitude falls below this threshold.
Returns:
On success, NULL is returned. On error, an Error is returned and *[rgb]_pts_out are freed and set to NULL.

Definition at line 673 of file surface.c.

Error* detect_matblock_surface_points_f ( Surface_point_f **  pts_out,
uint32_t *  num_pts_out,
const Matblock_f m,
float  sigma,
float  grad_mat_weight,
float  grad_row_weight,
float  grad_col_weight,
float  begin_thresh,
float  end_thresh 
)

Detects surface points in a single precision matrix block (single-sample image block).

Smoothed partial derivative kernels, non-maximal suppression, and hysteresis are used to trace out the surface points from the input image block.

Parameters:
pts_outResult parameter. If *pts_out is NULL, an array of surface points is allocated; otherwise its space is re-used.
num_pts_outResult parameter. Number of surface points detected.
mMatrix block to get the surface points of.
sigmaParameter for the Gaussian kernel used for smoothing and surface detection.
grad_mat_weightGradient weight for the matrix component.
grad_row_weightGradient weight for the row component.
grad_col_weightGradient weight for the column component.
begin_threshUsed when scanning the image block to look for gradient magnitudes to follow under non-maximal suppression.
end_threshOnce an surface is found under non-maximal suppression, it is followed (perpendicular to the gradient) until the gradient magnitude falls below this threshold.
Returns:
On success, NULL is returned. On error, an Error is returned and *pts_out are freed and set to NULL.

Definition at line 761 of file surface.c.

void sample_surface_points_f ( Surface_point_f **  pts_out,
uint32_t *  num_pts_out,
const Surface_point_f pts_in,
uint32_t  num_pts_in,
float  p 
)

Randomly samples single precision surface points from an array of them.

Parameters:
pts_outResult parameter. If *pts_out is NULL, an array of surface points is allocated; otherwise its space is re-used.
num_pts_outNumber of surface points sampled.
pts_inArray of surface points to sample from.
num_pts_inNumber of surface points in pts_in.
pBernoulli parameter; probability of sampling an surface point.
Note:
If *pts_out == pts_in, then pts_in is overwritten.

Definition at line 818 of file surface.c.

void color_surface_points_f ( Imgblock_f **  img_out,
const Imgblock_f img_in,
const Surface_point_f pts,
uint32_t  num_pts,
const Pixel_f pxl 
)

Colors single precision surface points in an image block.

Parameters:
img_outResult parameter. If *img_out is NULL, an image block is allocated; otherwise its space is re-used.
img_inImage block to color the edge points on.
ptsSurface points to use.
num_ptsNumber of elements in pts.
pxlPixel to use for coloring the surface points.

Definition at line 879 of file surface.c.

Error* read_surface_points_f ( Surface_point_f **  pts_out,
uint32_t *  num_pts_out,
const char *  fname 
)

Reads an array of single precision surface points in ASCII format from a file.

The first line of the file must contain the number of surface points and each line after that must contain the parameters for one of those points. For example:

 num_pts=3
 col=0 row=0 mat=0 dcol=1 drow=1 dmat=2 intensity=1
 col=9 row=8 mat=7 dcol=4 drow=1 dmat=3 intensity=1
 col=1 row=2 mat=3 dcol=2 drow=1 dmat=0 intensity=1
Parameters:
pts_outResult parameter. If *pts_out is NULL, an array of surface points is allocated; otherwise its space is re-used.
num_pts_outNumber of surface points read from the file.
fnameName of the file to read from.
Returns:
On success, NULL is returned. On error, an Error is returned and *pts_out is freed and set to NULL.

Definition at line 937 of file surface.c.

Error* write_surface_points_f ( const Surface_point_f pts,
uint32_t  num_pts,
const char *  fname 
)

Writes an array of single precision surface pionts in ASCII format to a file.

The first line of the file contains the number of surface points and each line after that contains the parameters for one of those points. For example:

 num_pts=3
 col=0 row=0 mat=0 dcol=1 drow=1 dmat=2 intensity=1
 col=9 row=8 mat=7 dcol=4 drow=1 dmat=3 intensity=1
 col=1 row=2 mat=3 dcol=2 drow=1 dmat=0 intensity=1
Parameters:
ptsArray of surface points to write.
num_ptsNumber of surface points write to the file.
fnameName of the file to write to.
Returns:
On success, NULL is returned. On error, an Error is returned.

Definition at line 1023 of file surface.c.

void create_surface_patch_f ( Surface_patch_f **  patch_out,
const Surface_point_f point,
float  size,
float  x_scale,
float  y_scale,
float  z_scale 
)

Creates a Surface_patch_f from a Surface_point_f.

Parameters:
patch_outResult parameter.
pointPoint to create a patch from.
sizeLength of each side of the patch.
x_scaleNumber of world units per column value in a surface point.
y_scaleNumber of world units per row value in a surface point.
z_scaleNumber of world units per image value in a surface point.

Creates square shaped patches with each side of length size.

Definition at line 1081 of file surface.c.

void free_surface_patch_f ( Surface_patch_f patch)

Frees a Surface_patch_f.

Parameters:
patchSurface_patch_f to free.

Definition at line 1211 of file surface.c.