VCLib Documentation  6.12.2

Per Pixel Mappings

Per Pixel Mappings

Functions

I32 copy (image *a, image *b)
 Copy an Image Variable. More...
 
I32 copy_with_bitmask (image *src, image *dst, U32 mask)
 Copies an Image: Only those Bits where Mask bits are set to One. More...
 
I32 merge_with_bitmask (image *src0, image *src1, image *dst, U32 mask)
 Combines an Image out of two others using a bit mask selector. More...
 
void bin0 (image *src, image *dest, I32 thr, I32 bl, I32 wt, void(*fc)())
 Fast Binarization of an Image Variable. More...
 
void img2 (image *a, image *b, image *c, void(*func)(), I32 q)
 Link Two Image Variables. More...
 
I32 equalize (image *src, image *dst)
 Equalize Image. More...
 
I32 look (image *a, image *b, U32 table[])
 Look-up Table Function. More...
 
I32 lookfalse (image *src, image *dst, U8 red[], U8 grn[], U8 blu[])
 False Color Look-up Table Function. More...
 
void SetFalseColorLUT (U8 *red, U8 *grn, U8 *blu)
 Writes False Color Look-up Table. More...
 
#define add2(a, b, c, sh)   img2(a, b, c, (void (*)())FL_add2f, sh)
 Pixelwise Sum of Two Images (Macro). More...
 
#define sub2(a, b, c)   img2(a, b, c, (void (*)())FL_sub2f, 0)
 Pixelwise Absolute Difference of Two Images (Macro). More...
 
#define subx2(a, b, c, offs)   img2(a, b, c, (void (*)())FL_sub2x, offs)
 Pixelwise Difference of Two Images with Clipping (Macro). More...
 
#define suby2(a, b, c)   img2(a, b, c, (void (*)())FL_sub2y, 0)
 Pixelwise Sign of Two Images (Macro). More...
 
#define mul2(a, b, c, sh)   img2(a, b, c, (void (*)())FL_mul2f, sh)
 Pixelwise Product of Two Images (Macro). More...
 
#define max2(a, b, c)   img2(a, b, c, (void (*)())FL_max2f, 0)
 Pixelwise Maximum of Two Images (Macro). More...
 
#define min2(a, b, c)   img2(a, b, c, (void (*)())FL_min2f, 0)
 Pixelwise Minimum of Two Images (Macro). More...
 
#define and2(a, b, c)   img2(a, b, c, (void (*)())FL_and2f, 0)
 Pixelwise AND of Two Images (Macro). More...
 
#define or2(a, b, c)   img2(a, b, c, (void (*)())FL_or2f, 0)
 Pixelwise OR of Two Images (Macro). More...
 
#define xor2(a, b, c)   img2(a, b, c, (void (*)())FL_xor2f, 0)
 Pixelwise XOR of Two Images (Macro). More...
 
#define binarize(s, d, t, b, w)   bin0(s, d, t, b, w, (void (*)())FL_SetBin_U8P_U8P)
 Binarizes the Image. More...
 
#define PaintWhite(s, d, t, w)   bin0(s, d, t, w, 0, (void (*)())FL_SetIfGE_U8P_U8P)
 Fills Pixel greater or equal than a Threshold with a Color. More...
 
#define PaintBlack(s, d, t, b)   bin0(s, d, t, b, 0, (void (*)())FL_SetIfLT_U8P_U8P)
 Fills Pixel smaller than a Threshold with a Color. More...
 
#define AND_image(s, d, c)   bin0(s, d, c, 0, 0, (void (*)())FL_AND_I8P_I8)
 AND's Image Pixel Values with a Constant Value. More...
 
#define OR_image(s, d, c)   bin0(s, d, c, 0, 0, (void (*)())FL_OR_I8P_I8)
 OR's Image Pixel Values with a Constant Value. More...
 

Detailed Description

Functions in this group use only the input data at the same pixel position as the output, for example functions which add two image's grey values, or do an image binarisation.

Functions which output geometrc transformations of the input image can be found at pixelImageTransformation

Macro Definition Documentation

◆ binarize

#define binarize (   s,
  d,
  t,
  b,
 
)    bin0(s, d, t, b, w, (void (*)())FL_SetBin_U8P_U8P)

This Macro binarizes the given image, this means, if the pixel value is < t, the resulting pixel will have the value given by b, otherwise the value will be w.

