BRL-CAD
Loading...
Searching...
No Matches
Collaboration diagram for Image Operations:

Files

file  ops.h
 

Macros

#define ICV_DIFF_PHASH   0
 
#define ICV_DIFF_SSIM   1
 

Enumerations

enum  ICV_RESIZE_METHOD { ICV_RESIZE_UNDERSAMPLE , ICV_RESIZE_SHRINK , ICV_RESIZE_NINTERP , ICV_RESIZE_BINTERP }
 

Functions

int icv_sanitize (icv_image_t *img)
 
int icv_add_val (icv_image_t *img, double val)
 
int icv_multiply_val (icv_image_t *img, double val)
 
int icv_divide_val (icv_image_t *img, double val)
 
int icv_pow_val (icv_image_t *img, double val)
 
icv_image_ticv_add (icv_image_t *img1, icv_image_t *img2)
 
icv_image_ticv_sub (icv_image_t *img1, icv_image_t *img2)
 
icv_image_ticv_multiply (icv_image_t *img1, icv_image_t *img2)
 
icv_image_ticv_divide (icv_image_t *img1, icv_image_t *img2)
 
int icv_saturate (icv_image_t *img, double sat)
 
int icv_resize (icv_image_t *bif, ICV_RESIZE_METHOD method, size_t out_width, size_t out_height, size_t factor)
 
int icv_rot (size_t argc, const char *argv[])
 
int icv_diff (int *matching, int *off_by_1, int *off_by_many, icv_image_t *img1, icv_image_t *img2)
 
icv_image_ticv_diffimg (icv_image_t *img1, icv_image_t *img2)
 
DEPRECATED uint32_t icv_pdiff (icv_image_t *img1, icv_image_t *img2)
 
fastf_t icv_adiff (icv_image_t *img1, icv_image_t *img2, int m)
 
int icv_diff_render_info (const icv_image_t *img1, const icv_image_t *img2, struct bu_vls *out_msgs)
 
int icv_diff_nirt_shots (const icv_image_t *img1, const icv_image_t *img2, FILE *nirt_out1, FILE *nirt_out2)
 
int icv_fit (icv_image_t *img, struct bu_vls *msg, size_t o_width_req, size_t o_height_req, fastf_t sf)
 

Detailed Description

Various routines to perform operations on images.

Macro Definition Documentation

◆ ICV_DIFF_PHASH

#define ICV_DIFF_PHASH   0

Compare two images using approximate techniques.

Definition at line 237 of file ops.h.

◆ ICV_DIFF_SSIM

#define ICV_DIFF_SSIM   1

Definition at line 238 of file ops.h.

Enumeration Type Documentation

◆ ICV_RESIZE_METHOD

Enumerator
ICV_RESIZE_UNDERSAMPLE 
ICV_RESIZE_SHRINK 
ICV_RESIZE_NINTERP 
ICV_RESIZE_BINTERP 

Definition at line 147 of file ops.h.

Function Documentation

◆ icv_sanitize()

int icv_sanitize ( icv_image_t img)

This function sanitizes the image.

It forces the image pixels to be in the prescribed range.

All the pixels higher than the max range are set to MAX (1.0). All the pixels lower than the min range are set to MIN (0.0).

Note if an image(bif) is sanitized then, (bif->flags&&ICV_SANITIZED) is true.

◆ icv_add_val()

int icv_add_val ( icv_image_t img,
double  val 
)

This adds a constant value to all the pixels of the image. Also if the flag ICV_OPERATIONS_MODE is set this doesn't sanitize the image.

Note to set the flag for a bif (icv_image struct); bif->flags |= ICV_OPERATIONS_MODE;

◆ icv_multiply_val()

int icv_multiply_val ( icv_image_t img,
double  val 
)

This multiplies all the pixels of the image with a constant Value. Also if the flag ICV_OPERATIONS_MODE is set this doesn't sanitize the image.

◆ icv_divide_val()

int icv_divide_val ( icv_image_t img,
double  val 
)

This divides all the pixels of the image with a constant Value. Also if the flag ICV_OPERATIONS_MODE is set this doesn't sanitize the image.

◆ icv_pow_val()

int icv_pow_val ( icv_image_t img,
double  val 
)

This raises all the pixels of the image to a constant exponential power. Also if the flag ICV_OPERATIONS_MODE is set this doesn't sanitize the image.

◆ icv_add()

icv_image_t * icv_add ( icv_image_t img1,
icv_image_t img2 
)

This routine adds pixel value of one image to pixel value of other pixel and inserts in the same index of the output image.

Also it sanitizes the image.

◆ icv_sub()

icv_image_t * icv_sub ( icv_image_t img1,
icv_image_t img2 
)

This routine subtracts pixel value of one image from pixel value of other pixel and inserts the result at the same index of the output image.

Also it sanitizes the image.

Parameters
img1First Image.
img2Second Image.
Returns
New icv_image (img1 - img2)

◆ icv_multiply()

icv_image_t * icv_multiply ( icv_image_t img1,
icv_image_t img2 
)

This routine multiplies pixel value of one image to pixel value of other pixel and inserts the result at the same index of the output image.

Also it sanitizes the image.

Parameters
img1First Image.
img2Second Image.
Returns
New icv_image (img1 * img2)

◆ icv_divide()

icv_image_t * icv_divide ( icv_image_t img1,
icv_image_t img2 
)

This routine divides pixel value of one image from pixel value of other pixel and inserts the result at the same index of the output image.

Also it sanitizes the image.

Parameters
img1First Image.
img2Second Image.
Returns
New icv_image (img1 / img2)

◆ icv_saturate()

int icv_saturate ( icv_image_t img,
double  sat 
)

