lensfun: Image correction

lensfun 0.3.4.0

Classes | Macros | Typedefs | Enumerations | Functions
Image correction

This group of functions will allow you to apply a image transform that will correct some lens defects. More...

## Classes
struct | lfModifier
| A modifier object contains optimized data required to rectify a image. More...

## Macros
#define | LF_CR_1(a) (LF_CR_ ## a)
| This macro defines a pixel format consisting of one component.
#define | LF_CR_2(a, b) ((LF_CR_ ## a) | ((LF_CR_ ## b) << 4))
| This macro defines a pixel format consisting of two components.
#define | LF_CR_3(a, b, c)
| This macro defines a pixel format consisting of three components.
#define | LF_CR_4(a, b, c, d)
| This macro defines a pixel format consisting of four components.
#define | LF_CR_5(a, b, c, d, e)
| This macro defines a pixel format consisting of five components.
#define | LF_CR_6(a, b, c, d, e, f)
| This macro defines a pixel format consisting of six components.
#define | LF_CR_7(a, b, c, d, e, f, g)
| This macro defines a pixel format consisting of seven components.
#define | LF_CR_8(a, b, c, d, e, f, g, h)
| This macro defines a pixel format consisting of eight components.

## Typedefs
typedef void(* | lfSubpixelCoordFunc) (void *data, float *iocoord, int count)
| A callback function which modifies the separate coordinates for all color components for every pixel in a strip.
typedef void(* | lfModifyColorFunc) (void *data, float x, float y, void *pixels, int comp_role, int count)
| A callback function which modifies the colors of a strip of pixels.
typedef void(* | lfModifyCoordFunc) (void *data, float *iocoord, int count)
| A callback function which modifies the coordinates of a strip of pixels.

## Enumerations
enum | { LF_MODIFY_TCA = 0x00000001 , LF_MODIFY_VIGNETTING = 0x00000002 , LF_MODIFY_DISTORTION = 0x00000008 , LF_MODIFY_GEOMETRY = 0x00000010 , LF_MODIFY_SCALE = 0x00000020 , LF_MODIFY_ALL = ~0 }
| A list of bitmask flags used for ordering various image corrections. More...
enum | lfPixelFormat { LF_PF_U8 , LF_PF_U16 , LF_PF_U32 , LF_PF_F32 , LF_PF_F64 }
| A list of pixel formats supported by internal colour callbacks. More...
enum | lfComponentRole { LF_CR_END = 0 , LF_CR_NEXT , LF_CR_UNKNOWN , LF_CR_INTENSITY , LF_CR_RED , LF_CR_GREEN , LF_CR_BLUE }
| These constants define the role of every pixel component, four bits each. "pixel" refers here to a set of values which share the same (x, y) coordinates. More...

## Functions
lfModifier * | lf_modifier_new (const lfLens *lens, float crop, int width, int height)
void | lf_modifier_destroy (lfModifier *modifier)
int | lf_modifier_initialize (lfModifier *modifier, const lfLens *lens, lfPixelFormat format, float focal, float aperture, float distance, float scale, lfLensType targeom, int flags, cbool reverse)
void | lf_modifier_add_coord_callback (lfModifier *modifier, lfModifyCoordFunc callback, int priority, void *data, size_t data_size)
void | lf_modifier_add_subpixel_callback (lfModifier *modifier, lfSubpixelCoordFunc callback, int priority, void *data, size_t data_size)
void | lf_modifier_add_color_callback (lfModifier *modifier, lfModifyColorFunc callback, int priority, void *data, size_t data_size)
cbool | lf_modifier_add_subpixel_callback_TCA (lfModifier *modifier, lfLensCalibTCA *model, cbool reverse)
cbool | lf_modifier_add_color_callback_vignetting (lfModifier *modifier, lfLensCalibVignetting *model, lfPixelFormat format, cbool reverse)
cbool | lf_modifier_add_coord_callback_distortion (lfModifier *modifier, lfLensCalibDistortion *model, cbool reverse)
cbool | lf_modifier_add_coord_callback_geometry (lfModifier *modifier, lfLensType from, lfLensType to, float focal)
cbool | lf_modifier_add_coord_callback_scale (lfModifier *modifier, float scale, cbool reverse)
float | lf_modifier_get_auto_scale (lfModifier *modifier, cbool reverse)
cbool | lf_modifier_apply_subpixel_distortion (lfModifier *modifier, float xu, float yu, int width, int height, float *res)
cbool | lf_modifier_apply_color_modification (lfModifier *modifier, void *pixels, float x, float y, int width, int height, int comp_role, int row_stride)
cbool | lf_modifier_apply_geometry_distortion (lfModifier *modifier, float xu, float yu, int width, int height, float *res)
cbool | lf_modifier_apply_subpixel_geometry_distortion (lfModifier *modifier, float xu, float yu, int width, int height, float *res)

