File: plimage.m

package info (click to toggle)
plplot 5.14.0%2Bdfsg-3
  • links: PTS, VCS
  • area: main
  • in suites: buster
  • size: 30,424 kB
  • sloc: ansic: 79,613; xml: 28,583; cpp: 20,037; ada: 19,456; tcl: 12,081; f90: 11,423; ml: 7,276; java: 6,863; python: 6,792; sh: 3,185; perl: 828; lisp: 75; makefile: 48; sed: 33; fortran: 5
file content (69 lines) | stat: -rw-r--r-- 1,855 bytes parent folder | download | duplicates (6)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
## Copyright (C) 2000-2003 Joao Cardoso.
##
## This program is free software; you can redistribute it and/or modify it
## under the terms of the GNU General Public License as published by the
## Free Software Foundation; either version 2 of the License, or (at your
## option) any later version.
##
## This program is distributed in the hope that it will be useful, but
## WITHOUT ANY WARRANTY; without even the implied warranty of
## MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
## General Public License for more details.
##
## This file is part of plplot_octave.

## plimage(img, xi, xe, yi, ye)
##
## Plot an image, assuming that it is in octave image format, where each
##   matrix element is an index in the colormap.
##   if xi, xe, yi and ye exists, and are smaller than the image dimension
##   in pixels, than only that portion of the image will be shown.
##   No smoothing will be performed!
## Preliminary! see p17.m
##
## ex:
##   [img, map] = loadimage("default.img"); # "Chloe.img" can also be used
##   colormap(map);
##   plimage(img);

function plimage(img, x1, x2, y1, y2)

  global __pl
  strm = __pl_init;

  [nr, nc] = size(img);
  if (nargin == 1)
    xi = yi = 1.0;
    xf = nc;
    yf = nr;
  elseif (nargin == 5)
    if (x1 < 1 || x1 > nc || x2 < 1 || x2 > nc ||
	y1 < 1 || y1 > nr || y1 < 1 || y2 > nr)
      usage "plimage";
      return;
    else
      xi = min([x1, x2]);
      xf = max([x1, x2]);
      yi = min([y1, y2]);
      yf = max([y1, y2]);
    endif
  else
    usage "plimage";
    return;
  endif

  __pl_plenv(xi, xf, yi, yf, 1, -1);

  pplimage (fliplr(img'),
	    1.0, nc, 1.0, nr,
	    0.0, 0.0,
	    xi, xf, yi, yf);

  pllab(tdeblank(__pl.xlabel(strm,:)),
	tdeblank(__pl.ylabel(strm,:)),
	tdeblank(__pl.tlabel(strm,:)));
  plflush;pleop;

  __pl.items(strm) = 1; # for now!

endfunction