28.1.4 Viewing images
Starting from Xcas version 1.9.0, image objects are viewed by using
the display
command. The legacy Xcas image structure can be visualized by exporting
it to a file by using the writergb command (see Section 28.1.5).
-
display takes one mandatory arguments and one optional argument:
-
img, an image object.
- Optionally, either a,b, a pair of real numbers, or a+ib,
a complex number (by default, a=b=0).
- display(img ⟨,a,b ⟩)
or display(img ⟨,a+ib ⟩)
returns a graphic object showing img with (a,b) corresponding to its
lower-left corner. The axes are automatically hidden and the view
is orthonormalized in order to preserve the original aspect ratio of the image.
In the examples that follow, we assume that the current directory in Xcas
is changed (by using the cd command, see Section 4.2.1)
to /usr/local/share/giac/examples in Linux resp. to
C:\xcaswin\examples in Windows.
Example
img:=image("Exemples/demo/terre.jpg") |
|
an image of size 512×256 (RGB)
| | | | | | | | | | |
|
Multiple images can be shown together by calling display several times
within a single command line (delimited by ;) and adjusting a and b
to appropriate values in each call. If desired, individual image captions can be
inserted by using the legend command
(See Section 21.4.10 for an example.) There is also a possibility
of combining images with other graphical objects.
display(img);
legend(285+125i,"Africa",color=gold); legend(270+200i,"Europe",color=gold);
legend(380+190i,"Asia",color=yellow); legend(430+90i,"Australia",color=yellow);
legend(100+190i,"North America",color=gold); legend(160+80i,"South America",color=gold); |
Viewing images as textures.
Xcas can also display image files in rectangles in
2D or on surfaces in 3D with the
gl_texture
property of the object (see Section 19.1.2). This
procedure does not use image objects, but reads images
from disk.
Examples
rectangle(0,200,1/2,gl_texture="Exemples/demo/terre.jpg") |
sphere([0,0,0],1,gl_material=[gl_texture,"Exemples/demo/terre.jpg"]) |