Structural Informatics Group (SIG) logo
Home | Projects | Demos | Downloads | Publications | Local Info | About Us | New site
Go to the first, previous, next, last section, table of contents.

:RESIZE-RELATION

source files: xzum.[ch]

SYNTAX

(require "xg.3d.imageops-xzum")

(send <src-grl> :RESIZE-RELATION
    [ :X-SRC-LOC <fix:x-src-loc> ]
    [ :Y-SRC-LOC <fix:y-src-loc> ]
    [ :X-SRC-SIZ <fix:x-src-siz> ]
    [ :Y-SRC-SIZ <fix:y-src-siz> ]

    [ :X-DST-LOC <fix:x-dst-loc> ]
    [ :Y-DST-LOC <fix:y-dst-loc> ]
    [ :X-DST-SIZ <fix:x-dst-siz> ]
    [ :Y-DST-SIZ <fix:y-dst-siz> ]

    [ :SCALE <fix-or-flo:scaling> ]
    [ :FILTER-SHAPE { :IMPULSE | :BOX | :TRIANGLE | :QUADRATIC | :MITCHELL } ]
    [ :BLUR-FACTOR <flo:blur-factor> ]
    [ :RESULT-IN <dst-grl> ]
)

DESCRIPTION

This call copies a two-dimensional rectangle from <src-grl> to <dst-grl>. If no <dst-grl> is provided, or if it is the wrong shape, a new one will be created. If <src-grl> contains arrays not present in <dst-grl>, or if the arrays present are of different type than the matching ones in <src-grl>, new arrays will be inserted. Any <dst-grl> arrays not present in <src-grl> will be ignored.

The <src-grl> relation must be two-dimensional, and must contain only CLASS-UNIT-FLOAT-ARRAY and CLASS-FLOAT-ARRAY arrays. (It would be perfectly reasonable to support other types, but I haven't had the time or incentive to write the code to do this.)

In general, the source and destination rectangles will be different sizes, since the main design purpose of this message is to resize an image.

Currently, the source and destination relations must be distinct.

By default, the complete src image is resized to exactly fit the dst relation, but the {X|Y}-{SRC|DST@}-{LOC|SIZ@} keywords may be used to copy any subrectangle of the src to any subrectangle of the dst. The *LOC* keywords specify the lower-left corner of the subrectangle, and the *SIZ* keywords the x and y dimensions in pixels of the subrectangles.

Alternatively, the :scale parameter may be provided, specifying the factor by which the relation should be scaled -- 0.9 to shrink by ten percent, for example.

The :FILTER-SHAPE governs the sort of interpolation/convolution used to select the value for each output pixel, and defaults to :TRIANGLE.

The filters are listed roughly in order of increasing quality and computation time.

The :IMPULSE 'filter' simply copies the geometrically closest input pixel to output, which produces severe pixellation effect ('jaggies') when magnifying an image, but which *does* have the virtue of being about ten times faster than the remaining filters.

The :BOX filter samples a neighborhood of the input image using a (2-D) square-wave weighting function, while the :TRIANGLE filter uses a triangular-peaked weighting function.

The :QUADRATIC and :MITCHELL filters provide still better approximations to the ideal (?) Gaussian weighting function, at the cost of about twice the computation time of the :BOX and :TRIANGLE filters.

The :MITCHELL filter is based on Mitchell&Netravali, "Reconstruction Filters in Computer Graphics", SIGGRAPH 88.

The :BLUR-FACTOR defaults to 1.0. It allows the user explicit control of the neighborhood size used to compute each output pixel: setting this parameter larger will produce a steadily blurrier image. The default :blur-factor 1.0 neighborhoods include the nearest neighbor pixels for :BOX and :TRIANGLE, and extend twice as far for :QUADRATIC and :MITCHELL.


Go to the first, previous, next, last section, table of contents.