Parameters
sSource Image.
dDestination Image.
tThreshold.
bGrey Value for 'Black' Color.
wGrey Value for 'Brighter than or Equals Threshold' Color.

binarize() is a macro which calls bin0() with basic function FL_SetBin_U8P_U8P() as an argument.

◆ PaintWhite

#define PaintWhite (   s,
  d,
  t,
 
)    bin0(s, d, t, w, 0, (void (*)())FL_SetIfGE_U8P_U8P)

This Macro sets pixel brighter than the threshold to a new color, i.e. if the pixel value is < t, the pixel value is not changed, otherwise the value will be w.

Parameters
sSource Image.
dDestination Image.
tThreshold.
wGrey Value for 'Brighter than or Equals Threshold' Color.

PaintWhite() is a macro which calls bin0() with basic function FL_SetIfGE_U8P_U8P() as an argument.

◆ PaintBlack

#define PaintBlack (   s,
  d,
  t,
 
)    bin0(s, d, t, b, 0, (void (*)())FL_SetIfLT_U8P_U8P)

This Macro sets pixel darker than the threshold grey value to a new color, i.e. if the pixel value is < t, the resulting pixel will have the value specified by b, otherwise the value will not be changed.

Parameters
sSource Image.
dDestination Image.
tThreshold.
bGrey Value for 'Darker than Threshold' Color.

PaintBlack() is a macro which calls bin0() with basic function FL_SetIfLT_U8P_U8P() as an argument.

◆ AND_image

#define AND_image (   s,
  d,
 
)    bin0(s, d, c, 0, 0, (void (*)())FL_AND_I8P_I8)

This Macro ANDs each pixel of the image provided by the constant value c.

Parameters
sSource Image.
dDestination Image.
cConstant for ANDing.

AND_image() is a macro which calls bin0() with basic function FL_AND_I8P_I8() as an argument.

◆ OR_image

#define OR_image (   s,
  d,
 
)    bin0(s, d, c, 0, 0, (void (*)())FL_OR_I8P_I8)

This Macro ORs each pixel of the image provided by the constant value c.

Parameters
sSource Image.
dDestination Image.
cConstant for ORing.

OR_image() is a macro which calls bin0() with basic function FL_OR_I8P_I8() as an argument.

◆ add2

#define add2 (   a,
  b,
  c,
  sh 
)    img2(a, b, c, (void (*)())FL_add2f, sh)

The macro calculates the pixelwise sum of two images. You can additionally change a shift value from no shift (= 0) to the desired shift value. The sign of the shift value provides the direction of the shift, e.g. sh == 1 means sizing up values by multiplication with 2 (one shift operation step to the left), sh == -2 divides the result values by 4 (shifts right for two steps). As formula:

\[ px_{\tt c} = \left\{ \matrix { (px_{\tt a} + px_{\tt b})<<|{\tt sh}|,& \quad {\tt sh} > 0 \cr (px_{\tt a} + px_{\tt b})\hphantom{<<|{\tt sh}|},& \quad {\tt sh} = 0 \cr (px_{\tt a} + px_{\tt b})>>|{\tt sh}|,& \quad {\tt sh} < 0 \cr } \right. \]

Any parameter may be identical to any other, e.g. a == c.

add2() is a macro which calls img2() with basic function FL_add2f() as an argument.

◆ sub2

#define sub2 (   a,
  b,
 
)    img2(a, b, c, (void (*)())FL_sub2f, 0)

The pixelwise absolute value of the difference of two images a and b is written to image c. As formula:

\[ px_{\tt c} = |px_{\tt a} - px_{\tt b}|. \]

Any parameter may be identical to any other, e.g. a == c.

sub2() is a macro which calls img2() with basic function FL_sub2f() as an argument.

◆ subx2

#define subx2 (   a,
  b,
  c,
  offs 
)    img2(a, b, c, (void (*)())FL_sub2x, offs)

The pixelwise value of the difference of two images a and b is written to image c after adding the offset offs. If the value underruns 0 or exceeds 255 the value will be set to that value. As formula:

\[ px_{\tt c} = \min(255,\max(0, (px_{\tt a} - px_{\tt b} + {\tt offs}) )). \]

Any parameter may be identical to any other, e.g. a == c.

subx2() is a macro which calls img2() with basic function FL_sub2x() as an argument.

