Leptonica  1.82.0
Image processing and image analysis suite
rotateorth.c File Reference
#include <string.h>
#include "allheaders.h"

Go to the source code of this file.

Functions

static l_uint8 * makeReverseByteTab1 (void)
 
static l_uint8 * makeReverseByteTab2 (void)
 
static l_uint8 * makeReverseByteTab4 (void)
 
PIXpixRotateOrth (PIX *pixs, l_int32 quads)
 
PIXpixRotate180 (PIX *pixd, PIX *pixs)
 
PIXpixRotate90 (PIX *pixs, l_int32 direction)
 
PIXpixFlipLR (PIX *pixd, PIX *pixs)
 
PIXpixFlipTB (PIX *pixd, PIX *pixs)
 

Detailed Description

     Top-level rotation by multiples of 90 degrees
           PIX             *pixRotateOrth()
     180-degree rotation
           PIX             *pixRotate180()
     90-degree rotation (both directions)
           PIX             *pixRotate90()
     Left-right flip
           PIX             *pixFlipLR()
     Top-bottom flip
           PIX             *pixFlipTB()
     Byte reverse tables
           static l_uint8  *makeReverseByteTab1()
           static l_uint8  *makeReverseByteTab2()
           static l_uint8  *makeReverseByteTab4()

Definition in file rotateorth.c.

Function Documentation

◆ makeReverseByteTab1()

static l_uint8 * makeReverseByteTab1 ( void  )
static

makeReverseByteTab1()

Notes: (1) This generates an 8 bit lookup table for reversing the order of eight 1-bit pixels.

Definition at line 656 of file rotateorth.c.

◆ makeReverseByteTab2()

static l_uint8 * makeReverseByteTab2 ( void  )
static

makeReverseByteTab2()

Notes: (1) This generates an 8 bit lookup table for reversing the order of four 2-bit pixels.

Definition at line 683 of file rotateorth.c.

◆ makeReverseByteTab4()

static l_uint8 * makeReverseByteTab4 ( void  )
static

makeReverseByteTab4()

Notes: (1) This generates an 8 bit lookup table for reversing the order of two 4-bit pixels.

Definition at line 706 of file rotateorth.c.

◆ pixFlipLR()

PIX* pixFlipLR ( PIX pixd,
PIX pixs 
)

pixFlipLR()

Parameters
[in]pixd[optional]; can be null, equal to pixs, or different from pixs
[in]pixsall depths
Returns
pixd, or NULL on error
Notes:
     (1) This does a left-right flip of the image, which is
         equivalent to a rotation out of the plane about a
         vertical line through the image center.
     (2) There are 3 cases for input:
         (a) pixd == null (creates a new pixd)
         (b) pixd == pixs (in-place operation)
         (c) pixd != pixs (existing pixd)
     (3) For clarity, use these three patterns, respectively:
         (a) pixd = pixFlipLR(NULL, pixs);
         (b) pixFlipLR(pixs, pixs);
         (c) pixFlipLR(pixd, pixs);
     (4) If an existing pixd is not the same size as pixs, the
         image data will be reallocated.
     (5) The pixel access routines allow a trivial implementation.
         However, for d < 8, it is more efficient to right-justify
         each line to a 32-bit boundary and then extract bytes and
         do pixel reversing.   In those cases, as in the 180 degree
         rotation, we right-shift the data (if necessary) to
         right-justify on the 32 bit boundary, and then read the
         bytes off each raster line in reverse order, reversing
         the pixels in each byte using a table.  These functions
         for 1, 2 and 4 bpp were tested against the "trivial"
         version (shown here for 4 bpp):
             for (i = 0; i < h; i++) {
                 line = data + i * wpl;
                 memcpy(buffer, line, bpl);
                   for (j = 0; j < w; j++) {
                     val = GET_DATA_QBIT(buffer, w - 1 - j);
                       SET_DATA_QBIT(line, j, val);
                 }
             }

Definition at line 427 of file rotateorth.c.

References pixCopy(), pixGetData(), and pixGetDimensions().

Referenced by pixMirroredTiling().

◆ pixFlipTB()

PIX* pixFlipTB ( PIX pixd,
PIX pixs 
)

pixFlipTB()

Parameters
[in]pixd[optional]; can be null, equal to pixs, or different from pixs
[in]pixsall depths
Returns
pixd, or NULL on error
Notes:
     (1) This does a top-bottom flip of the image, which is
         equivalent to a rotation out of the plane about a
         horizontal line through the image center.
     (2) There are 3 cases for input:
         (a) pixd == null (creates a new pixd)
         (b) pixd == pixs (in-place operation)
         (c) pixd != pixs (existing pixd)
     (3) For clarity, use these three patterns, respectively:
         (a) pixd = pixFlipTB(NULL, pixs);
         (b) pixFlipTB(pixs, pixs);
         (c) pixFlipTB(pixd, pixs);
     (4) If an existing pixd is not the same size as pixs, the
         image data will be reallocated.
     (5) This is simple and fast.  We use the memcpy function
         to do all the work on aligned data, regardless of pixel
         depth.

Definition at line 605 of file rotateorth.c.

References pixCopy(), pixGetData(), and pixGetDimensions().

Referenced by pixMirroredTiling().

◆ pixRotate180()

PIX* pixRotate180 ( PIX pixd,
PIX pixs 
)

pixRotate180()

Parameters
[in]pixd[optional]; can be null, equal to pixs, or different from pixs
[in]pixsall depths
Returns
pixd, or NULL on error
Notes:
     (1) This does a 180 rotation of the image about the center,
         which is equivalent to a left-right flip about a vertical
         line through the image center, followed by a top-bottom
         flip about a horizontal line through the image center.
     (2) There are 3 cases for input:
         (a) pixd == null (creates a new pixd)
         (b) pixd == pixs (in-place operation)
         (c) pixd != pixs (existing pixd)
     (3) For clarity, use these three patterns, respectively:
         (a) pixd = pixRotate180(NULL, pixs);
         (b) pixRotate180(pixs, pixs);
         (c) pixRotate180(pixd, pixs);

Definition at line 124 of file rotateorth.c.

Referenced by pixRotateOrth().

◆ pixRotate90()

PIX* pixRotate90 ( PIX pixs,
l_int32  direction 
)

pixRotate90()

Parameters
[in]pixsall depths
[in]directionclockwise = 1, counterclockwise = -1
Returns
pixd, or NULL on error
Notes:
     (1) This does a 90 degree rotation of the image about the center,
         either cw or ccw, returning a new pix.
     (2) The direction must be either 1 (cw) or -1 (ccw).

Definition at line 166 of file rotateorth.c.

References pixCopyColormap(), pixCreate(), and pixGetDimensions().

Referenced by pixDecideIfTable(), and pixRotateOrth().

◆ pixRotateOrth()

PIX* pixRotateOrth ( PIX pixs,
l_int32  quads 
)

pixRotateOrth()

Parameters
[in]pixsall depths
[in]quads0-3; number of 90 degree cw rotations
Returns
pixd, or NULL on error

Definition at line 75 of file rotateorth.c.

References pixCopy(), pixRotate180(), and pixRotate90().

Referenced by dewarpFindVertDisparity(), and pixaRotateOrth().