BLOCKS Monash Image Library BLOCKS
These functions allow indirect access to a block or region of another image
(called the parent). Indirect blocks are useful with cut and ipaste
operations and with transforms which operate on small rectangular blocks of
pixels (such as morphological transforms and in compression modelling).
For i_mkblock, a new image IMAGE structure is created and its scanline
buffers are set to point directly into those of the parent image. Pixel
addressing in an indirect block is relatibe to the origin in the parent
image. There are restrictions on certain functions in the library when
dealing with indirect blocks, mainly those that affect the size and/or bits
per pixel of an image.
i_mvblock will adjust the scanline buffer pointers in block so they point to
a new region in the parent image. A pointer to the parent of the existing
block is not required because the address of the parent is saved in the
IMAGE structure when the block is first created.
The following example function demonstrates the use of indirect blocks. The
mean of each 2 by 2 block is used to implement a shear transformation:
#include "image.h"
IMAGE *i_half(IMAGE *image)
{
register int row, col, pix;
IMAGE *result, *block;
/*
* Create an indirect block of size 2 by 2
*/
block = i_mkblock(image, 0, 0, 2, 2);
/*
* Resulting image has half the height, half the width, and the same bpp
*/
result = i_mktemp(image->rows/2, image->cols/2, image->bitsperpixel);
for (row=0; row < image->rows-1; row+=2)
for (col=0; col < image->cols-1; col+=2)
{
/*
* Move the origin of the block
*/
i_mvblock(block,row,col);
pix = i_getpix(block,0,0) + i_getpix(block,0,1) +
i_getpix(block,1,0) + i_getpix(block,1,1,);
i_putpix(result,row/2, col/2, pix/4);
}
/*
* Close the block and return the result image
*/
i_close(block);
return result;
}
| imkblock | create indirect sub-image |
| imvblock | move the origin of indirect sub-image |
index | userguide | full | arithmetic | basic | binary | blocks | colour | compress | display | docs | fft | hist | image | io | makefile | masks | memory | misc | morph | pixel | rgb | stats | transform | error | mapping