◆ suby2

#define suby2 (   a,
  b,
 
)    img2(a, b, c, (void (*)())FL_sub2y, 0)

The pixelwise sign of the difference of two images a and b is encoded as 0 (bigger a) or 255 (bigger b) in image c. If both values are equal the result value is set to 0. As formula:

\[ px_{\tt c} = \left\{ \matrix { 255,& \quad px_{\tt a} > px_{\tt b} \cr 0,& \quad px_{\tt a} = px_{\tt b} \cr 0,& \quad px_{\tt a} < px_{\tt b} \cr } \right. \]

Any parameter may be identical to any other, e.g. a == c.

suby2() is a macro which calls img2() with basic function FL_sub2y() as an argument.

◆ mul2

#define mul2 (   a,
  b,
  c,
  sh 
)    img2(a, b, c, (void (*)())FL_mul2f, sh)

The macro calculates the pixelwise product of two images. You can additionally change a shift value from no shift (= 0) to the desired shift value. The sign of the shift value provides the direction of the shift, e.g. sh == 1 means sizing up values by multiplication with 2 (one shift operation step to the left), sh == -2 divides the result values by 4 (shifts right for two steps). As formula:

\[ px_{\tt c} = \left\{ \matrix { (px_{\tt a} * px_{\tt b})<<|{\tt sh}|,& \quad {\tt sh} > 0 \cr (px_{\tt a} * px_{\tt b})\hphantom{<<|{\tt sh}|},& \quad {\tt sh} = 0 \cr (px_{\tt a} * px_{\tt b})>>|{\tt sh}|,& \quad {\tt sh} < 0 \cr } \right. \]

Any parameter may be identical to any other, e.g. a == c.

mul2() is a macro which calls img2() with basic function FL_mul2f() as an argument.

◆ max2

#define max2 (   a,
  b,
 
)    img2(a, b, c, (void (*)())FL_max2f, 0)

The pixelwise maximum value of the two images a and b is written to image c. As formula:

\[ px_{\tt c} = \max(px_{\tt a}, px_{\tt b}). \]

Any parameter may be identical to any other, e.g. a == c.

max2() is a macro which calls img2() with basic function FL_max2f() as an argument.

◆ min2

#define min2 (   a,
  b,
 
)    img2(a, b, c, (void (*)())FL_min2f, 0)

The pixelwise minimum value of the two images a and b is written to image c. As formula:

\[ px_{\tt c} = \min(px_{\tt a}, px_{\tt b}). \]

Any parameter may be identical to any other, e.g. a == c.

min2() is a macro which calls img2() with basic function FL_min2f() as an argument.

◆ and2

#define and2 (   a,
  b,
 
)    img2(a, b, c, (void (*)())FL_and2f, 0)

The pixelwise logical AND value of the two images a and b is written to image c. As formula:

\[ px_{\tt c} = px_{\tt a} \textrm{ AND } px_{\tt b}. \]

Any parameter may be identical to any other, e.g. a == c.

and2() is a macro which calls img2() with basic function FL_and2f() as an argument.

◆ or2

#define or2 (   a,
  b,
 
)    img2(a, b, c, (void (*)())FL_or2f, 0)

The pixelwise logical OR value of the two images a and b is written to image c. As formula:

\[ px_{\tt c} = px_{\tt a} \textrm{ OR } px_{\tt b}. \]

Any parameter may be identical to any other, e.g. a == c.

or2() is a macro which calls img2() with basic function FL_or2f() as an argument.

◆ xor2

#define xor2 (   a,
  b,
 
)    img2(a, b, c, (void (*)())FL_xor2f, 0)

The pixelwise logical XOR value of the two images a and b is written to image c. As formula:

\[ px_{\tt c} = px_{\tt a} \textrm{ XOR } px_{\tt b}. \]

Any parameter may be identical to any other, e.g. a == c.

xor2() is a macro which calls img2() with basic function FL_xor2f() as an argument.

Function Documentation

◆ copy()

I32 copy ( image src,
image dst 
)

The function copies the contents of the image variable src to dst. If the format of the image variable (dx, dy) is not identical, the format of the result variable dst is used. In particular, this means that the result of the operation is not defined if the image format of src is smaller than that of dst. ( src->dx < dst->dx or src->dy < dst->dy). You are recommended to work with identical image formats, i.e. src->dx = dst->dx and src->dy = dst->dy.

