annotate scripts/image/image.m @ 17281:bc924baa2c4e

doc: Add new @qcode macro for code samples which are quoted. Macro handles options ("on") or properties ("position") more elegantly than @code{"text"}. * doc/interpreter/macros.texi: Add new @qcode macro. * doc/interpreter/tips.txi: Add documentation about @qcode macro. * doc/interpreter/basics.txi, doc/interpreter/container.txi, doc/interpreter/emacs.txi, doc/interpreter/errors.txi, doc/interpreter/eval.txi, doc/interpreter/expr.txi, doc/interpreter/external.txi, doc/interpreter/func.txi, doc/interpreter/grammar.txi, doc/interpreter/image.txi, doc/interpreter/install.txi, doc/interpreter/interp.txi, doc/interpreter/io.txi, doc/interpreter/matrix.txi, doc/interpreter/numbers.txi, doc/interpreter/oop.txi, doc/interpreter/package.txi, doc/interpreter/plot.txi, doc/interpreter/quad.txi, doc/interpreter/sparse.txi, doc/interpreter/strings.txi, doc/interpreter/system.txi, doc/interpreter/vectorize.txi, libinterp/corefcn/balance.cc, libinterp/corefcn/bitfcns.cc, libinterp/corefcn/cellfun.cc, libinterp/corefcn/conv2.cc, libinterp/corefcn/data.cc, libinterp/corefcn/debug.cc, libinterp/corefcn/defaults.cc, libinterp/corefcn/dirfns.cc, libinterp/corefcn/dlmread.cc, libinterp/corefcn/error.cc, libinterp/corefcn/file-io.cc, libinterp/corefcn/find.cc, libinterp/corefcn/gammainc.cc, libinterp/corefcn/graphics.cc, libinterp/corefcn/help.cc, libinterp/corefcn/hex2num.cc, libinterp/corefcn/input.cc, libinterp/corefcn/load-path.cc, libinterp/corefcn/load-save.cc, libinterp/corefcn/ls-oct-ascii.cc, libinterp/corefcn/lu.cc, libinterp/corefcn/luinc.cc, libinterp/corefcn/matrix_type.cc, libinterp/corefcn/oct-hist.cc, libinterp/corefcn/pager.cc, libinterp/corefcn/pr-output.cc, libinterp/corefcn/pt-jit.cc, libinterp/corefcn/qz.cc, libinterp/corefcn/rand.cc, libinterp/corefcn/regexp.cc, libinterp/corefcn/schur.cc, libinterp/corefcn/sighandlers.cc, libinterp/corefcn/sparse.cc, libinterp/corefcn/spparms.cc, libinterp/corefcn/str2double.cc, libinterp/corefcn/svd.cc, libinterp/corefcn/symtab.cc, libinterp/corefcn/syscalls.cc, libinterp/corefcn/toplev.cc, libinterp/corefcn/tril.cc, libinterp/corefcn/typecast.cc, libinterp/corefcn/utils.cc, libinterp/corefcn/variables.cc, libinterp/dldfcn/__init_fltk__.cc, libinterp/dldfcn/chol.cc, libinterp/dldfcn/colamd.cc, libinterp/dldfcn/fftw.cc, libinterp/dldfcn/qr.cc, libinterp/dldfcn/symbfact.cc, libinterp/octave-value/ov-base.cc, libinterp/octave-value/ov-fcn-handle.cc, libinterp/octave-value/ov-fcn-inline.cc, libinterp/octave-value/ov-java.cc, libinterp/octave-value/ov-range.cc, libinterp/octave-value/ov-struct.cc, libinterp/octave-value/ov-usr-fcn.cc, libinterp/parse-tree/oct-parse.in.yy, libinterp/parse-tree/pt-binop.cc, libinterp/parse-tree/pt-eval.cc, libinterp/parse-tree/pt-mat.cc, scripts/@ftp/ftp.m, scripts/deprecated/java_convert_matrix.m, scripts/deprecated/java_debug.m, scripts/deprecated/java_unsigned_conversion.m, scripts/deprecated/shell_cmd.m, scripts/general/dblquad.m, scripts/general/display.m, scripts/general/genvarname.m, scripts/general/idivide.m, scripts/general/interp1.m, scripts/general/interp2.m, scripts/general/interp3.m, scripts/general/interpn.m, scripts/general/isa.m, scripts/general/profexplore.m, scripts/general/profile.m, scripts/general/quadgk.m, scripts/general/randi.m, scripts/general/structfun.m, scripts/general/subsindex.m, scripts/general/triplequad.m, scripts/geometry/griddata.m, scripts/geometry/griddata3.m, scripts/geometry/griddatan.m, scripts/geometry/voronoi.m, scripts/help/help.m, scripts/help/lookfor.m, scripts/image/cmpermute.m, scripts/image/colormap.m, scripts/image/image.m, scripts/image/imagesc.m, scripts/image/imfinfo.m, scripts/image/imformats.m, scripts/image/imread.m, scripts/image/imshow.m, scripts/image/imwrite.m, scripts/image/ind2gray.m, scripts/image/lines.m, scripts/image/rgb2ind.m, scripts/image/spinmap.m, scripts/io/dlmwrite.m, scripts/io/strread.m, scripts/io/textread.m, scripts/io/textscan.m, scripts/java/javaclasspath.m, scripts/java/usejava.m, scripts/miscellaneous/bzip2.m, scripts/miscellaneous/computer.m, scripts/miscellaneous/copyfile.m, scripts/miscellaneous/debug.m, scripts/miscellaneous/dos.m, scripts/miscellaneous/edit.m, scripts/miscellaneous/gzip.m, scripts/miscellaneous/license.m, scripts/miscellaneous/mkoctfile.m, scripts/miscellaneous/movefile.m, scripts/miscellaneous/parseparams.m, scripts/miscellaneous/unix.m, scripts/optimization/fminbnd.m, scripts/optimization/fminsearch.m, scripts/optimization/fminunc.m, scripts/optimization/fsolve.m, scripts/optimization/fzero.m, scripts/optimization/glpk.m, scripts/optimization/lsqnonneg.m, scripts/optimization/optimset.m, scripts/optimization/pqpnonneg.m, scripts/pkg/pkg.m, scripts/plot/allchild.m, scripts/plot/ancestor.m, scripts/plot/area.m, scripts/plot/axis.m, scripts/plot/bar.m, scripts/plot/barh.m, scripts/plot/box.m, scripts/plot/caxis.m, scripts/plot/cla.m, scripts/plot/clabel.m, scripts/plot/clf.m, scripts/plot/close.m, scripts/plot/colorbar.m, scripts/plot/daspect.m, scripts/plot/ezmesh.m, scripts/plot/ezmeshc.m, scripts/plot/ezsurf.m, scripts/plot/ezsurfc.m, scripts/plot/findall.m, scripts/plot/findobj.m, scripts/plot/gcbo.m, scripts/plot/gcf.m, scripts/plot/gco.m, scripts/plot/grid.m, scripts/plot/guihandles.m, scripts/plot/hdl2struct.m, scripts/plot/hidden.m, scripts/plot/hold.m, scripts/plot/isonormals.m, scripts/plot/isosurface.m, scripts/plot/legend.m, scripts/plot/mesh.m, scripts/plot/meshc.m, scripts/plot/meshz.m, scripts/plot/newplot.m, scripts/plot/orient.m, scripts/plot/pareto.m, scripts/plot/patch.m, scripts/plot/pbaspect.m, scripts/plot/pcolor.m, scripts/plot/plot.m, scripts/plot/print.m, scripts/plot/private/__add_default_menu__.m, scripts/plot/quiver.m, scripts/plot/quiver3.m, scripts/plot/refreshdata.m, scripts/plot/saveas.m, scripts/plot/scatter.m, scripts/plot/scatter3.m, scripts/plot/shading.m, scripts/plot/shrinkfaces.m, scripts/plot/slice.m, scripts/plot/stem.m, scripts/plot/stem3.m, scripts/plot/struct2hdl.m, scripts/plot/subplot.m, scripts/plot/surf.m, scripts/plot/surfc.m, scripts/plot/surfl.m, scripts/plot/tetramesh.m, scripts/plot/uigetfile.m, scripts/plot/uimenu.m, scripts/plot/uiputfile.m, scripts/plot/waterfall.m, scripts/plot/whitebg.m, scripts/plot/xlim.m, scripts/plot/ylim.m, scripts/plot/zlim.m, scripts/polynomial/conv.m, scripts/polynomial/polyout.m, scripts/polynomial/splinefit.m, scripts/set/ismember.m, scripts/set/powerset.m, scripts/set/setdiff.m, scripts/set/union.m, scripts/set/unique.m, scripts/signal/detrend.m, scripts/signal/filter2.m, scripts/signal/freqz.m, scripts/signal/periodogram.m, scripts/signal/spectral_adf.m, scripts/signal/spectral_xdf.m, scripts/sparse/eigs.m, scripts/sparse/svds.m, scripts/specfun/legendre.m, scripts/special-matrix/gallery.m, scripts/statistics/base/mean.m, scripts/statistics/base/moment.m, scripts/statistics/tests/cor_test.m, scripts/statistics/tests/kolmogorov_smirnov_test.m, scripts/statistics/tests/kolmogorov_smirnov_test_2.m, scripts/statistics/tests/kruskal_wallis_test.m, scripts/statistics/tests/prop_test_2.m, scripts/statistics/tests/sign_test.m, scripts/statistics/tests/t_test.m, scripts/statistics/tests/t_test_2.m, scripts/statistics/tests/t_test_regression.m, scripts/statistics/tests/u_test.m, scripts/statistics/tests/var_test.m, scripts/statistics/tests/welch_test.m, scripts/statistics/tests/wilcoxon_test.m, scripts/statistics/tests/z_test.m, scripts/statistics/tests/z_test_2.m, scripts/strings/base2dec.m, scripts/strings/index.m, scripts/strings/isstrprop.m, scripts/strings/mat2str.m, scripts/strings/regexptranslate.m, scripts/strings/rindex.m, scripts/strings/str2num.m, scripts/strings/strcat.m, scripts/strings/strjust.m, scripts/strings/strmatch.m, scripts/strings/validatestring.m, scripts/testfun/demo.m, scripts/testfun/example.m, scripts/testfun/test.m, scripts/time/addtodate.m, scripts/time/asctime.m, scripts/time/datestr.m, scripts/time/datetick.m, scripts/time/weekday.m, scripts/ui/errordlg.m, scripts/ui/helpdlg.m, scripts/ui/inputdlg.m, scripts/ui/listdlg.m, scripts/ui/msgbox.m, scripts/ui/questdlg.m, scripts/ui/warndlg.m: Use new @qcode macro.
author Rik <rik@octave.org>
date Mon, 19 Aug 2013 20:46:38 -0700
parents db90efd8f32b
children b81b9d079515
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
14138
72c96de7a403 maint: update copyright notices for 2012
John W. Eaton <jwe@octave.org>
parents: 14001
diff changeset
1 ## Copyright (C) 1994-2012 John W. Eaton
2313
5ca126254d15 [project @ 1996-07-11 21:25:22 by jwe]
jwe
parents: 2312
diff changeset
2 ##
5ca126254d15 [project @ 1996-07-11 21:25:22 by jwe]
jwe
parents: 2312
diff changeset
3 ## This file is part of Octave.
5ca126254d15 [project @ 1996-07-11 21:25:22 by jwe]
jwe
parents: 2312
diff changeset
4 ##
5ca126254d15 [project @ 1996-07-11 21:25:22 by jwe]
jwe
parents: 2312
diff changeset
5 ## Octave is free software; you can redistribute it and/or modify it
5ca126254d15 [project @ 1996-07-11 21:25:22 by jwe]
jwe
parents: 2312
diff changeset
6 ## under the terms of the GNU General Public License as published by
7016
93c65f2a5668 [project @ 2007-10-12 06:40:56 by jwe]
jwe
parents: 6368
diff changeset
7 ## the Free Software Foundation; either version 3 of the License, or (at
93c65f2a5668 [project @ 2007-10-12 06:40:56 by jwe]
jwe
parents: 6368
diff changeset
8 ## your option) any later version.
2313
5ca126254d15 [project @ 1996-07-11 21:25:22 by jwe]
jwe
parents: 2312
diff changeset
9 ##
5ca126254d15 [project @ 1996-07-11 21:25:22 by jwe]
jwe
parents: 2312
diff changeset
10 ## Octave is distributed in the hope that it will be useful, but
5ca126254d15 [project @ 1996-07-11 21:25:22 by jwe]
jwe
parents: 2312
diff changeset
11 ## WITHOUT ANY WARRANTY; without even the implied warranty of
5ca126254d15 [project @ 1996-07-11 21:25:22 by jwe]
jwe
parents: 2312
diff changeset
12 ## MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
5ca126254d15 [project @ 1996-07-11 21:25:22 by jwe]
jwe
parents: 2312
diff changeset
13 ## General Public License for more details.
5ca126254d15 [project @ 1996-07-11 21:25:22 by jwe]
jwe
parents: 2312
diff changeset
14 ##
5ca126254d15 [project @ 1996-07-11 21:25:22 by jwe]
jwe
parents: 2312
diff changeset
15 ## You should have received a copy of the GNU General Public License
7016
93c65f2a5668 [project @ 2007-10-12 06:40:56 by jwe]
jwe
parents: 6368
diff changeset
16 ## along with Octave; see the file COPYING. If not, see
93c65f2a5668 [project @ 2007-10-12 06:40:56 by jwe]
jwe
parents: 6368
diff changeset
17 ## <http://www.gnu.org/licenses/>.
1024
56520a75b5b3 [project @ 1995-01-11 20:30:04 by jwe]
jwe
parents: 904
diff changeset
18
3381
69b167451491 [project @ 1999-12-15 20:48:10 by jwe]
jwe
parents: 3373
diff changeset
19 ## -*- texinfo -*-
10793
be55736a0783 Grammarcheck the documentation from m-files.
Rik <octave@nomad.inbox5.com>
parents: 10704
diff changeset
20 ## @deftypefn {Function File} {} image (@var{img})
6257
44c91c5dfe1d [project @ 2007-01-30 19:16:52 by jwe]
jwe
parents: 6164
diff changeset
21 ## @deftypefnx {Function File} {} image (@var{x}, @var{y}, @var{img})
15683
806ea52af230 Overhaul m-files in image directory to provide better support for images stored as integers.
Rik <rik@octave.org>
parents: 15202
diff changeset
22 ## @deftypefnx {Function File} {} image (@dots{}, "@var{property}", @var{value}, @dots{})
14001
5f0bb45e615c doc: Update documentation for functions returning a graphics handle h (Bug #34761)
Rik <octave@nomad.inbox5.com>
parents: 13993
diff changeset
23 ## @deftypefnx {Function File} {@var{h} =} image (@dots{})
15683
806ea52af230 Overhaul m-files in image directory to provide better support for images stored as integers.
Rik <rik@octave.org>
parents: 15202
diff changeset
24 ## Display a matrix as an indexed color image.
3651
c2305b99fbd7 [project @ 2000-03-31 07:12:29 by jwe]
jwe
parents: 3457
diff changeset
25 ##
14260
1f911333ed3d doc: Update docstrings for functions in image/ directory
Rik <octave@nomad.inbox5.com>
parents: 14247
diff changeset
26 ## The elements of @var{img} are indices into the current colormap.
15683
806ea52af230 Overhaul m-files in image directory to provide better support for images stored as integers.
Rik <rik@octave.org>
parents: 15202
diff changeset
27 ## @var{x} and @var{y} are optional 2-element vectors, @w{@code{[min, max]}},
806ea52af230 Overhaul m-files in image directory to provide better support for images stored as integers.
Rik <rik@octave.org>
parents: 15202
diff changeset
28 ## which specify the range for the axis labels. If a range is specified as
806ea52af230 Overhaul m-files in image directory to provide better support for images stored as integers.
Rik <rik@octave.org>
parents: 15202
diff changeset
29 ## @w{@code{[max, min]}} then the image will be reversed along that axis. For
806ea52af230 Overhaul m-files in image directory to provide better support for images stored as integers.
Rik <rik@octave.org>
parents: 15202
diff changeset
30 ## convenience, @var{x} and @var{y} may be specified as N-element vectors
806ea52af230 Overhaul m-files in image directory to provide better support for images stored as integers.
Rik <rik@octave.org>
parents: 15202
diff changeset
31 ## matching the length of the data in @var{img}. However, only the first and
806ea52af230 Overhaul m-files in image directory to provide better support for images stored as integers.
Rik <rik@octave.org>
parents: 15202
diff changeset
32 ## last elements will be used to determine the axis limits.
806ea52af230 Overhaul m-files in image directory to provide better support for images stored as integers.
Rik <rik@octave.org>
parents: 15202
diff changeset
33 ## @strong{Warning:} @var{x} and @var{y} are ignored when using gnuplot 4.0
806ea52af230 Overhaul m-files in image directory to provide better support for images stored as integers.
Rik <rik@octave.org>
parents: 15202
diff changeset
34 ## or earlier.
10817
d9147775da54 image.m: Always reverse 'ydir' property when displaying images.
Rik <octave@nomad.inbox5.com>
parents: 10793
diff changeset
35 ##
14260
1f911333ed3d doc: Update docstrings for functions in image/ directory
Rik <octave@nomad.inbox5.com>
parents: 14247
diff changeset
36 ## The optional return value @var{h} is a graphics handle to the image.
1f911333ed3d doc: Update docstrings for functions in image/ directory
Rik <octave@nomad.inbox5.com>
parents: 14247
diff changeset
37 ##
11587
c792872f8942 all script files: untabify and strip trailing whitespace
John W. Eaton <jwe@octave.org>
parents: 11523
diff changeset
38 ## Implementation Note: The origin (0, 0) for images is located in the
10817
d9147775da54 image.m: Always reverse 'ydir' property when displaying images.
Rik <octave@nomad.inbox5.com>
parents: 10793
diff changeset
39 ## upper left. For ordinary plots, the origin is located in the lower
d9147775da54 image.m: Always reverse 'ydir' property when displaying images.
Rik <octave@nomad.inbox5.com>
parents: 10793
diff changeset
40 ## left. Octave handles this inversion by plotting the data normally,
d9147775da54 image.m: Always reverse 'ydir' property when displaying images.
Rik <octave@nomad.inbox5.com>
parents: 10793
diff changeset
41 ## and then reversing the direction of the y-axis by setting the
17281
bc924baa2c4e doc: Add new @qcode macro for code samples which are quoted.
Rik <rik@octave.org>
parents: 17038
diff changeset
42 ## @code{ydir} property to @qcode{"reverse"}. This has implications whenever
10817
d9147775da54 image.m: Always reverse 'ydir' property when displaying images.
Rik <octave@nomad.inbox5.com>
parents: 10793
diff changeset
43 ## an image and an ordinary plot need to be overlaid. The recommended
d9147775da54 image.m: Always reverse 'ydir' property when displaying images.
Rik <octave@nomad.inbox5.com>
parents: 10793
diff changeset
44 ## solution is to display the image and then plot the reversed ydata
15683
806ea52af230 Overhaul m-files in image directory to provide better support for images stored as integers.
Rik <rik@octave.org>
parents: 15202
diff changeset
45 ## using, for example, @code{flipud (ydata)}.
14001
5f0bb45e615c doc: Update documentation for functions returning a graphics handle h (Bug #34761)
Rik <octave@nomad.inbox5.com>
parents: 13993
diff changeset
46 ##
11109
41d18f6342f9 remove image_viewer function
John W. Eaton <jwe@octave.org>
parents: 11090
diff changeset
47 ## @seealso{imshow, imagesc, colormap}
3373
36405da8e173 [project @ 1999-11-23 20:54:17 by jwe]
jwe
parents: 3202
diff changeset
48 ## @end deftypefn
559
4e826edfbc56 [project @ 1994-07-25 22:18:28 by jwe]
jwe
parents:
diff changeset
49
3202
44d82b369c78 [project @ 1998-10-29 20:27:57 by jwe]
jwe
parents: 2847
diff changeset
50 ## Author: Tony Richardson <arichard@stark.cc.oh.us>
2312
204cc7db6f4a [project @ 1996-07-11 21:20:36 by jwe]
jwe
parents: 2311
diff changeset
51 ## Created: July 1994
204cc7db6f4a [project @ 1996-07-11 21:20:36 by jwe]
jwe
parents: 2311
diff changeset
52 ## Adapted-By: jwe
904
3470f1e25a79 [project @ 1994-11-09 21:22:15 by jwe]
jwe
parents: 686
diff changeset
53
15683
806ea52af230 Overhaul m-files in image directory to provide better support for images stored as integers.
Rik <rik@octave.org>
parents: 15202
diff changeset
54 function h = image (varargin)
7189
e8d953d03f6a [project @ 2007-11-26 20:42:09 by dbateman]
dbateman
parents: 7074
diff changeset
55
17038
db90efd8f32b image.m: Update to use new __plt_get_axis_arg__ without using "axes" and "newplot" function.
Rik <rik@octave.org>
parents: 15764
diff changeset
56 [hax, varargin, nargin] = __plt_get_axis_arg__ ("image", varargin{:});
db90efd8f32b image.m: Update to use new __plt_get_axis_arg__ without using "axes" and "newplot" function.
Rik <rik@octave.org>
parents: 15764
diff changeset
57
db90efd8f32b image.m: Update to use new __plt_get_axis_arg__ without using "axes" and "newplot" function.
Rik <rik@octave.org>
parents: 15764
diff changeset
58 if (isempty (hax))
db90efd8f32b image.m: Update to use new __plt_get_axis_arg__ without using "axes" and "newplot" function.
Rik <rik@octave.org>
parents: 15764
diff changeset
59 hax = gca ();
db90efd8f32b image.m: Update to use new __plt_get_axis_arg__ without using "axes" and "newplot" function.
Rik <rik@octave.org>
parents: 15764
diff changeset
60 endif
7276
1e8e64d71e34 [project @ 2007-12-10 20:09:59 by jwe]
jwe
parents: 7208
diff changeset
61
15683
806ea52af230 Overhaul m-files in image directory to provide better support for images stored as integers.
Rik <rik@octave.org>
parents: 15202
diff changeset
62 chararg = find (cellfun ("isclass", varargin, "char"), 1, "first");
806ea52af230 Overhaul m-files in image directory to provide better support for images stored as integers.
Rik <rik@octave.org>
parents: 15202
diff changeset
63
806ea52af230 Overhaul m-files in image directory to provide better support for images stored as integers.
Rik <rik@octave.org>
parents: 15202
diff changeset
64 if (nargin == 0 || chararg == 1)
10650
f0dc41c824ce Replace calls to deprecated functions.
Rik <octave@nomad.inbox5.com>
parents: 10433
diff changeset
65 img = imread ("default.img");
7276
1e8e64d71e34 [project @ 2007-12-10 20:09:59 by jwe]
jwe
parents: 7208
diff changeset
66 x = y = [];
15683
806ea52af230 Overhaul m-files in image directory to provide better support for images stored as integers.
Rik <rik@octave.org>
parents: 15202
diff changeset
67 elseif (nargin == 1 || chararg == 2)
7276
1e8e64d71e34 [project @ 2007-12-10 20:09:59 by jwe]
jwe
parents: 7208
diff changeset
68 img = varargin{1};
1e8e64d71e34 [project @ 2007-12-10 20:09:59 by jwe]
jwe
parents: 7208
diff changeset
69 x = y = [];
15683
806ea52af230 Overhaul m-files in image directory to provide better support for images stored as integers.
Rik <rik@octave.org>
parents: 15202
diff changeset
70 elseif (nargin == 2 || chararg == 3)
7276
1e8e64d71e34 [project @ 2007-12-10 20:09:59 by jwe]
jwe
parents: 7208
diff changeset
71 print_usage ();
7189
e8d953d03f6a [project @ 2007-11-26 20:42:09 by dbateman]
dbateman
parents: 7074
diff changeset
72 else
7276
1e8e64d71e34 [project @ 2007-12-10 20:09:59 by jwe]
jwe
parents: 7208
diff changeset
73 x = varargin{1};
1e8e64d71e34 [project @ 2007-12-10 20:09:59 by jwe]
jwe
parents: 7208
diff changeset
74 y = varargin{2};
1e8e64d71e34 [project @ 2007-12-10 20:09:59 by jwe]
jwe
parents: 7208
diff changeset
75 img = varargin{3};
15683
806ea52af230 Overhaul m-files in image directory to provide better support for images stored as integers.
Rik <rik@octave.org>
parents: 15202
diff changeset
76 chararg = 4;
15064
489736962e80 image.m: Don't accept complex image data (bug #36866)
Rik <rik@octave.org>
parents: 14872
diff changeset
77 endif
17038
db90efd8f32b image.m: Update to use new __plt_get_axis_arg__ without using "axes" and "newplot" function.
Rik <rik@octave.org>
parents: 15764
diff changeset
78
db90efd8f32b image.m: Update to use new __plt_get_axis_arg__ without using "axes" and "newplot" function.
Rik <rik@octave.org>
parents: 15764
diff changeset
79 htmp = __img__ (hax, x, y, img, varargin{chararg:end});
db90efd8f32b image.m: Update to use new __plt_get_axis_arg__ without using "axes" and "newplot" function.
Rik <rik@octave.org>
parents: 15764
diff changeset
80 set (hax, "layer", "top");
7276
1e8e64d71e34 [project @ 2007-12-10 20:09:59 by jwe]
jwe
parents: 7208
diff changeset
81
7189
e8d953d03f6a [project @ 2007-11-26 20:42:09 by dbateman]
dbateman
parents: 7074
diff changeset
82 if (nargout > 0)
15683
806ea52af230 Overhaul m-files in image directory to provide better support for images stored as integers.
Rik <rik@octave.org>
parents: 15202
diff changeset
83 h = htmp;
7189
e8d953d03f6a [project @ 2007-11-26 20:42:09 by dbateman]
dbateman
parents: 7074
diff changeset
84 endif
e8d953d03f6a [project @ 2007-11-26 20:42:09 by dbateman]
dbateman
parents: 7074
diff changeset
85
e8d953d03f6a [project @ 2007-11-26 20:42:09 by dbateman]
dbateman
parents: 7074
diff changeset
86 endfunction
9899
9f25290a35e8 more private function and subfunction changes
John W. Eaton <jwe@octave.org>
parents: 9245
diff changeset
87
9f25290a35e8 more private function and subfunction changes
John W. Eaton <jwe@octave.org>
parents: 9245
diff changeset
88 ## Generic image creation.
9f25290a35e8 more private function and subfunction changes
John W. Eaton <jwe@octave.org>
parents: 9245
diff changeset
89 ##
9f25290a35e8 more private function and subfunction changes
John W. Eaton <jwe@octave.org>
parents: 9245
diff changeset
90 ## The axis values corresponding to the matrix elements are specified in
14260
1f911333ed3d doc: Update docstrings for functions in image/ directory
Rik <octave@nomad.inbox5.com>
parents: 14247
diff changeset
91 ## @var{x} and @var{y}. If you're not using gnuplot 4.2 or later, these
9899
9f25290a35e8 more private function and subfunction changes
John W. Eaton <jwe@octave.org>
parents: 9245
diff changeset
92 ## variables are ignored.
9f25290a35e8 more private function and subfunction changes
John W. Eaton <jwe@octave.org>
parents: 9245
diff changeset
93
9f25290a35e8 more private function and subfunction changes
John W. Eaton <jwe@octave.org>
parents: 9245
diff changeset
94 ## Author: Tony Richardson <arichard@stark.cc.oh.us>
9f25290a35e8 more private function and subfunction changes
John W. Eaton <jwe@octave.org>
parents: 9245
diff changeset
95 ## Created: July 1994
9f25290a35e8 more private function and subfunction changes
John W. Eaton <jwe@octave.org>
parents: 9245
diff changeset
96 ## Adapted-By: jwe
9f25290a35e8 more private function and subfunction changes
John W. Eaton <jwe@octave.org>
parents: 9245
diff changeset
97
17038
db90efd8f32b image.m: Update to use new __plt_get_axis_arg__ without using "axes" and "newplot" function.
Rik <rik@octave.org>
parents: 15764
diff changeset
98 function h = __img__ (hax, x, y, img, varargin)
9899
9f25290a35e8 more private function and subfunction changes
John W. Eaton <jwe@octave.org>
parents: 9245
diff changeset
99
9f25290a35e8 more private function and subfunction changes
John W. Eaton <jwe@octave.org>
parents: 9245
diff changeset
100 if (isempty (img))
9f25290a35e8 more private function and subfunction changes
John W. Eaton <jwe@octave.org>
parents: 9245
diff changeset
101 error ("__img__: matrix is empty");
9f25290a35e8 more private function and subfunction changes
John W. Eaton <jwe@octave.org>
parents: 9245
diff changeset
102 endif
9f25290a35e8 more private function and subfunction changes
John W. Eaton <jwe@octave.org>
parents: 9245
diff changeset
103
15764
0a27a0e157a6 Temporary fix for display of indexed images of integer class.
Rik <rik@octave.org>
parents: 15683
diff changeset
104 ## FIXME: Hack for integer formats which use zero-based indexing
0a27a0e157a6 Temporary fix for display of indexed images of integer class.
Rik <rik@octave.org>
parents: 15683
diff changeset
105 ## Hack favors correctness of display over size of image in memory.
0a27a0e157a6 Temporary fix for display of indexed images of integer class.
Rik <rik@octave.org>
parents: 15683
diff changeset
106 ## True fix will be done in C++ code.
0a27a0e157a6 Temporary fix for display of indexed images of integer class.
Rik <rik@octave.org>
parents: 15683
diff changeset
107 if (ndims (img) == 2 && (isinteger (img) || islogical (img)))
0a27a0e157a6 Temporary fix for display of indexed images of integer class.
Rik <rik@octave.org>
parents: 15683
diff changeset
108 img = single (img) + 1;
0a27a0e157a6 Temporary fix for display of indexed images of integer class.
Rik <rik@octave.org>
parents: 15683
diff changeset
109 endif
0a27a0e157a6 Temporary fix for display of indexed images of integer class.
Rik <rik@octave.org>
parents: 15683
diff changeset
110
9899
9f25290a35e8 more private function and subfunction changes
John W. Eaton <jwe@octave.org>
parents: 9245
diff changeset
111 if (isempty (x))
9f25290a35e8 more private function and subfunction changes
John W. Eaton <jwe@octave.org>
parents: 9245
diff changeset
112 x = [1, columns(img)];
9f25290a35e8 more private function and subfunction changes
John W. Eaton <jwe@octave.org>
parents: 9245
diff changeset
113 endif
9f25290a35e8 more private function and subfunction changes
John W. Eaton <jwe@octave.org>
parents: 9245
diff changeset
114
9f25290a35e8 more private function and subfunction changes
John W. Eaton <jwe@octave.org>
parents: 9245
diff changeset
115 if (isempty (y))
9f25290a35e8 more private function and subfunction changes
John W. Eaton <jwe@octave.org>
parents: 9245
diff changeset
116 y = [1, rows(img)];
9f25290a35e8 more private function and subfunction changes
John W. Eaton <jwe@octave.org>
parents: 9245
diff changeset
117 endif
9f25290a35e8 more private function and subfunction changes
John W. Eaton <jwe@octave.org>
parents: 9245
diff changeset
118
15683
806ea52af230 Overhaul m-files in image directory to provide better support for images stored as integers.
Rik <rik@octave.org>
parents: 15202
diff changeset
119 xdata = x([1, end]);
806ea52af230 Overhaul m-files in image directory to provide better support for images stored as integers.
Rik <rik@octave.org>
parents: 15202
diff changeset
120 ydata = y([1, end]);
9899
9f25290a35e8 more private function and subfunction changes
John W. Eaton <jwe@octave.org>
parents: 9245
diff changeset
121
15683
806ea52af230 Overhaul m-files in image directory to provide better support for images stored as integers.
Rik <rik@octave.org>
parents: 15202
diff changeset
122 if (numel (x) > 2 && numel (y) > 2)
806ea52af230 Overhaul m-files in image directory to provide better support for images stored as integers.
Rik <rik@octave.org>
parents: 15202
diff changeset
123 ## Test data for non-linear spacing which is unsupported
806ea52af230 Overhaul m-files in image directory to provide better support for images stored as integers.
Rik <rik@octave.org>
parents: 15202
diff changeset
124 ## FIXME: Need a better check on linearity
806ea52af230 Overhaul m-files in image directory to provide better support for images stored as integers.
Rik <rik@octave.org>
parents: 15202
diff changeset
125 tol = 100*eps;
806ea52af230 Overhaul m-files in image directory to provide better support for images stored as integers.
Rik <rik@octave.org>
parents: 15202
diff changeset
126 dx = diff (x);
806ea52af230 Overhaul m-files in image directory to provide better support for images stored as integers.
Rik <rik@octave.org>
parents: 15202
diff changeset
127 dy = diff (y);
806ea52af230 Overhaul m-files in image directory to provide better support for images stored as integers.
Rik <rik@octave.org>
parents: 15202
diff changeset
128 dx = std (dx) / mean (abs (dx));
806ea52af230 Overhaul m-files in image directory to provide better support for images stored as integers.
Rik <rik@octave.org>
parents: 15202
diff changeset
129 dy = std (dy) / mean (abs (dy));
806ea52af230 Overhaul m-files in image directory to provide better support for images stored as integers.
Rik <rik@octave.org>
parents: 15202
diff changeset
130 if (any (dx > tol) || any (dy > tol))
806ea52af230 Overhaul m-files in image directory to provide better support for images stored as integers.
Rik <rik@octave.org>
parents: 15202
diff changeset
131 warning ("image: non-linear X, Y data is ignored. IMG will be shown with linear mapping");
806ea52af230 Overhaul m-files in image directory to provide better support for images stored as integers.
Rik <rik@octave.org>
parents: 15202
diff changeset
132 endif
13980
bd2be36fd949 image.m: Warn if input coordinates are not linearly spaced.
Ben Abbott <bpabbott@mac.com>
parents: 13173
diff changeset
133 endif
bd2be36fd949 image.m: Warn if input coordinates are not linearly spaced.
Ben Abbott <bpabbott@mac.com>
parents: 13173
diff changeset
134
17038
db90efd8f32b image.m: Update to use new __plt_get_axis_arg__ without using "axes" and "newplot" function.
Rik <rik@octave.org>
parents: 15764
diff changeset
135 htmp = __go_image__ (hax, "cdata", img, "xdata", xdata, "ydata", ydata,
15683
806ea52af230 Overhaul m-files in image directory to provide better support for images stored as integers.
Rik <rik@octave.org>
parents: 15202
diff changeset
136 "cdatamapping", "direct", varargin {:});
11076
b748b86cb8c1 fix images with width or height of 1
Shai Ayal <shaiay@users.sourceforge.net>
parents: 10952
diff changeset
137
15683
806ea52af230 Overhaul m-files in image directory to provide better support for images stored as integers.
Rik <rik@octave.org>
parents: 15202
diff changeset
138 px = __image_pixel_size__ (htmp);
11090
2adf4736dafa Do not store flipped image property values when x/ydata descends.
Ben Abbott <bpabbott@mac.com>
parents: 11080
diff changeset
139
2adf4736dafa Do not store flipped image property values when x/ydata descends.
Ben Abbott <bpabbott@mac.com>
parents: 11080
diff changeset
140 if (xdata(2) < xdata(1))
15683
806ea52af230 Overhaul m-files in image directory to provide better support for images stored as integers.
Rik <rik@octave.org>
parents: 15202
diff changeset
141 xdata = fliplr (xdata);
11090
2adf4736dafa Do not store flipped image property values when x/ydata descends.
Ben Abbott <bpabbott@mac.com>
parents: 11080
diff changeset
142 elseif (xdata(2) == xdata(1))
14872
c2dbdeaa25df maint: use rows() and columns() to clarify m-files.
Rik <octave@nomad.inbox5.com>
parents: 14260
diff changeset
143 xdata = xdata(1) + [0, columns(img)-1];
11090
2adf4736dafa Do not store flipped image property values when x/ydata descends.
Ben Abbott <bpabbott@mac.com>
parents: 11080
diff changeset
144 endif
2adf4736dafa Do not store flipped image property values when x/ydata descends.
Ben Abbott <bpabbott@mac.com>
parents: 11080
diff changeset
145 if (ydata(2) < ydata(1))
15683
806ea52af230 Overhaul m-files in image directory to provide better support for images stored as integers.
Rik <rik@octave.org>
parents: 15202
diff changeset
146 ydata = fliplr (ydata);
11090
2adf4736dafa Do not store flipped image property values when x/ydata descends.
Ben Abbott <bpabbott@mac.com>
parents: 11080
diff changeset
147 elseif (ydata(2) == ydata(1))
14872
c2dbdeaa25df maint: use rows() and columns() to clarify m-files.
Rik <octave@nomad.inbox5.com>
parents: 14260
diff changeset
148 ydata = ydata(1) + [0, rows(img)-1];
11090
2adf4736dafa Do not store flipped image property values when x/ydata descends.
Ben Abbott <bpabbott@mac.com>
parents: 11080
diff changeset
149 endif
11076
b748b86cb8c1 fix images with width or height of 1
Shai Ayal <shaiay@users.sourceforge.net>
parents: 10952
diff changeset
150 xlim = xdata + [-px(1), px(1)];
b748b86cb8c1 fix images with width or height of 1
Shai Ayal <shaiay@users.sourceforge.net>
parents: 10952
diff changeset
151 ylim = ydata + [-px(2), px(2)];
9899
9f25290a35e8 more private function and subfunction changes
John W. Eaton <jwe@octave.org>
parents: 9245
diff changeset
152
9f25290a35e8 more private function and subfunction changes
John W. Eaton <jwe@octave.org>
parents: 9245
diff changeset
153 ## FIXME -- how can we do this and also get the {x,y}limmode
9f25290a35e8 more private function and subfunction changes
John W. Eaton <jwe@octave.org>
parents: 9245
diff changeset
154 ## properties to remain "auto"? I suppose this adjustment should
9f25290a35e8 more private function and subfunction changes
John W. Eaton <jwe@octave.org>
parents: 9245
diff changeset
155 ## happen automatically in axes::update_axis_limits instead of
9f25290a35e8 more private function and subfunction changes
John W. Eaton <jwe@octave.org>
parents: 9245
diff changeset
156 ## explicitly setting the values here. But then what information is
9f25290a35e8 more private function and subfunction changes
John W. Eaton <jwe@octave.org>
parents: 9245
diff changeset
157 ## available to axes::update_axis_limits to determine that the
9f25290a35e8 more private function and subfunction changes
John W. Eaton <jwe@octave.org>
parents: 9245
diff changeset
158 ## adjustment is necessary?
17038
db90efd8f32b image.m: Update to use new __plt_get_axis_arg__ without using "axes" and "newplot" function.
Rik <rik@octave.org>
parents: 15764
diff changeset
159 set (hax, "xlim", xlim, "ylim", ylim);
9899
9f25290a35e8 more private function and subfunction changes
John W. Eaton <jwe@octave.org>
parents: 9245
diff changeset
160
9f25290a35e8 more private function and subfunction changes
John W. Eaton <jwe@octave.org>
parents: 9245
diff changeset
161 if (ndims (img) == 3)
9f25290a35e8 more private function and subfunction changes
John W. Eaton <jwe@octave.org>
parents: 9245
diff changeset
162 if (isinteger (img))
15683
806ea52af230 Overhaul m-files in image directory to provide better support for images stored as integers.
Rik <rik@octave.org>
parents: 15202
diff changeset
163 cls = class (img);
806ea52af230 Overhaul m-files in image directory to provide better support for images stored as integers.
Rik <rik@octave.org>
parents: 15202
diff changeset
164 mn = intmin (cls);
806ea52af230 Overhaul m-files in image directory to provide better support for images stored as integers.
Rik <rik@octave.org>
parents: 15202
diff changeset
165 mx = intmax (cls);
17038
db90efd8f32b image.m: Update to use new __plt_get_axis_arg__ without using "axes" and "newplot" function.
Rik <rik@octave.org>
parents: 15764
diff changeset
166 set (hax, "clim", double ([mn, mx]));
9899
9f25290a35e8 more private function and subfunction changes
John W. Eaton <jwe@octave.org>
parents: 9245
diff changeset
167 endif
9f25290a35e8 more private function and subfunction changes
John W. Eaton <jwe@octave.org>
parents: 9245
diff changeset
168 endif
9f25290a35e8 more private function and subfunction changes
John W. Eaton <jwe@octave.org>
parents: 9245
diff changeset
169
17038
db90efd8f32b image.m: Update to use new __plt_get_axis_arg__ without using "axes" and "newplot" function.
Rik <rik@octave.org>
parents: 15764
diff changeset
170 set (hax, "view", [0, 90]);
9899
9f25290a35e8 more private function and subfunction changes
John W. Eaton <jwe@octave.org>
parents: 9245
diff changeset
171
17038
db90efd8f32b image.m: Update to use new __plt_get_axis_arg__ without using "axes" and "newplot" function.
Rik <rik@octave.org>
parents: 15764
diff changeset
172 if (strcmp (get (hax, "nextplot"), "replace"))
11308
9a08fa5b33bd image.m: Only flip y-axis if nextplot property equal "replace".
Ben Abbott <bpabbott@mac.com>
parents: 11109
diff changeset
173 # Always reverse y-axis for images, unless hold is on
17038
db90efd8f32b image.m: Update to use new __plt_get_axis_arg__ without using "axes" and "newplot" function.
Rik <rik@octave.org>
parents: 15764
diff changeset
174 set (hax, "ydir", "reverse");
11308
9a08fa5b33bd image.m: Only flip y-axis if nextplot property equal "replace".
Ben Abbott <bpabbott@mac.com>
parents: 11109
diff changeset
175 endif
10817
d9147775da54 image.m: Always reverse 'ydir' property when displaying images.
Rik <octave@nomad.inbox5.com>
parents: 10793
diff changeset
176
9899
9f25290a35e8 more private function and subfunction changes
John W. Eaton <jwe@octave.org>
parents: 9245
diff changeset
177 if (nargout > 0)
15683
806ea52af230 Overhaul m-files in image directory to provide better support for images stored as integers.
Rik <rik@octave.org>
parents: 15202
diff changeset
178 h = htmp;
9899
9f25290a35e8 more private function and subfunction changes
John W. Eaton <jwe@octave.org>
parents: 9245
diff changeset
179 endif
9f25290a35e8 more private function and subfunction changes
John W. Eaton <jwe@octave.org>
parents: 9245
diff changeset
180
9f25290a35e8 more private function and subfunction changes
John W. Eaton <jwe@octave.org>
parents: 9245
diff changeset
181 endfunction
10942
48a1812fcc3a image.m: Matlab compatible axis limits, add demo.
Ben Abbott <bpabbott@mac.com>
parents: 10818
diff changeset
182
14237
11949c9795a0 Revamp %!demos in m-files to use Octave coding conventions on spacing, etc.
Rik <octave@nomad.inbox5.com>
parents: 14138
diff changeset
183
10942
48a1812fcc3a image.m: Matlab compatible axis limits, add demo.
Ben Abbott <bpabbott@mac.com>
parents: 10818
diff changeset
184 %!demo
14237
11949c9795a0 Revamp %!demos in m-files to use Octave coding conventions on spacing, etc.
Rik <octave@nomad.inbox5.com>
parents: 14138
diff changeset
185 %! clf;
15683
806ea52af230 Overhaul m-files in image directory to provide better support for images stored as integers.
Rik <rik@octave.org>
parents: 15202
diff changeset
186 %! colormap (jet (21));
11080
36ceff79607b image.m: Allow x/ydata to imply a flip of the image. Modify demos.
Ben Abbott <bpabbott@mac.com>
parents: 11076
diff changeset
187 %! img = 1 ./ hilb (11);
15683
806ea52af230 Overhaul m-files in image directory to provide better support for images stored as integers.
Rik <rik@octave.org>
parents: 15202
diff changeset
188 %! x = y = -5:5;
14237
11949c9795a0 Revamp %!demos in m-files to use Octave coding conventions on spacing, etc.
Rik <octave@nomad.inbox5.com>
parents: 14138
diff changeset
189 %! subplot (2,2,1);
15683
806ea52af230 Overhaul m-files in image directory to provide better support for images stored as integers.
Rik <rik@octave.org>
parents: 15202
diff changeset
190 %! h = image (x, y, img);
806ea52af230 Overhaul m-files in image directory to provide better support for images stored as integers.
Rik <rik@octave.org>
parents: 15202
diff changeset
191 %! ylabel ("limits = [-5.5, 5.5]");
806ea52af230 Overhaul m-files in image directory to provide better support for images stored as integers.
Rik <rik@octave.org>
parents: 15202
diff changeset
192 %! title ("image (x, y, img)");
14237
11949c9795a0 Revamp %!demos in m-files to use Octave coding conventions on spacing, etc.
Rik <octave@nomad.inbox5.com>
parents: 14138
diff changeset
193 %! subplot (2,2,2);
11949c9795a0 Revamp %!demos in m-files to use Octave coding conventions on spacing, etc.
Rik <octave@nomad.inbox5.com>
parents: 14138
diff changeset
194 %! h = image (-x, y, img);
11949c9795a0 Revamp %!demos in m-files to use Octave coding conventions on spacing, etc.
Rik <octave@nomad.inbox5.com>
parents: 14138
diff changeset
195 %! title ("image (-x, y, img)");
11949c9795a0 Revamp %!demos in m-files to use Octave coding conventions on spacing, etc.
Rik <octave@nomad.inbox5.com>
parents: 14138
diff changeset
196 %! subplot (2,2,3);
11949c9795a0 Revamp %!demos in m-files to use Octave coding conventions on spacing, etc.
Rik <octave@nomad.inbox5.com>
parents: 14138
diff changeset
197 %! h = image (x, -y, img);
11949c9795a0 Revamp %!demos in m-files to use Octave coding conventions on spacing, etc.
Rik <octave@nomad.inbox5.com>
parents: 14138
diff changeset
198 %! title ("image (x, -y, img)");
11949c9795a0 Revamp %!demos in m-files to use Octave coding conventions on spacing, etc.
Rik <octave@nomad.inbox5.com>
parents: 14138
diff changeset
199 %! ylabel ("limits = [-5.5, 5.5]");
11949c9795a0 Revamp %!demos in m-files to use Octave coding conventions on spacing, etc.
Rik <octave@nomad.inbox5.com>
parents: 14138
diff changeset
200 %! subplot (2,2,4);
11949c9795a0 Revamp %!demos in m-files to use Octave coding conventions on spacing, etc.
Rik <octave@nomad.inbox5.com>
parents: 14138
diff changeset
201 %! h = image (-x, -y, img);
11949c9795a0 Revamp %!demos in m-files to use Octave coding conventions on spacing, etc.
Rik <octave@nomad.inbox5.com>
parents: 14138
diff changeset
202 %! title ("image (-x, -y, img)");
10942
48a1812fcc3a image.m: Matlab compatible axis limits, add demo.
Ben Abbott <bpabbott@mac.com>
parents: 10818
diff changeset
203