PDL::Graphics2D (3)
Leading comments
Automatically generated by Pod::Man 4.09 (Pod::Simple 3.35) Standard preamble: ========================================================================
NAME
PDL::Graphics2D - An object oriented interface to PDL graphicsSYNOPSIS
use PDL::Graphics2D; $win = PDL::Graphics2D->new(<Interface>, <Options>); $w = imag2d( $image, 'Title Here', ... );
DESCRIPTION
This is an umbrella class allowing for a simple interface to all plotting routines inThis requires a lot more work before it is useful I feel, but it can be used already.
CONSTRUCTORS
new
Create a 2-D graphics object with the requested interface typeFUNCTIONS
imag2d
Display a 2-D image in a figure windowimag2d() creates a plain FreeGLUT OpenGL window and displays the input image with 1:1 aspect ratio for pixels. The window resize is constrained to the actual ratio of the image dimensions. The initial display size is currently a 200x200 window to prevent things from being too small by default.
The image to display can have dimensions ($c,$M,$N) where for $c==4 the display is in
This routine does not yet thread but multiple images may be viewed at the same time in separate windows by multiple calls to imag2d(). TriD graphics visualization windows and the imag2d() windows may be created and used independently.
$window_id = imag2d($image, $name, $zoom, $x_off, $y_off); creates a new image figure window from the input piddle with the given title, zoom factor, and position (if possible) $window_id - may be used to refer to the figure window $image - 2D image piddle with at least 2 or 3 dimensions e.g. [M,N], [1,M,N], [2,M,N], [3,M,N], [4,M,N] $name - the name to use for the figure window (optional) $zoom - desired (float) pixel zoom factor (optional) ($x_off, $y_off) - desired window pixel position (optional) with (0,0) as the top left pixel of the display
use PDL::Graphics2D; # imports imag2d() and twiddle() $a = sequence(64,48,3); # make test RGB image $a = $a->mv(2,0); # color must be dim(0) with size [0..4] $a /= $a->max; # pixel values in [0.0,1.0] $a = sin(10*$a); $w1 = imag2d($a); # with parens... $w2 = imag2d $a->sqrt; # or without $w3 = imag2d $a**2;
imag2d_update
Update an existing imag2d window with new piddle data
$image = random(3,64,48)/2 + 0.25; # random pixel image $win = imag2d($image); # create original image display imag2d_update($win, $image->sequence/$image->nelem); # update data
"imag2d_update" allows one to update an "imag2d" display window by replacing the associated image data with new contents. The new image data must be the same type and shape as the previous.
Eventually, we would like to implement this via some sort of dataflow that would be transparent to the user.
twiddle
Enable
twiddle(); # same as twiddle(undef) Runs the FreeGLUT event loop so window GUI operations such as resize, expose, mouse click,.. work twiddle(0); # disables twiddle looping for next twiddle() call twiddle(1); # re-enables default twiddle looping for next twiddle() call