It is possible to copy the contents of any type of image, e.g. color images with this function. In this case, the copy is performed only, if src and dst belong to the same storage classes, i.e. require the same amount of memory and the same number of bits per pixel. I.e. a copy from type = IMAGE_RGB to IMAGE_IHS is allowed, whereas a copy from IMAGE_GREY to IMAGE_RGB is not allowed. It is recommended to use images of the same type for src and dst.

The function returns the standard error code.

Memory Consumption
None.

◆ copy_with_bitmask()

I32 copy_with_bitmask ( image src,
image dst,
U32  mask 
)

The function copies the contents of the image variable src to dst. If the format of the image variable (dx, dy) is not identical, the format of the result variable dst is used. In particular, this means that the result of the operation is not defined if the image format of src is smaller than that of dst. ( src->dx < dst->dx or src->dy < dst->dy). You are recommended to work with identical image formats, i.e. src->dx = dst->dx and src->dy = dst->dy.

It is possible to copy the contents of any type of image, e.g. color images with this function. In this case, the copy is performed only, if src and dst belong to the same storage classes, i.e. require the same amount of memory and the same number of bits per pixel. I.e. a copy from type = IMAGE_RGB to IMAGE_IHS is allowed, whereas a copy from IMAGE_GREY to IMAGE_RGB is not allowed. It is recommended to use images of the same type for src and dst.

The mask bits define the bits which are overwritten (1) at the destination, others remain untouched (0).

The function returns the standard error code.

Note
only 8 bit images are supported so far.
Memory Consumption
None.

◆ merge_with_bitmask()

I32 merge_with_bitmask ( image src0,
image src1,
image dst,
U32  mask 
)

The function combines an image out of two others using a bit mask selector. If the format of the image variable (dx, dy) is not identical, the format of the result variable dst is used. In particular, this means that the result of the operation is not defined if the image format of src0 or src1 is smaller than that of dst. ( src?->dx < dst->dx or src?->dy < dst->dy). You are recommended to work with identical image formats, i.e. src?->dx = dst->dx and src?->dy = dst->dy.

It is possible to merge the contents of any type of image, e.g. color images with this function. In this case, the copy is performed only, if src0, src1, and dst belong to the same storage classes, i.e. require the same amount of memory and the same number of bits per pixel. I.e. a merge from type = IMAGE_RGB to IMAGE_IHS is allowed, whereas a copy from IMAGE_GREY to IMAGE_RGB is not allowed. It is recommended to use images of the same type for src0, src1, and dst.

The mask bits define the origin of the bits which are written to the destination, for each bit which is zero the bit comes from src0, for each bit which is one the bit comes from src1.

The function returns the standard error code.

Note
only 8 bit images are supported so far.
Memory Consumption
None.

◆ bin0()

void bin0 ( image src,
image dst,
I32  thr,
I32  blk,
I32  wht,
void(*)()  fc 
)

The function binarizes image src and writes the result to dst, which may be equal to src. thr is the threshold, blk the grey value for the display of binary 'black', wht the grey value for the display of binary 'white'. fc is a function pointer to the basic binarisation function.

The following macros use this function:

Call Operation Basic function
binarize(s, d, t, b, w) (pixel < t) ? b : w FL_SetBin_U8P_U8P()
PaintWhite(s, d, t, w) (pixel < t) ? nc : w FL_SetIfGE_U8P_U8P()
PaintBlack(s, d, t, b) (pixel < t) ? b : nc FL_SetIfLT_U8P_U8P()
OR_image(s, d, c) pixel OR c FL_OR_I8P_I8()

remark: nc means "not changed"

Of course, you can write your own basic binarisation functions. Pass their address (function pointer) to bin0().

Parameters
srcSource Image.
dstDestination Image.
thrThreshold.
blkGrey Value for 'black' color.
whtGrey Value for 'white' color.
fcBasic Function to perform Binarization.
Memory Consumption
None.
See also
look().

◆ img2()

void img2 ( image a,
image b,
image c,
void(*)()  func,
int  q 
)

