Mercurial > octave-nkf
annotate scripts/image/imshow.m @ 20193:7503499a252b stable
doc: Update docstrings to have one sentence summary as first line.
Update scripts in audio, elfun, general, geometry, and image directories.
* scripts/audio/@audioplayer/__get_properties__.m,
scripts/audio/@audioplayer/audioplayer.m, scripts/audio/@audioplayer/get.m,
scripts/audio/@audioplayer/isplaying.m, scripts/audio/@audioplayer/play.m,
scripts/audio/@audioplayer/playblocking.m, scripts/audio/@audioplayer/set.m,
scripts/audio/@audioplayer/subsasgn.m, scripts/audio/@audioplayer/subsref.m,
scripts/audio/@audiorecorder/audiorecorder.m,
scripts/audio/@audiorecorder/get.m,
scripts/audio/@audiorecorder/getaudiodata.m,
scripts/audio/@audiorecorder/getplayer.m,
scripts/audio/@audiorecorder/isrecording.m,
scripts/audio/@audiorecorder/play.m, scripts/audio/@audiorecorder/record.m,
scripts/audio/@audiorecorder/recordblocking.m,
scripts/audio/@audiorecorder/set.m, scripts/audio/@audiorecorder/stop.m,
scripts/audio/@audiorecorder/subsasgn.m,
scripts/audio/@audiorecorder/subsref.m, scripts/audio/lin2mu.m,
scripts/audio/mu2lin.m, scripts/audio/record.m, scripts/audio/sound.m,
scripts/audio/soundsc.m, scripts/audio/wavread.m, scripts/audio/wavwrite.m,
scripts/elfun/cosd.m, scripts/elfun/sind.m, scripts/elfun/tand.m,
scripts/general/accumarray.m, scripts/general/accumdim.m,
scripts/general/bitcmp.m, scripts/general/bitget.m, scripts/general/bitset.m,
scripts/general/blkdiag.m, scripts/general/cart2pol.m,
scripts/general/cart2sph.m, scripts/general/cell2mat.m,
scripts/general/celldisp.m, scripts/general/chop.m,
scripts/general/circshift.m, scripts/general/common_size.m,
scripts/general/cplxpair.m, scripts/general/cumtrapz.m,
scripts/general/dblquad.m, scripts/general/deal.m, scripts/general/del2.m,
scripts/general/display.m, scripts/general/divergence.m,
scripts/general/fieldnames.m, scripts/general/flip.m,
scripts/general/flipdim.m, scripts/general/fliplr.m, scripts/general/flipud.m,
scripts/general/gradient.m, scripts/general/interp3.m,
scripts/general/interpft.m, scripts/general/interpn.m,
scripts/general/loadobj.m, scripts/general/logspace.m,
scripts/general/methods.m, scripts/general/nargchk.m,
scripts/general/narginchk.m, scripts/general/nargoutchk.m,
scripts/general/nextpow2.m, scripts/general/nthargout.m,
scripts/general/num2str.m, scripts/general/pol2cart.m,
scripts/general/polyarea.m, scripts/general/postpad.m,
scripts/general/prepad.m, scripts/general/profile.m, scripts/general/quadgk.m,
scripts/general/quadl.m, scripts/general/quadv.m, scripts/general/randi.m,
scripts/general/rat.m, scripts/general/repmat.m, scripts/general/rot90.m,
scripts/general/rotdim.m, scripts/general/saveobj.m, scripts/general/shift.m,
scripts/general/shiftdim.m, scripts/general/sortrows.m,
scripts/general/sph2cart.m, scripts/general/structfun.m,
scripts/general/subsindex.m, scripts/general/trapz.m,
scripts/general/triplequad.m, scripts/geometry/delaunayn.m,
scripts/geometry/dsearch.m, scripts/geometry/dsearchn.m,
scripts/geometry/griddata.m, scripts/geometry/griddata3.m,
scripts/geometry/griddatan.m, scripts/geometry/inpolygon.m,
scripts/geometry/rectint.m, scripts/geometry/tsearchn.m,
scripts/geometry/voronoi.m, scripts/geometry/voronoin.m,
scripts/help/__unimplemented__.m, scripts/help/doc.m,
scripts/help/doc_cache_create.m, scripts/help/get_first_help_sentence.m,
scripts/help/help.m, scripts/help/lookfor.m, scripts/help/print_usage.m,
scripts/help/type.m, scripts/help/which.m, scripts/image/autumn.m,
scripts/image/bone.m, scripts/image/brighten.m, scripts/image/cmpermute.m,
scripts/image/colorcube.m, scripts/image/contrast.m, scripts/image/cool.m,
scripts/image/copper.m, scripts/image/cubehelix.m, scripts/image/flag.m,
scripts/image/gmap40.m, scripts/image/gray.m, scripts/image/gray2ind.m,
scripts/image/hot.m, scripts/image/hsv.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/iscolormap.m, scripts/image/jet.m, scripts/image/lines.m,
scripts/image/ntsc2rgb.m, scripts/image/ocean.m, scripts/image/pink.m,
scripts/image/prism.m, scripts/image/rainbow.m, scripts/image/rgb2ntsc.m,
scripts/image/spinmap.m, scripts/image/spring.m, scripts/image/summer.m,
scripts/image/white.m, scripts/image/winter.m:
Update docstrings to have one sentence summary as first line.
Re-structure to have line lengths <= 80 chars.
author | Rik <rik@octave.org> |
---|---|
date | Sun, 03 May 2015 09:36:20 -0700 |
parents | 9fc020886ae9 |
children | aa36fb998a4d |
rev | line source |
---|---|
19731
4197fc428c7d
maint: Update copyright notices for 2015.
John W. Eaton <jwe@octave.org>
parents:
19631
diff
changeset
|
1 ## Copyright (C) 1994-2015 John W. Eaton |
11587
c792872f8942
all script files: untabify and strip trailing whitespace
John W. Eaton <jwe@octave.org>
parents:
11523
diff
changeset
|
2 ## |
2313 | 3 ## This file is part of Octave. |
4 ## | |
5 ## Octave is free software; you can redistribute it and/or modify it | |
6 ## under the terms of the GNU General Public License as published by | |
7016 | 7 ## the Free Software Foundation; either version 3 of the License, or (at |
8 ## your option) any later version. | |
2313 | 9 ## |
10 ## Octave is distributed in the hope that it will be useful, but | |
11 ## WITHOUT ANY WARRANTY; without even the implied warranty of | |
12 ## MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU | |
13 ## General Public License for more details. | |
14 ## | |
15 ## You should have received a copy of the GNU General Public License | |
7016 | 16 ## along with Octave; see the file COPYING. If not, see |
17 ## <http://www.gnu.org/licenses/>. | |
1024 | 18 |
3381 | 19 ## -*- texinfo -*- |
10793
be55736a0783
Grammarcheck the documentation from m-files.
Rik <octave@nomad.inbox5.com>
parents:
10648
diff
changeset
|
20 ## @deftypefn {Function File} {} imshow (@var{im}) |
5934 | 21 ## @deftypefnx {Function File} {} imshow (@var{im}, @var{limits}) |
22 ## @deftypefnx {Function File} {} imshow (@var{im}, @var{map}) | |
7074 | 23 ## @deftypefnx {Function File} {} imshow (@var{rgb}, @dots{}) |
5934 | 24 ## @deftypefnx {Function File} {} imshow (@var{filename}) |
6309 | 25 ## @deftypefnx {Function File} {} imshow (@dots{}, @var{string_param1}, @var{value1}, @dots{}) |
14001
5f0bb45e615c
doc: Update documentation for functions returning a graphics handle h (Bug #34761)
Rik <octave@nomad.inbox5.com>
parents:
13738
diff
changeset
|
26 ## @deftypefnx {Function File} {@var{h} =} imshow (@dots{}) |
6368 | 27 ## Display the image @var{im}, where @var{im} can be a 2-dimensional |
14897
8e2a6fc55787
doc: Use 'grayscale' rather than 'gray-scale' in documentation.
Rik <rik@octave.org>
parents:
14366
diff
changeset
|
28 ## (grayscale image) or a 3-dimensional (RGB image) matrix. |
5934 | 29 ## |
20193
7503499a252b
doc: Update docstrings to have one sentence summary as first line.
Rik <rik@octave.org>
parents:
19867
diff
changeset
|
30 ## If @var{limits} is a 2-element vector @code{[@var{low}, @var{high}]}, the |
7503499a252b
doc: Update docstrings to have one sentence summary as first line.
Rik <rik@octave.org>
parents:
19867
diff
changeset
|
31 ## image is shown using a display range between @var{low} and @var{high}. If |
7503499a252b
doc: Update docstrings to have one sentence summary as first line.
Rik <rik@octave.org>
parents:
19867
diff
changeset
|
32 ## an empty matrix is passed for @var{limits}, the display range is computed |
7503499a252b
doc: Update docstrings to have one sentence summary as first line.
Rik <rik@octave.org>
parents:
19867
diff
changeset
|
33 ## as the range between the minimal and the maximal value in the image. |
3426 | 34 ## |
5934 | 35 ## If @var{map} is a valid color map, the image will be shown as an indexed |
36 ## image using the supplied color map. | |
37 ## | |
20193
7503499a252b
doc: Update docstrings to have one sentence summary as first line.
Rik <rik@octave.org>
parents:
19867
diff
changeset
|
38 ## If a file name is given instead of an image, the file will be read and shown. |
3426 | 39 ## |
20193
7503499a252b
doc: Update docstrings to have one sentence summary as first line.
Rik <rik@octave.org>
parents:
19867
diff
changeset
|
40 ## If given, the parameter @var{string_param1} has value @var{value1}. |
7503499a252b
doc: Update docstrings to have one sentence summary as first line.
Rik <rik@octave.org>
parents:
19867
diff
changeset
|
41 ## @var{string_param1} can be any of the following: |
14366
b76f0740940e
doc: Periodic grammar check of documentation.
Rik <octave@nomad.inbox5.com>
parents:
14237
diff
changeset
|
42 ## |
11595
5ec6aa05638d
Prevent doubled quotes around @table items in Info.
Rik <octave@nomad.inbox5.com>
parents:
11587
diff
changeset
|
43 ## @table @asis |
17281
bc924baa2c4e
doc: Add new @qcode macro for code samples which are quoted.
Rik <rik@octave.org>
parents:
14897
diff
changeset
|
44 ## @item @qcode{"displayrange"} |
5934 | 45 ## @var{value1} is the display range as described above. |
19627
446c46af4b42
strip trailing whitespace from most source files
John W. Eaton <jwe@octave.org>
parents:
18546
diff
changeset
|
46 ## |
18748
c79696701468
doc: Document new 'colormap' parameter to imshow.
Rik <rik@octave.org>
parents:
18747
diff
changeset
|
47 ## @item @qcode{"colormap"} |
c79696701468
doc: Document new 'colormap' parameter to imshow.
Rik <rik@octave.org>
parents:
18747
diff
changeset
|
48 ## @var{value1} is the colormap to use when displaying an indexed image. |
19630
0e1f5a750d00
maint: Periodic merge of gui-release to default.
John W. Eaton <jwe@octave.org>
diff
changeset
|
49 ## |
17753
887df64e54e4
doc: Final grammarcheck of docstrings for 3.8 release.
Rik <rik@octave.org>
parents:
17744
diff
changeset
|
50 ## @item @qcode{"xdata"} |
17734
64ad713b3a64
imshow.m: Add support for "xdata" and "ydata" options, make option parser case insensitive
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents:
17281
diff
changeset
|
51 ## If @var{value1} is a two element vector, it must contain horizontal axis |
20193
7503499a252b
doc: Update docstrings to have one sentence summary as first line.
Rik <rik@octave.org>
parents:
19867
diff
changeset
|
52 ## limits in the form [xmin xmax]; Otherwise @var{value1} must be a vector and |
7503499a252b
doc: Update docstrings to have one sentence summary as first line.
Rik <rik@octave.org>
parents:
19867
diff
changeset
|
53 ## only the first and last elements will be used for xmin and xmax respectively. |
19627
446c46af4b42
strip trailing whitespace from most source files
John W. Eaton <jwe@octave.org>
parents:
18546
diff
changeset
|
54 ## |
17753
887df64e54e4
doc: Final grammarcheck of docstrings for 3.8 release.
Rik <rik@octave.org>
parents:
17744
diff
changeset
|
55 ## @item @qcode{"ydata"} |
17734
64ad713b3a64
imshow.m: Add support for "xdata" and "ydata" options, make option parser case insensitive
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents:
17281
diff
changeset
|
56 ## If @var{value1} is a two element vector, it must contain vertical axis |
20193
7503499a252b
doc: Update docstrings to have one sentence summary as first line.
Rik <rik@octave.org>
parents:
19867
diff
changeset
|
57 ## limits in the form [ymin ymax]; Otherwise @var{value1} must be a vector and |
7503499a252b
doc: Update docstrings to have one sentence summary as first line.
Rik <rik@octave.org>
parents:
19867
diff
changeset
|
58 ## only the first and last elements will be used for ymin and ymax respectively. |
17734
64ad713b3a64
imshow.m: Add support for "xdata" and "ydata" options, make option parser case insensitive
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents:
17281
diff
changeset
|
59 ## |
5934 | 60 ## @end table |
14001
5f0bb45e615c
doc: Update documentation for functions returning a graphics handle h (Bug #34761)
Rik <octave@nomad.inbox5.com>
parents:
13738
diff
changeset
|
61 ## |
5f0bb45e615c
doc: Update documentation for functions returning a graphics handle h (Bug #34761)
Rik <octave@nomad.inbox5.com>
parents:
13738
diff
changeset
|
62 ## The optional return value @var{h} is a graphics handle to the image. |
5642 | 63 ## @seealso{image, imagesc, colormap, gray2ind, rgb2ind} |
3373 | 64 ## @end deftypefn |
904 | 65 |
7074 | 66 ## Author: Stefan van der Walt <stefan@sun.ac.za> |
5934 | 67 ## Author: Soren Hauberg <hauberg at gmail dot com> |
2312 | 68 ## Adapted-By: jwe |
559 | 69 |
7074 | 70 function h = imshow (im, varargin) |
559 | 71 |
5934 | 72 if (nargin == 0) |
73 print_usage (); | |
5318 | 74 endif |
75 | |
7328 | 76 display_range = NA; |
18747
0585787aa8ae
imshow.m: Overhaul function and support integer images (bug #41240).
Rik <rik@octave.org>
parents:
18746
diff
changeset
|
77 truecolor = false; |
7074 | 78 indexed = false; |
17734
64ad713b3a64
imshow.m: Add support for "xdata" and "ydata" options, make option parser case insensitive
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents:
17281
diff
changeset
|
79 xdata = ydata = []; |
7074 | 80 |
5935 | 81 ## Get the image. |
5934 | 82 if (ischar (im)) |
7931
de26beacb20f
imread.m: simplify; loadimage.m: deprecate
John W. Eaton <jwe@octave.org>
parents:
7930
diff
changeset
|
83 [im, map] = imread (im); |
7074 | 84 indexed = true; |
85 colormap (map); | |
86 endif | |
87 | |
10286
8cf666139297
imshow for logical matrices
John W. Eaton <jwe@octave.org>
parents:
9273
diff
changeset
|
88 nd = ndims (im); |
8cf666139297
imshow for logical matrices
John W. Eaton <jwe@octave.org>
parents:
9273
diff
changeset
|
89 |
8cf666139297
imshow for logical matrices
John W. Eaton <jwe@octave.org>
parents:
9273
diff
changeset
|
90 if (! ((isnumeric (im) || islogical (im)) && (nd == 2 || nd == 3))) |
11472
1740012184f9
Use uppercase for variable names in error() strings to match Info documentation. Only m-files done.
Rik <octave@nomad.inbox5.com>
parents:
11324
diff
changeset
|
91 error ("imshow: IM must be an image or the filename of an image"); |
5318 | 92 endif |
7074 | 93 |
10286
8cf666139297
imshow for logical matrices
John W. Eaton <jwe@octave.org>
parents:
9273
diff
changeset
|
94 if (nd == 2) |
7074 | 95 if (! indexed) |
96 colormap (gray ()); | |
97 endif | |
98 elseif (size (im, 3) == 3) | |
99 if (ismember (class (im), {"uint8", "uint16", "double", "single"})) | |
18747
0585787aa8ae
imshow.m: Overhaul function and support integer images (bug #41240).
Rik <rik@octave.org>
parents:
18746
diff
changeset
|
100 truecolor = true; |
7074 | 101 else |
18747
0585787aa8ae
imshow.m: Overhaul function and support integer images (bug #41240).
Rik <rik@octave.org>
parents:
18746
diff
changeset
|
102 error ("imshow: TrueColor image must be uint8, uint16, double, or single"); |
7074 | 103 endif |
104 else | |
105 error ("imshow: expecting MxN or MxNx3 matrix for image"); | |
5318 | 106 endif |
107 | |
7074 | 108 narg = 1; |
109 while (narg <= numel (varargin)) | |
110 arg = varargin{narg++}; | |
111 if (isnumeric (arg)) | |
7331 | 112 if (numel (arg) == 2 || isempty (arg)) |
10433
2c01d24459fb
Detabify scripts in 'scripts/image/'
Soren Hauberg <hauberg@gmail.com>
parents:
10286
diff
changeset
|
113 display_range = arg; |
7074 | 114 elseif (columns (arg) == 3) |
10433
2c01d24459fb
Detabify scripts in 'scripts/image/'
Soren Hauberg <hauberg@gmail.com>
parents:
10286
diff
changeset
|
115 indexed = true; |
18747
0585787aa8ae
imshow.m: Overhaul function and support integer images (bug #41240).
Rik <rik@octave.org>
parents:
18746
diff
changeset
|
116 if (iscolormap (arg)) |
0585787aa8ae
imshow.m: Overhaul function and support integer images (bug #41240).
Rik <rik@octave.org>
parents:
18746
diff
changeset
|
117 colormap (arg); |
0585787aa8ae
imshow.m: Overhaul function and support integer images (bug #41240).
Rik <rik@octave.org>
parents:
18746
diff
changeset
|
118 else |
0585787aa8ae
imshow.m: Overhaul function and support integer images (bug #41240).
Rik <rik@octave.org>
parents:
18746
diff
changeset
|
119 error ("imshow: invalid colormap MAP"); |
0585787aa8ae
imshow.m: Overhaul function and support integer images (bug #41240).
Rik <rik@octave.org>
parents:
18746
diff
changeset
|
120 endif |
7074 | 121 elseif (! isempty (arg)) |
18747
0585787aa8ae
imshow.m: Overhaul function and support integer images (bug #41240).
Rik <rik@octave.org>
parents:
18746
diff
changeset
|
122 error ("imshow: argument number %d is invalid", narg); |
7074 | 123 endif |
124 elseif (ischar (arg)) | |
17734
64ad713b3a64
imshow.m: Add support for "xdata" and "ydata" options, make option parser case insensitive
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents:
17281
diff
changeset
|
125 switch (tolower (arg)) |
18747
0585787aa8ae
imshow.m: Overhaul function and support integer images (bug #41240).
Rik <rik@octave.org>
parents:
18746
diff
changeset
|
126 case "colormap" |
0585787aa8ae
imshow.m: Overhaul function and support integer images (bug #41240).
Rik <rik@octave.org>
parents:
18746
diff
changeset
|
127 map = varargin{narg++}; |
0585787aa8ae
imshow.m: Overhaul function and support integer images (bug #41240).
Rik <rik@octave.org>
parents:
18746
diff
changeset
|
128 if (iscolormap (map)) |
0585787aa8ae
imshow.m: Overhaul function and support integer images (bug #41240).
Rik <rik@octave.org>
parents:
18746
diff
changeset
|
129 colormap (map); |
0585787aa8ae
imshow.m: Overhaul function and support integer images (bug #41240).
Rik <rik@octave.org>
parents:
18746
diff
changeset
|
130 else |
0585787aa8ae
imshow.m: Overhaul function and support integer images (bug #41240).
Rik <rik@octave.org>
parents:
18746
diff
changeset
|
131 error ("imshow: invalid colormap"); |
0585787aa8ae
imshow.m: Overhaul function and support integer images (bug #41240).
Rik <rik@octave.org>
parents:
18746
diff
changeset
|
132 endif |
0585787aa8ae
imshow.m: Overhaul function and support integer images (bug #41240).
Rik <rik@octave.org>
parents:
18746
diff
changeset
|
133 case "displayrange" |
10433
2c01d24459fb
Detabify scripts in 'scripts/image/'
Soren Hauberg <hauberg@gmail.com>
parents:
10286
diff
changeset
|
134 display_range = varargin{narg++}; |
18747
0585787aa8ae
imshow.m: Overhaul function and support integer images (bug #41240).
Rik <rik@octave.org>
parents:
18746
diff
changeset
|
135 case "parent" |
0585787aa8ae
imshow.m: Overhaul function and support integer images (bug #41240).
Rik <rik@octave.org>
parents:
18746
diff
changeset
|
136 warning ("imshow: parent argument is not implemented"); |
0585787aa8ae
imshow.m: Overhaul function and support integer images (bug #41240).
Rik <rik@octave.org>
parents:
18746
diff
changeset
|
137 case {"truesize", "initialmagnification"} |
0585787aa8ae
imshow.m: Overhaul function and support integer images (bug #41240).
Rik <rik@octave.org>
parents:
18746
diff
changeset
|
138 warning ("image: zoom argument ignored -- use GUI features"); |
0585787aa8ae
imshow.m: Overhaul function and support integer images (bug #41240).
Rik <rik@octave.org>
parents:
18746
diff
changeset
|
139 case "xdata" |
17734
64ad713b3a64
imshow.m: Add support for "xdata" and "ydata" options, make option parser case insensitive
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents:
17281
diff
changeset
|
140 xdata = varargin{narg++}; |
64ad713b3a64
imshow.m: Add support for "xdata" and "ydata" options, make option parser case insensitive
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents:
17281
diff
changeset
|
141 if (! isvector (xdata)) |
64ad713b3a64
imshow.m: Add support for "xdata" and "ydata" options, make option parser case insensitive
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents:
17281
diff
changeset
|
142 error ("imshow: xdata must be a vector") |
64ad713b3a64
imshow.m: Add support for "xdata" and "ydata" options, make option parser case insensitive
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents:
17281
diff
changeset
|
143 endif |
64ad713b3a64
imshow.m: Add support for "xdata" and "ydata" options, make option parser case insensitive
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents:
17281
diff
changeset
|
144 xdata = [xdata(1) xdata(end)]; |
18747
0585787aa8ae
imshow.m: Overhaul function and support integer images (bug #41240).
Rik <rik@octave.org>
parents:
18746
diff
changeset
|
145 case "ydata" |
17734
64ad713b3a64
imshow.m: Add support for "xdata" and "ydata" options, make option parser case insensitive
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents:
17281
diff
changeset
|
146 ydata = varargin{narg++}; |
18546
8e384416ebb3
imshow.m: Fix bad input validation of ydata (bug #41773).
Rik <rik@octave.org>
parents:
17753
diff
changeset
|
147 if (! isvector (ydata)) |
18747
0585787aa8ae
imshow.m: Overhaul function and support integer images (bug #41240).
Rik <rik@octave.org>
parents:
18746
diff
changeset
|
148 error ("imshow: ydata must be a vector") |
17734
64ad713b3a64
imshow.m: Add support for "xdata" and "ydata" options, make option parser case insensitive
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents:
17281
diff
changeset
|
149 endif |
64ad713b3a64
imshow.m: Add support for "xdata" and "ydata" options, make option parser case insensitive
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents:
17281
diff
changeset
|
150 ydata = [ydata(1) ydata(end)]; |
10433
2c01d24459fb
Detabify scripts in 'scripts/image/'
Soren Hauberg <hauberg@gmail.com>
parents:
10286
diff
changeset
|
151 otherwise |
2c01d24459fb
Detabify scripts in 'scripts/image/'
Soren Hauberg <hauberg@gmail.com>
parents:
10286
diff
changeset
|
152 warning ("imshow: unrecognized property %s", arg); |
2c01d24459fb
Detabify scripts in 'scripts/image/'
Soren Hauberg <hauberg@gmail.com>
parents:
10286
diff
changeset
|
153 narg++; |
7074 | 154 endswitch |
155 else | |
18747
0585787aa8ae
imshow.m: Overhaul function and support integer images (bug #41240).
Rik <rik@octave.org>
parents:
18746
diff
changeset
|
156 error ("imshow: argument number %d is invalid", narg); |
7074 | 157 endif |
158 endwhile | |
159 | |
13738
7ee61e56eaed
Periodic merge of stable to default
Jordi Gutiérrez Hermoso <jordigh@octave.org>
parents:
13705
diff
changeset
|
160 ## Check for complex images. |
7ee61e56eaed
Periodic merge of stable to default
Jordi Gutiérrez Hermoso <jordigh@octave.org>
parents:
13705
diff
changeset
|
161 if (iscomplex (im)) |
7ee61e56eaed
Periodic merge of stable to default
Jordi Gutiérrez Hermoso <jordigh@octave.org>
parents:
13705
diff
changeset
|
162 warning ("imshow: only showing real part of complex image"); |
7ee61e56eaed
Periodic merge of stable to default
Jordi Gutiérrez Hermoso <jordigh@octave.org>
parents:
13705
diff
changeset
|
163 im = real (im); |
7ee61e56eaed
Periodic merge of stable to default
Jordi Gutiérrez Hermoso <jordigh@octave.org>
parents:
13705
diff
changeset
|
164 endif |
7ee61e56eaed
Periodic merge of stable to default
Jordi Gutiérrez Hermoso <jordigh@octave.org>
parents:
13705
diff
changeset
|
165 |
8117 | 166 ## Set default display range if display_range not set yet. |
7328 | 167 if (isempty (display_range)) |
7074 | 168 display_range = [min(im(:)), max(im(:))]; |
8117 | 169 elseif (isna (display_range)) |
7074 | 170 t = class (im); |
171 switch (t) | |
172 case {"double", "single", "logical"} | |
10433
2c01d24459fb
Detabify scripts in 'scripts/image/'
Soren Hauberg <hauberg@gmail.com>
parents:
10286
diff
changeset
|
173 display_range = [0, 1]; |
18747
0585787aa8ae
imshow.m: Overhaul function and support integer images (bug #41240).
Rik <rik@octave.org>
parents:
18746
diff
changeset
|
174 case {"uint8", "uint16", "int16"} |
11597
a066673566da
set clim to [0,1] so that scaled cdatamapping works as intended.
Jordi Gutiérrez Hermoso <jordigh@gmail.com>
parents:
11595
diff
changeset
|
175 display_range = [intmin(t), intmax(t)]; |
7074 | 176 otherwise |
10433
2c01d24459fb
Detabify scripts in 'scripts/image/'
Soren Hauberg <hauberg@gmail.com>
parents:
10286
diff
changeset
|
177 error ("imshow: invalid data type for image"); |
7074 | 178 endswitch |
179 endif | |
5934 | 180 |
18747
0585787aa8ae
imshow.m: Overhaul function and support integer images (bug #41240).
Rik <rik@octave.org>
parents:
18746
diff
changeset
|
181 if (isfloat (im)) |
0585787aa8ae
imshow.m: Overhaul function and support integer images (bug #41240).
Rik <rik@octave.org>
parents:
18746
diff
changeset
|
182 nans = isnan (im(:)); |
0585787aa8ae
imshow.m: Overhaul function and support integer images (bug #41240).
Rik <rik@octave.org>
parents:
18746
diff
changeset
|
183 if (any (nans)) |
0585787aa8ae
imshow.m: Overhaul function and support integer images (bug #41240).
Rik <rik@octave.org>
parents:
18746
diff
changeset
|
184 warning ("Octave:imshow-NaN", |
0585787aa8ae
imshow.m: Overhaul function and support integer images (bug #41240).
Rik <rik@octave.org>
parents:
18746
diff
changeset
|
185 "imshow: pixels with NaN or NA values are set to minimum pixel value"); |
0585787aa8ae
imshow.m: Overhaul function and support integer images (bug #41240).
Rik <rik@octave.org>
parents:
18746
diff
changeset
|
186 im(nans) = display_range(1); |
0585787aa8ae
imshow.m: Overhaul function and support integer images (bug #41240).
Rik <rik@octave.org>
parents:
18746
diff
changeset
|
187 endif |
7074 | 188 endif |
189 | |
18747
0585787aa8ae
imshow.m: Overhaul function and support integer images (bug #41240).
Rik <rik@octave.org>
parents:
18746
diff
changeset
|
190 ## FIXME: Commented out 2014/05/01. imagesc and 'clim' will automatically |
0585787aa8ae
imshow.m: Overhaul function and support integer images (bug #41240).
Rik <rik@octave.org>
parents:
18746
diff
changeset
|
191 ## take care of displaying out-of-range data clamped to the limits. |
0585787aa8ae
imshow.m: Overhaul function and support integer images (bug #41240).
Rik <rik@octave.org>
parents:
18746
diff
changeset
|
192 ## Eventually, this can be deleted if no problems arise. |
11597
a066673566da
set clim to [0,1] so that scaled cdatamapping works as intended.
Jordi Gutiérrez Hermoso <jordigh@gmail.com>
parents:
11595
diff
changeset
|
193 ## Clamp the image to the range boundaries |
18747
0585787aa8ae
imshow.m: Overhaul function and support integer images (bug #41240).
Rik <rik@octave.org>
parents:
18746
diff
changeset
|
194 ##if (! (truecolor || indexed || islogical (im))) |
0585787aa8ae
imshow.m: Overhaul function and support integer images (bug #41240).
Rik <rik@octave.org>
parents:
18746
diff
changeset
|
195 ## low = display_range(1); |
0585787aa8ae
imshow.m: Overhaul function and support integer images (bug #41240).
Rik <rik@octave.org>
parents:
18746
diff
changeset
|
196 ## high = display_range(2); |
0585787aa8ae
imshow.m: Overhaul function and support integer images (bug #41240).
Rik <rik@octave.org>
parents:
18746
diff
changeset
|
197 ## im(im < low) = low; |
0585787aa8ae
imshow.m: Overhaul function and support integer images (bug #41240).
Rik <rik@octave.org>
parents:
18746
diff
changeset
|
198 ## im(im > high) = high; |
0585787aa8ae
imshow.m: Overhaul function and support integer images (bug #41240).
Rik <rik@octave.org>
parents:
18746
diff
changeset
|
199 ##endif |
6368 | 200 |
18747
0585787aa8ae
imshow.m: Overhaul function and support integer images (bug #41240).
Rik <rik@octave.org>
parents:
18746
diff
changeset
|
201 if (truecolor || indexed) |
0585787aa8ae
imshow.m: Overhaul function and support integer images (bug #41240).
Rik <rik@octave.org>
parents:
18746
diff
changeset
|
202 htmp = image (xdata, ydata, im); |
5934 | 203 else |
18747
0585787aa8ae
imshow.m: Overhaul function and support integer images (bug #41240).
Rik <rik@octave.org>
parents:
18746
diff
changeset
|
204 htmp = imagesc (xdata, ydata, im, display_range); |
11597
a066673566da
set clim to [0,1] so that scaled cdatamapping works as intended.
Jordi Gutiérrez Hermoso <jordigh@gmail.com>
parents:
11595
diff
changeset
|
205 set (gca (), "clim", display_range); |
5934 | 206 endif |
19867
9fc020886ae9
maint: Clean up m-files to follow Octave coding conventions.
Rik <rik@octave.org>
parents:
19731
diff
changeset
|
207 set (gca (), "visible", "off", "view", [0, 90], |
9fc020886ae9
maint: Clean up m-files to follow Octave coding conventions.
Rik <rik@octave.org>
parents:
19731
diff
changeset
|
208 "ydir", "reverse", "layer", "top"); |
7511
f028e7aa77a7
imshow.m: use axis ("image")
John W. Eaton <jwe@octave.org>
parents:
7331
diff
changeset
|
209 axis ("image"); |
7074 | 210 |
211 if (nargout > 0) | |
18747
0585787aa8ae
imshow.m: Overhaul function and support integer images (bug #41240).
Rik <rik@octave.org>
parents:
18746
diff
changeset
|
212 h = htmp; |
7074 | 213 endif |
214 | |
559 | 215 endfunction |
4836 | 216 |
14237
11949c9795a0
Revamp %!demos in m-files to use Octave coding conventions on spacing, etc.
Rik <octave@nomad.inbox5.com>
parents:
14138
diff
changeset
|
217 |
11949c9795a0
Revamp %!demos in m-files to use Octave coding conventions on spacing, etc.
Rik <octave@nomad.inbox5.com>
parents:
14138
diff
changeset
|
218 %!demo |
11949c9795a0
Revamp %!demos in m-files to use Octave coding conventions on spacing, etc.
Rik <octave@nomad.inbox5.com>
parents:
14138
diff
changeset
|
219 %! clf; |
11949c9795a0
Revamp %!demos in m-files to use Octave coding conventions on spacing, etc.
Rik <octave@nomad.inbox5.com>
parents:
14138
diff
changeset
|
220 %! imshow ("default.img"); |
4836 | 221 |
222 %!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
|
223 %! clf; |
11949c9795a0
Revamp %!demos in m-files to use Octave coding conventions on spacing, etc.
Rik <octave@nomad.inbox5.com>
parents:
14138
diff
changeset
|
224 %! imshow ("default.img"); |
11949c9795a0
Revamp %!demos in m-files to use Octave coding conventions on spacing, etc.
Rik <octave@nomad.inbox5.com>
parents:
14138
diff
changeset
|
225 %! colormap (autumn (64)); |
7074 | 226 |
227 %!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
|
228 %! clf; |
11949c9795a0
Revamp %!demos in m-files to use Octave coding conventions on spacing, etc.
Rik <octave@nomad.inbox5.com>
parents:
14138
diff
changeset
|
229 %! [I, M] = imread ("default.img"); |
11949c9795a0
Revamp %!demos in m-files to use Octave coding conventions on spacing, etc.
Rik <octave@nomad.inbox5.com>
parents:
14138
diff
changeset
|
230 %! imshow (I, M); |
4836 | 231 |
232 %!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
|
233 %! clf; |
11949c9795a0
Revamp %!demos in m-files to use Octave coding conventions on spacing, etc.
Rik <octave@nomad.inbox5.com>
parents:
14138
diff
changeset
|
234 %! [I, M] = imread ("default.img"); |
11949c9795a0
Revamp %!demos in m-files to use Octave coding conventions on spacing, etc.
Rik <octave@nomad.inbox5.com>
parents:
14138
diff
changeset
|
235 %! [R, G, B] = ind2rgb (I, M); |
11949c9795a0
Revamp %!demos in m-files to use Octave coding conventions on spacing, etc.
Rik <octave@nomad.inbox5.com>
parents:
14138
diff
changeset
|
236 %! imshow (cat (3, R, G*0.5, B*0.8)); |
5318 | 237 |
238 %!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
|
239 %! clf; |
11949c9795a0
Revamp %!demos in m-files to use Octave coding conventions on spacing, etc.
Rik <octave@nomad.inbox5.com>
parents:
14138
diff
changeset
|
240 %! imshow (rand (100, 100)); |
5318 | 241 |
242 %!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
|
243 %! clf; |
11949c9795a0
Revamp %!demos in m-files to use Octave coding conventions on spacing, etc.
Rik <octave@nomad.inbox5.com>
parents:
14138
diff
changeset
|
244 %! imshow (rand (100, 100, 3)); |
7074 | 245 |
246 %!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
|
247 %! clf; |
11949c9795a0
Revamp %!demos in m-files to use Octave coding conventions on spacing, etc.
Rik <octave@nomad.inbox5.com>
parents:
14138
diff
changeset
|
248 %! imshow (100*rand (100, 100, 3)); |
7074 | 249 |
250 %!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
|
251 %! clf; |
11949c9795a0
Revamp %!demos in m-files to use Octave coding conventions on spacing, etc.
Rik <octave@nomad.inbox5.com>
parents:
14138
diff
changeset
|
252 %! imshow (rand (100, 100)); |
11949c9795a0
Revamp %!demos in m-files to use Octave coding conventions on spacing, etc.
Rik <octave@nomad.inbox5.com>
parents:
14138
diff
changeset
|
253 %! colormap (jet (64)); |
7074 | 254 |
19867
9fc020886ae9
maint: Clean up m-files to follow Octave coding conventions.
Rik <rik@octave.org>
parents:
19731
diff
changeset
|
255 ## Test input validation |
14237
11949c9795a0
Revamp %!demos in m-files to use Octave coding conventions on spacing, etc.
Rik <octave@nomad.inbox5.com>
parents:
14138
diff
changeset
|
256 %!error imshow () |
11949c9795a0
Revamp %!demos in m-files to use Octave coding conventions on spacing, etc.
Rik <octave@nomad.inbox5.com>
parents:
14138
diff
changeset
|
257 %!error <IM must be an image> imshow ({"cell"}) |
18747
0585787aa8ae
imshow.m: Overhaul function and support integer images (bug #41240).
Rik <rik@octave.org>
parents:
18746
diff
changeset
|
258 %!error <TrueColor image must be uint8> imshow (ones (3,3,3, "uint32")) |
0585787aa8ae
imshow.m: Overhaul function and support integer images (bug #41240).
Rik <rik@octave.org>
parents:
18746
diff
changeset
|
259 %!error <TrueColor image must be uint8> imshow (ones (3,3,3, "int16")) |
14237
11949c9795a0
Revamp %!demos in m-files to use Octave coding conventions on spacing, etc.
Rik <octave@nomad.inbox5.com>
parents:
14138
diff
changeset
|
260 %!error <expecting MxN or MxNx3 matrix> imshow (ones (4,4,4)) |
11949c9795a0
Revamp %!demos in m-files to use Octave coding conventions on spacing, etc.
Rik <octave@nomad.inbox5.com>
parents:
14138
diff
changeset
|
261 |
18773
0461fe1d2a01
imshow.m: Don't popup blank figure during 'make check'
Rik <rik@octave.org>
parents:
18753
diff
changeset
|
262 %!test |
0461fe1d2a01
imshow.m: Don't popup blank figure during 'make check'
Rik <rik@octave.org>
parents:
18753
diff
changeset
|
263 %! hf = figure ("visible", "off"); |
0461fe1d2a01
imshow.m: Don't popup blank figure during 'make check'
Rik <rik@octave.org>
parents:
18753
diff
changeset
|
264 %! unwind_protect |
0461fe1d2a01
imshow.m: Don't popup blank figure during 'make check'
Rik <rik@octave.org>
parents:
18753
diff
changeset
|
265 %! fail ("imshow ([1,1], [2 0 0])", "invalid colormap MAP"); |
19631
db92e7e28e1f
strip trailing whitespace from most source files
John W. Eaton <jwe@octave.org>
parents:
19630
diff
changeset
|
266 %! fail ("imshow ([1,1], [1 0 0 0])", "argument number 2 is invalid"); |
db92e7e28e1f
strip trailing whitespace from most source files
John W. Eaton <jwe@octave.org>
parents:
19630
diff
changeset
|
267 %! fail ('imshow ([1,1], "colormap", [2 0 0])', "invalid colormap"); |
db92e7e28e1f
strip trailing whitespace from most source files
John W. Eaton <jwe@octave.org>
parents:
19630
diff
changeset
|
268 %! fail ('imshow ([1,1], "xdata", ones (2,2))', "xdata must be a vector"); |
db92e7e28e1f
strip trailing whitespace from most source files
John W. Eaton <jwe@octave.org>
parents:
19630
diff
changeset
|
269 %! fail ('imshow ([1,1], "ydata", ones (2,2))', "ydata must be a vector"); |
18773
0461fe1d2a01
imshow.m: Don't popup blank figure during 'make check'
Rik <rik@octave.org>
parents:
18753
diff
changeset
|
270 %! fail ('imshow ([1,1], "foobar")', "warning", "unrecognized property foobar") |
19631
db92e7e28e1f
strip trailing whitespace from most source files
John W. Eaton <jwe@octave.org>
parents:
19630
diff
changeset
|
271 %! fail ("imshow ([1,1], {1})", "argument number 2 is invalid"); |
18773
0461fe1d2a01
imshow.m: Don't popup blank figure during 'make check'
Rik <rik@octave.org>
parents:
18753
diff
changeset
|
272 %! fail ("imshow ([1+i,1-i])", "warning", "only showing real part of complex image"); |
0461fe1d2a01
imshow.m: Don't popup blank figure during 'make check'
Rik <rik@octave.org>
parents:
18753
diff
changeset
|
273 %! unwind_protect_cleanup |
0461fe1d2a01
imshow.m: Don't popup blank figure during 'make check'
Rik <rik@octave.org>
parents:
18753
diff
changeset
|
274 %! close (hf); |
0461fe1d2a01
imshow.m: Don't popup blank figure during 'make check'
Rik <rik@octave.org>
parents:
18753
diff
changeset
|
275 %! end_unwind_protect |
0461fe1d2a01
imshow.m: Don't popup blank figure during 'make check'
Rik <rik@octave.org>
parents:
18753
diff
changeset
|
276 |