Binary Image Library
Macros | Functions
C:/Users/Malcolm/Documents/temp/binaryimagelibrary/rotatebyshear.c File Reference
#include <stdlib.h>
#include <math.h>
#include <assert.h>

Macros

#define PI   3.1415926535897932384626433832795
 

Functions

int rotatebyshear (unsigned char *binary, int width, int height, double cx, double cy, double theta, unsigned char *out)
 

Detailed Description

Rotate by shear.

By Malcolm McLean

Rotate an image using the shearing method, which avoids sampling artifacts as preserves pixel values.

Part of the binary image processing library.

Function Documentation

int rotatebyshear ( unsigned char *  binary,
int  width,
int  height,
double  cx,
double  cy,
double  theta,
unsigned char *  out 
)

Rotate an image, using the shearing method.

Parameters
[in]binary- the binary or colour-indexed image
width- image width
height- image height
cx- centre x, y co-ordinates (pass in 1.5, 1.5 for the centre of a 3x3 image)
cy- centre x, y co-ordinates (pass in 1.5, 1.5 for the centre of a 3x3 image)
theta- angle to rotate by
out[out]- buffer for output (can't be the same as input)
Returns
: 0 for success
Note
conventional image rotation by the matrix method causes destination pixels to be sub-samples of source pixels. This isn't a problem with continous tone images where the new pixel values can be obtained by interpolation. However with binary or colour-index images, interpolation isn't possible. The shearing method preserves the pixels, at some cost in rotational accuracy.
maggie.jpg
Margaret Thatcher (1925-2013) greyscale photograph
maggierotshear.gif
Mrs Thatcher rotated
test.gif
Test card (256 colour-indexed)
testrotshear.gif
Test card rotated