#ifndef float_image_splat_H #define float_image_splat_H /* Tools for splatting (pixelwise adding) shapes onto float images. */ /* Last edited on 2018-03-04 23:22:34 by stolfilocal */ #include #include #include #include /* IMAGE COORDINATES For the functions in this interface, the domain of a float image {A} is an axis-aligned rectangle {[0 _ nx] × [0 _ ny]} of the plane {R^2} with pixel in row 0, column 0 adjacent to the origin, where {nx = A->sz[1]} and {ny = A->sz[2]}. Each pixel with indices {(x,y)} is conceptually a square with side 1, whose corners are {(x,y)} and {(x+1,y+1)}, and whose center is {(x+0.5,y+0.5)}. SUBSAMPLING In all procedures below, the procedural image is filtered by averaging it over a grid of {2*m+1} by {2*m+1} subsamples within a window of size {2 × 2} pixels centered on pixel {ix,iy}, with C1 piecewise quadratic weights. In particular, if {m} is zero, there is no subsampling: the procedural image is sampled once, at the center of that pixel. TOTAL SPLATTED MASS In all the procedures below, if {vTot} is not {NULL}, the total amount that was added to the image is also added to {vTot}. However, if {A} is {NULL}, {vTot} receives the amount that would be added, if {A} was given and the figure was not clipped to its domain. Note that {vTot} must be cleared by the client before calling the procedures. */ void float_image_splat_sample ( float_image_t *A, int c, double *vTot, int ix, int iy, float_image_func_t *func, int m ); /* Adds to pixel {ix,iy} of channel {c} of image {A} the average value of procedural image {func} at that pixel. It is a no-op if the the average value is {NAN} If the image {A} is {NULL}, or {(ix,iy)} is outside the image's domain, no painting is done. */ void float_image_splat_samples ( float_image_t *A, int c, double *vTot, int xLo, int xHi, int yLo, int yHi, float_image_func_t *func, int m ); /* Applies {float_image_splat_sample} to all pixels {ix,iy} with {ix} in {xLo..xHi} and {iy} in {yLo..yHi}. If {A} is {NULL} or {xLo > xHi} or {yLo > yHi}, no painting is done. */ /* SPLATTING SIMPLE SHAPES The procedures in this section splat simple geometric shapes on the given image {A}. If {v} is {NAN}, the operation is a no-op. If the image {A} is {NULL}, or the figure falls entirely outside the domain, no painting is done. */ void float_image_splat_dot ( float_image_t *A, int c, /* Channel. */ double *vTot, double xctr, /* Center's X coordinate. */ double yctr, /* Center's Y coordinate. */ double rad, /* Radius of cross (not counting {hwd}). */ float v, /* Value inside dot. */ int m /* Subsampling parameter. */ ); /* Splats into channel {c} of image {A} a circular dot centered at {xctr,yctr} with radius {fabs(rad)}. */ void float_image_splat_smudge ( float_image_t *A, int c, /* Channel. */ double *vTot, double xctr, /* Center's X coordinate. */ double yctr, /* Center's Y coordinate. */ double xdev, /* Standard deviation in X direction. */ double ydev, /* Standard deviation in Y direction. */ float v, /* Value at center. */ int m /* Subsampling parameter. */ ); /* Paints onto channel {c} of image {A} a fuzzy dot centered at {xctr,yctr}. The dot will have color {v} at the center, decaying to zero away from it according to an axis-aligned Gaussian bell fuction with deviations {xdev,ydev} along each axis. */ double float_image_splat_smudge_mass ( double xctr, /* Center's X coordinate. */ double yctr, /* Center's Y coordinate. */ double xdev, /* Standard deviation in X direction. */ double ydev, /* Standard deviation in Y direction. */ int m /* Subsampling parameter. */ ); /* Returns the total amount that would be added to an image by {float_image_splat_smudge} with given smudge parameters and unit value {v}. Assumes that the whole smudge would fit in the image. */ #endif