1Graphics2D(3)         User Contributed Perl Documentation        Graphics2D(3)
2
3
4

NAME

6       PDL::Graphics2D - An object oriented interface to PDL graphics
7

SYNOPSIS

9        use PDL::Graphics2D;
10        $win = PDL::Graphics2D->new(<Interface>, <Options>);
11
12        $w = imag2d( $image, 'Title Here', ... );
13

DESCRIPTION

15       This is an umbrella class allowing for a simple interface to all
16       plotting routines in PDL. On its own it does not do any work it merely
17       passes information to the appropriate class. Ideally this should
18       probably offer a uniform interface to a variety of packages.
19
20       This requires a lot more work before it is useful I feel, but it can be
21       used already.
22

CONSTRUCTORS

24   new
25       Create a 2-D graphics object with the requested interface type
26

FUNCTIONS

28   imag2d
29       Display a 2-D image in a figure window
30
31       imag2d() creates a plain FreeGLUT OpenGL window and displays the input
32       image with 1:1 aspect ratio for pixels.  The window resize is
33       constrained to the actual ratio of the image dimensions.  The initial
34       display size is currently a 200x200 window to prevent things from being
35       too small by default.
36
37       The image to display can have dimensions ($c,$M,$N) where for $c==4 the
38       display is in GL_RGBA, for $c==3 the display is GL_RGB, for $c==2 the
39       display is GL_LUMINANCE_ALPHA, and for $c==1 or for for dimensions
40       ($M,$N) then the display is GL_LUMINANCE.
41
42       This routine does not yet thread but multiple images may be viewed at
43       the same time in separate windows by multiple calls to imag2d().  TriD
44       graphics visualization windows and the imag2d() windows may be created
45       and used independently.
46
47       NOTE: If you are twiddling a TriD window, the imag2d() windows are
48       active as well.  If you call twiddle() the sub, only the imag2d()
49       windows will update correctly.
50
51         $window_id = imag2d($image, $name, $zoom, $x_off, $y_off);
52
53           creates a new image figure window from the input piddle
54           with the given title, zoom factor, and position (if possible)
55
56           $window_id - may be used to refer to the figure window
57
58           $image - 2D image piddle with at least 2 or 3 dimensions
59                    e.g. [M,N], [1,M,N], [2,M,N], [3,M,N], [4,M,N]
60
61           $name - the name to use for the figure window (optional)
62
63           $zoom - desired (float) pixel zoom factor     (optional)
64
65           ($x_off, $y_off) - desired window pixel position (optional)
66                              with (0,0) as the top left pixel of the
67                              display
68
69         use PDL::Graphics2D;     # imports imag2d() and twiddle()
70
71         $x = sequence(64,48,3);  # make test RGB image
72         $x = $x->mv(2,0);        # color must be dim(0) with size [0..4]
73         $x /= $x->max;           # pixel values in [0.0,1.0]
74         $x = sin(10*$x);
75         $w1 = imag2d($x);        # with parens...
76         $w2 = imag2d $x->sqrt;   # or without
77         $w3 = imag2d $x**2;
78
79   imag2d_update
80       Update an existing imag2d window with new piddle data
81
82         $image = random(3,64,48)/2 + 0.25;  # random pixel image
83         $win = imag2d($image);              # create original image display
84
85         imag2d_update($win, $image->sequence/$image->nelem);  # update data
86
87       "imag2d_update" allows one to update an "imag2d" display window by
88       replacing the associated image data with new contents.  The new image
89       data must be the same type and shape as the previous.
90
91       Eventually, we would like to implement this via some sort of dataflow
92       that would be transparent to the user.
93
94   twiddle
95       Enable GUI interaction with a FreeGLUT display window.  With an
96       argument, it sets the default value for the auto-twiddling state.  0
97       will disable the automatic twiddling and  1 , or true, will enable
98       twiddling.
99
100         twiddle();     # same as twiddle(undef)
101
102           Runs the FreeGLUT event loop so window GUI operations
103           such as resize, expose, mouse click,.. work
104
105         twiddle(0);  # disables twiddle looping for next twiddle() call
106         twiddle(1);  # re-enables default twiddle looping for next twiddle() call
107
108
109
110perl v5.32.0                      2020-09-17                     Graphics2D(3)
Impressum