Change the saturation of image pixels. If sat is set to 0.0 the result will be monochromatic; if sat is made 1.0, the color will not change; if sat is made greater than 1.0, the amount of color is increased.

Parameters
imgRGB Image to be saturated.
satSaturation value.

◆ icv_resize()

int icv_resize ( icv_image_t bif,
ICV_RESIZE_METHOD  method,
size_t  out_width,
size_t  out_height,
size_t  factor 
)

This function resizes the given input image. Mode of usage: a) ICV_RESIZE_UNDERSAMPLE : This method undersamples the said image e.g. icv_resize(bif, ICV_RESIZE_UNDERSAMPLE, 0, 0, 2); undersamples the image with a factor of 2.

b) ICV_RESIZE_SHRINK : This Shrinks the image, keeping the light energy per square area as constant. e.g. icv_resize(bif, ICV_RESIZE_SHRINK,0,0,2); shrinks the image with a factor of 2.

c) ICV_RESIZE_NINTERP : This interpolates using nearest neighbor method. Output endpoints map to input endpoints; a one-pixel output maps to source coordinate zero. e.g. icv_resize(bif, ICV_RESIZE_NINTERP,1024,1024,0); interpolates the output image to have the size of 1024X1024.

d) ICV_RESIZE_BINTERP : This interpolates using bilinear Interpolation Method. Output endpoints map to input endpoints; a one-pixel output maps to source coordinate zero. Stretching one dimension while shrinking the other is supported. e.g. icv_resize(bif, ICV_RESIZE_BINTERP,1024,1024,0); interpolates the output image to have the size of 1024X1024.

resizes the image inplace.

Parameters
bifImage (packed in icv_image struct)
methodOne of the modes.
out_widthOut Width.
out_heightOut Height.
factorInteger type data representing the factor to be shrunken
Returns
0 on success and -1 on failure.

◆ icv_rot()

int icv_rot ( size_t  argc,
const char argv[] 
)
extern

Rotate an image. s [-rifb | -a angle] [-# bytes] [-s squaresize] [-w width] [-n height] [-o outputfile] inputfile [> outputfile]

◆ icv_diff()

int icv_diff ( int *  matching,
int *  off_by_1,
int *  off_by_many,
icv_image_t img1,
icv_image_t img2 
)
extern

Compare two images and report pixel differences. Return code is 1 if there are any differences, else 0. For more detailed reporting, pass non-null integer pointers to the matching, off_by_1, and/or off_by_many parameters.

Counts are per-channel (matching pixdiff "bytes" semantics):

  • matching = number of channel bytes with identical values across both images
  • off_by_1 = number of channel bytes differing by exactly 1
  • off_by_many = number of channel bytes differing by more than 1

◆ icv_diffimg()

icv_image_t * icv_diffimg ( icv_image_t img1,
icv_image_t img2 
)
extern

Generate a visual representation of the differences between two images. (At least for now, images must be the same size.)

For pixels that match, a half-intensity greyscale representation is output. For pixels that differ, each channel is independently highlighted:

  • channel byte values differ by exactly 1 → 0xC0 for that channel
  • channel byte values differ by more than 1 → 0xFF for that channel
  • channel byte values are equal → 0x00 for that channel

This means a pixel that differs only in the red channel appears as a pure red highlight, green-only difference as pure green, etc. – matching the traditional pixdiff output convention.

Returns NULL if there is an error.

◆ icv_pdiff()

DEPRECATED uint32_t icv_pdiff ( icv_image_t img1,
icv_image_t img2 
)
extern

Compare two images using perceptual image hashing and report the Hamming distance between them. Useful for approximate image comparisons.

◆ icv_adiff()

fastf_t icv_adiff ( icv_image_t img1,
icv_image_t img2,
int  m 
)
extern

◆ icv_diff_render_info()

int icv_diff_render_info ( const icv_image_t img1,
const icv_image_t img2,
struct bu_vls out_msgs 
)
extern

Compare the embedded render metadata (icv_render_info) of two images.

Writes a human-readable report to out_msgs describing any differences found in the db filename, object list, and camera parameters.

Returns 0 if the metadata in both images is identical (or both absent), 1 if they differ, and -1 if neither image carries any metadata.

Parameters
img1First image (may be NULL – treated as having no metadata)
img2Second image (may be NULL – treated as having no metadata)
out_msgsbu_vls to receive the human-readable comparison report; may be NULL

◆ icv_diff_nirt_shots()

int icv_diff_nirt_shots ( const icv_image_t img1,
const icv_image_t img2,
FILE *  nirt_out1,
FILE *  nirt_out2 
)
extern

Generate nirt shotline commands for every pixel that differs between img1 and img2.

A separate nirt script is written for each image that has render_info attached. Both scripts encode shotlines for the same set of differing pixels; they differ only in the camera parameters used to reconstruct the rays and in the scene header comment. This allows the caller to interrogate either scene independently even when the images were rendered from different .g files or with different object sets.

Ray reconstruction mirrors BRL-CAD rt/grid.c grid_setup() for the orthographic case (rt_perspective == 0). Perspective is also handled.

Either output file pointer may be NULL to suppress that output. If an image has no render_info the corresponding output is silently skipped.

Parameters
img1First image
img2Second image
nirt_out1Open FILE* to write img1's nirt script (may be NULL)
nirt_out2Open FILE* to write img2's nirt script (may be NULL)

Returns the number of differing pixels for which shots were written, or -1 on error (e.g., neither active output has render metadata, mismatched sizes).

◆ icv_fit()

int icv_fit ( icv_image_t img,
struct bu_vls msg,
size_t  o_width_req,
size_t  o_height_req,
fastf_t  sf 
)
extern

Fit an image to suggested dimensions.