The function makes it possible to calculate any links of the two image variables a and b. The result is stored in the image variable c, which can be identical with a or b or both. If the format of the image variables (dx, dy) is not identical for all three image variables, then the format of the result variable c is used. In particular, this means that the result of the operation is not defined if the image format of a or b is smaller than that of c. ( a->dx < c->dx or a->dy < c->dy or b->dx < c->dx or b->dy < c->dy). You are recommended to work with identical image formats, i.e. a->dx = b->dx = c->dx and a->dy = b->dy = c->dy. q is a parameter which is passed to the basic function func(). The nature of the link is specified by providing a pointer to the basic function to be executed. For the available basic functions there are macros (define instructions), which make it easier to call the function.

The following macros are available and documented:

Call Operation Basic function
add2(a,b,c,sh) c=(a+b)<<+/->>|sh| FL_add2f()
sub2(a,b,c) c = abs(a-b) FL_sub2f()
subx2(a,b,c,offs) c = clip(0,255,(a - b + offs)) FL_sub2x()
suby2(a,b,c) c = (a - b)>0 ? 255 : 0 FL_sub2y()
mul2(a,b,c,sh) c=(a*b)<<+/->>|sh| FL_mul2f()
max2(a,b,c) c = max(a,b) FL_max2f()
min2(a,b,c) c = min(a,b) FL_min2f()
and2(a,b,c) c = a AND b FL_and2f()
or2 (a,b,c) c = a OR b FL_or2f()
xor2(a,b,c) c = a XOR b FL_xor2f()

Of course, you can write your own basic functions. Pass their address (function pointer) to img2().

Parameters
aFirst Source Image.
bSecond Source Image.
cResult Image.
(*func)()Processing Function.
qOptional Parameter for Processing Function.
Memory Consumption
None.

◆ equalize()

I32 equalize ( image src,
image dst 
)

In some cases, a grey image does not cover the complete range of grey values from 0 to 255. With this function the range can be expanded to ease the human interpretation of the image on a computer screen. First, maximum and minimum grey levels are calculated in the search image. The range between maximum and minimum is then expanded to values between 0 and 255 using a lookup table.

Parameters
srcSource Image.
dstDestination Image.
Memory Consumption
None.
See also
look().
Return values
ERR_NONEon Success.

◆ look()

I32 look ( image src,
image dst,
U32  table[] 
)

The function transforms the image variable src with the aid of a look-up table function. The result of the operation is stored in image variable dst, which may be identical to src. table is the transformation table, which must have been created beforehand. If the format of the image variable (dx, dy) is not identical, the minimum of the formats of the image variables src and dst is used. For example, src->dx = min( src->dx, dst->dx). In particular, this means that the result of the operation is not defined if the image format of src is smaller than that of dst ( src->dx < dst->dx or src->dy < dst->dy).

A pixel with a value 0 <= x < 256 will be transformed into table[x].

The function returns the standard error code.

Parameters
srcSource Image.
dstDestination Image.
tableLookup Table with 256 Values.
Memory Consumption
None.

◆ lookfalse()

I32 lookfalse ( image src,
image dst,
U8  red[],
U8  grn[],
U8  blu[] 
)

The function transforms the image variable src with the aid of a false color look-up table function. The result of the operation is stored in image variable dst, which must be of type IMAGE_RGB. red, grn and blu are the transformation tables, which must have been created beforehand. If the format of the image variable (dx, dy) is not identical, the minimum of the formats of the image variables src and dst is used. For example, dx = min( src->dx, dst->dx). In particular, this means that the result of the operation is not defined if the image format of src is smaller than that of dst ( src->dx < dst->dx or src->dy < dst->dy).

A pixel with a value 0 <= x < 256 will be transformed into a pseudo color.

The function returns the standard error code.

Parameters
srcSource Image.
dstDestination Image.
redLookup Table with 256 Values for red channel.
grnLookup Table with 256 Values for green channel.
bluLookup Table with 256 Values for blu channel.
Memory Consumption
None.

◆ SetFalseColorLUT()

void SetFalseColorLUT ( U8 red,
U8 grn,
U8 blu 
)

The function writes a false color lookup table at provided arrays. red, grn, blu must at least have 256 entries.

A pixel with a value 0 <= x < 256 will be transformed into a pseudo color. The color change is as follows, starting at smallest value:

Black -> Red -> Yellow -> Green -> Cyan -> Blue -> Magenta.

Parameters
redLookup Table with 256 Values for red channel.
grnLookup Table with 256 Values for green channel.
bluLookup Table with 256 Values for blu channel.