## Detailed Description

This group of functions will allow you to apply a image transform that will correct some lens defects.

## Macro Definition Documentation

## ◆ LF_CR_3

#define LF_CR_3 | ( |  | a,
|  |  | b,
|  |  | c )

Value:
((LF_CR_ ## a) | ((LF_CR_ ## b) << 4) | \
((LF_CR_ ## c) << 8))

This macro defines a pixel format consisting of three components.

## ◆ LF_CR_4

#define LF_CR_4 | ( |  | a,
|  |  | b,
|  |  | c,
|  |  | d )

Value:
((LF_CR_ ## a) | ((LF_CR_ ## b) << 4) | \
((LF_CR_ ## c) << 8) | ((LF_CR_ ## d) << 12))

This macro defines a pixel format consisting of four components.

Examples
  lenstool.cpp.

## ◆ LF_CR_5

#define LF_CR_5 | ( |  | a,
|  |  | b,
|  |  | c,
|  |  | d,
|  |  | e )

Value:
((LF_CR_ ## a) | ((LF_CR_ ## b) << 4) | \
((LF_CR_ ## c) << 8) | ((LF_CR_ ## d) << 12) | \
((LF_CR_ ## e) << 16))

This macro defines a pixel format consisting of five components.

## ◆ LF_CR_6

#define LF_CR_6 | ( |  | a,
|  |  | b,
|  |  | c,
|  |  | d,
|  |  | e,
|  |  | f )

Value:
((LF_CR_ ## a) | ((LF_CR_ ## b) << 4) | \
((LF_CR_ ## c) << 8) | ((LF_CR_ ## d) << 12) | \
((LF_CR_ ## e) << 16) | ((LF_CR_ ## f) << 20))

This macro defines a pixel format consisting of six components.

## ◆ LF_CR_7

#define LF_CR_7 | ( |  | a,
|  |  | b,
|  |  | c,
|  |  | d,
|  |  | e,
|  |  | f,
|  |  | g )

Value:
((LF_CR_ ## a) | ((LF_CR_ ## b) << 4) | \
((LF_CR_ ## c) << 8) | ((LF_CR_ ## d) << 12) | \
((LF_CR_ ## e) << 16) | ((LF_CR_ ## f) << 20) | \
((LF_CR_ ## g) << 24))

This macro defines a pixel format consisting of seven components.

## ◆ LF_CR_8

#define LF_CR_8 | ( |  | a,
|  |  | b,
|  |  | c,
|  |  | d,
|  |  | e,
|  |  | f,
|  |  | g,
|  |  | h )

Value:
((LF_CR_ ## a) | ((LF_CR_ ## b) << 4) | \
((LF_CR_ ## c) << 8) | ((LF_CR_ ## d) << 12) | \
((LF_CR_ ## e) << 16) | ((LF_CR_ ## f) << 20) | \
((LF_CR_ ## g) << 24) | ((LF_CR_ ## h) << 28))

This macro defines a pixel format consisting of eight components.

## Typedef Documentation

## ◆ lfModifyColorFunc

typedef void(* lfModifyColorFunc) (void *data, float x, float y, void *pixels, int comp_role, int count)

A callback function which modifies the colors of a strip of pixels.

This kind of callbacks are used in the first stage of image modification.

Parameters

  data | A opaque pointer to some data.
  x | The X coordinate of the beginning of the strip. For next pixels the X coordinate increments sequentialy.
  y | The Y coordinate of the pixel strip. This is a constant across all pixels of the strip.
  pixels | A pointer to pixel data. It is the responsability of the function inserting the callback into the chain to provide a callback operating with the correct pixel format.
  comp_role | The role of every pixel component. This is a bitfield, made by one of the LF_CR_X macros which defines the roles of every pixel field. For example, LF_CR_4(RED,GREEN,BLUE,UNKNOWN) will define a RGBA (or RGBX) pixel format, and the UNKNOWN field will not be modified.
  count | Number of pixels to process.

## ◆ lfModifyCoordFunc

typedef void(* lfModifyCoordFunc) (void *data, float *iocoord, int count)

A callback function which modifies the coordinates of a strip of pixels.

This kind of callbacks are used in third stage of image modification.

Parameters

  data | A opaque pointer to some data.
  iocoord | A pointer to an array count pixel coordinates (X,Y). The function must replace the coordinates with their new values.
  count | Number of coordinate groups to handle.

## ◆ lfSubpixelCoordFunc

typedef void(* lfSubpixelCoordFunc) (void *data, float *iocoord, int count)

A callback function which modifies the separate coordinates for all color components for every pixel in a strip.

This kind of callbacks are used in the second stage of image modification.

Parameters

  data | A opaque pointer to some data.
  iocoord | A pointer to an array of count*3 pixel coordinates (X,Y). The first coordinate pair is for the R component, second for G and third for B of same pixel. There are count*2*3 floats total in this array.
  count | Number of coordinate groups to handle.

## Enumeration Type Documentation

## ◆ anonymous enum

anonymous enum

A list of bitmask flags used for ordering various image corrections.

Enumerator
LF_MODIFY_TCA | Correct (or apply) lens transversal chromatic aberrations
LF_MODIFY_VIGNETTING | Correct (or apply) lens vignetting
LF_MODIFY_DISTORTION | Correct (or apply) lens distortion
LF_MODIFY_GEOMETRY | Convert image geometry
LF_MODIFY_SCALE | Additional resize of image
LF_MODIFY_ALL | Apply all possible corrections

## ◆ lfComponentRole

enum lfComponentRole

These constants define the role of every pixel component, four bits each. "pixel" refers here to a set of values which share the same (x, y) coordinates.

Enumerator
LF_CR_END | This marks the end of the role list. It doesn't have to be specified explicitly, since LF_CR_X macros always pad the value with zeros
LF_CR_NEXT | This value tells that what follows applies to next pixel. This can be used to define Bayer images, e.g. use LF_CR_3(LF_CR_RED, LF_CR_NEXT, LF_CR_GREEN) for even rows and LF_CR_3(LF_CR_GREEN, LF_CR_NEXT, LF_CR_BLUE) for odd rows.
LF_CR_UNKNOWN | This component has an unknown/doesn't matter role
LF_CR_INTENSITY | This is the pixel intensity (grayscale)
LF_CR_RED | This is the Red pixel component
LF_CR_GREEN | This is the Green pixel component
LF_CR_BLUE | This is the Blue pixel component

## ◆ lfPixelFormat

enum lfPixelFormat

A list of pixel formats supported by internal colour callbacks.

Enumerator
LF_PF_U8 | Unsigned 8-bit R,G,B
LF_PF_U16 | Unsigned 16-bit R,G,B
LF_PF_U32 | Unsigned 32-bit R,G,B
LF_PF_F32 | 32-bit floating-point R,G,B
LF_PF_F64 | 64-bit floating-point R,G,B

## Function Documentation

## ◆ lf_modifier_add_color_callback()

void lf_modifier_add_color_callback | ( | lfModifier * | modifier,
|  | lfModifyColorFunc | callback,
|  | int | priority,
|  | void * | data,
|  | size_t | data_size )

See also
  lfModifier::AddColorCallback

## ◆ lf_modifier_add_color_callback_vignetting()

cbool lf_modifier_add_color_callback_vignetting | ( | lfModifier * | modifier,
|  | lfLensCalibVignetting * | model,
|  | lfPixelFormat | format,
|  | cbool | reverse )

See also
  lfModifier::AddColorCallbackVignetting

## ◆ lf_modifier_add_coord_callback()

void lf_modifier_add_coord_callback | ( | lfModifier * | modifier,
|  | lfModifyCoordFunc | callback,
|  | int | priority,
|  | void * | data,
|  | size_t | data_size )

See also
  lfModifier::AddCoordCallback

## ◆ lf_modifier_add_coord_callback_distortion()

cbool lf_modifier_add_coord_callback_distortion | ( | lfModifier * | modifier,
|  | lfLensCalibDistortion * | model,
|  | cbool | reverse )

See also
  lfModifier::AddCoordCallbackDistortion

## ◆ lf_modifier_add_coord_callback_geometry()

cbool lf_modifier_add_coord_callback_geometry | ( | lfModifier * | modifier,
|  | lfLensType | from,
|  | lfLensType | to,
|  | float | focal )

See also
  lfModifier::AddCoordCallbackGeometry

## ◆ lf_modifier_add_coord_callback_scale()

cbool lf_modifier_add_coord_callback_scale | ( | lfModifier * | modifier,
|  | float | scale,
|  | cbool | reverse )

See also
  lfModifier::AddCoordCallbackScale

## ◆ lf_modifier_add_subpixel_callback()

void lf_modifier_add_subpixel_callback | ( | lfModifier * | modifier,
|  | lfSubpixelCoordFunc | callback,
|  | int | priority,
|  | void * | data,
|  | size_t | data_size )

See also
  lfModifier::AddSubpixelCallback

## ◆ lf_modifier_add_subpixel_callback_TCA()

cbool lf_modifier_add_subpixel_callback_TCA | ( | lfModifier * | modifier,
|  | lfLensCalibTCA * | model,
|  | cbool | reverse )

See also
  lfModifier::AddSubpixelCallbackTCA

## ◆ lf_modifier_apply_color_modification()

cbool lf_modifier_apply_color_modification | ( | lfModifier * | modifier,
|  | void * | pixels,
|  | float | x,
|  | float | y,
|  | int | width,
|  | int | height,
|  | int | comp_role,
|  | int | row_stride )

See also
  lfModifier::ApplyColorModification

## ◆ lf_modifier_apply_geometry_distortion()

cbool lf_modifier_apply_geometry_distortion | ( | lfModifier * | modifier,
|  | float | xu,
|  | float | yu,
|  | int | width,
|  | int | height,
|  | float * | res )

See also
  lfModifier::ApplyGeometryDistortion

## ◆ lf_modifier_apply_subpixel_distortion()

cbool lf_modifier_apply_subpixel_distortion | ( | lfModifier * | modifier,
|  | float | xu,
|  | float | yu,
|  | int | width,
|  | int | height,
|  | float * | res )

See also
  lfModifier::ApplySubpixelDistortion

## ◆ lf_modifier_apply_subpixel_geometry_distortion()

cbool lf_modifier_apply_subpixel_geometry_distortion | ( | lfModifier * | modifier,
|  | float | xu,
|  | float | yu,
|  | int | width,
|  | int | height,
|  | float * | res )

See also
  lfModifier::ApplySubpixelGeometryDistortion

## ◆ lf_modifier_destroy()

void lf_modifier_destroy | ( | lfModifier * | modifier | ) |

See also
  lfModifier::Destroy

## ◆ lf_modifier_get_auto_scale()

float lf_modifier_get_auto_scale | ( | lfModifier * | modifier,
|  | cbool | reverse )

See also
  lfModifier::GetAutoScale

## ◆ lf_modifier_initialize()

int lf_modifier_initialize | ( | lfModifier * | modifier,
|  | const lfLens * | lens,
|  | lfPixelFormat | format,
|  | float | focal,
|  | float | aperture,
|  | float | distance,
|  | float | scale,
|  | lfLensType | targeom,
|  | int | flags,
|  | cbool | reverse )

See also
  lfModifier::Initialize

## ◆ lf_modifier_new()

lfModifier * lf_modifier_new | ( | const lfLens * | lens,
|  | float | crop,
|  | int | width,
|  | int | height )

See also
  lfModifier::Create