Mercurial > hg > octave-nkf
annotate scripts/image/rgb2ind.m @ 20279:db30302bedc3
Added tag rc-4-0-0-3 for changeset 065f933ef083
author | John W. Eaton <jwe@octave.org> |
---|---|
date | Fri, 10 Apr 2015 14:41:21 -0400 |
parents | 9fc020886ae9 |
children | 21dbaf135667 |
rev | line source |
---|---|
19898
4197fc428c7d
maint: Update copyright notices for 2015.
John W. Eaton <jwe@octave.org>
parents:
18075
diff
changeset
|
1 ## Copyright (C) 1994-2015 John W. Eaton |
15687
89c8d8f8f87b
rgb2ind: find unique RGB values for indexed image and scale colormap for correct range
Carnë Draug <carandraug+dev@gmail.com>
parents:
14260
diff
changeset
|
2 ## Copyright (C) 2012 Carnë Draug |
2313 | 3 ## |
4 ## This file is part of Octave. | |
5 ## | |
6 ## Octave is free software; you can redistribute it and/or modify it | |
7 ## under the terms of the GNU General Public License as published by | |
7016 | 8 ## the Free Software Foundation; either version 3 of the License, or (at |
9 ## your option) any later version. | |
2313 | 10 ## |
11 ## Octave is distributed in the hope that it will be useful, but | |
12 ## WITHOUT ANY WARRANTY; without even the implied warranty of | |
13 ## MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU | |
14 ## General Public License for more details. | |
15 ## | |
16 ## You should have received a copy of the GNU General Public License | |
7016 | 17 ## along with Octave; see the file COPYING. If not, see |
18 ## <http://www.gnu.org/licenses/>. | |
1024 | 19 |
3381 | 20 ## -*- texinfo -*- |
5922 | 21 ## @deftypefn {Function File} {[@var{x}, @var{map}] =} rgb2ind (@var{rgb}) |
11469
c776f063fefe
Overhaul m-script files to use common variable name between code and documentation.
Rik <octave@nomad.inbox5.com>
parents:
8920
diff
changeset
|
22 ## @deftypefnx {Function File} {[@var{x}, @var{map}] =} rgb2ind (@var{R}, @var{G}, @var{B}) |
15714
b1cd65881592
Clean up scripts in image directory.
Rik <rik@octave.org>
parents:
15693
diff
changeset
|
23 ## Convert an image in red-green-blue (RGB) color space to an indexed image. |
16630
5d6243c2acbf
rgb2ind.m: Enable handling of ND images, and enable n,tol,map,dither as inputs.
Adam H Aitkenhead <adamhaitkenhead@gmail.com>
parents:
15715
diff
changeset
|
24 ## |
17992
b8cd17571a1d
rgb2ind: support for N-dimensional images (bug #40664)
Carnë Draug <carandraug@octave.org>
parents:
17990
diff
changeset
|
25 ## The input image @var{rgb} can be specified as a single matrix of size |
b8cd17571a1d
rgb2ind: support for N-dimensional images (bug #40664)
Carnë Draug <carandraug@octave.org>
parents:
17990
diff
changeset
|
26 ## @nospell{MxNx3}, or as three separate variables, @var{R}, @var{G}, and |
20001
a0c9c85860c0
doc: Spellcheck documentation before 4.0 release.
Rik <rik@octave.org>
parents:
19898
diff
changeset
|
27 ## @var{B}, its three color channels, red, green, and blue. |
17992
b8cd17571a1d
rgb2ind: support for N-dimensional images (bug #40664)
Carnë Draug <carandraug@octave.org>
parents:
17990
diff
changeset
|
28 ## |
b8cd17571a1d
rgb2ind: support for N-dimensional images (bug #40664)
Carnë Draug <carandraug@octave.org>
parents:
17990
diff
changeset
|
29 ## It outputs an indexed image @var{x} and a colormap @var{map} to interpret |
b8cd17571a1d
rgb2ind: support for N-dimensional images (bug #40664)
Carnë Draug <carandraug@octave.org>
parents:
17990
diff
changeset
|
30 ## an image exactly the same as the input. No dithering or other form of color |
b8cd17571a1d
rgb2ind: support for N-dimensional images (bug #40664)
Carnë Draug <carandraug@octave.org>
parents:
17990
diff
changeset
|
31 ## quantization is performed. The output class of the indexed image @var{x} |
b8cd17571a1d
rgb2ind: support for N-dimensional images (bug #40664)
Carnë Draug <carandraug@octave.org>
parents:
17990
diff
changeset
|
32 ## can be uint8, uint16 or double, whichever is required to specify the |
18075
24759ac2b8cb
doc: Periodic spellcheck of documentation
Rik <rik@octave.org>
parents:
17992
diff
changeset
|
33 ## number of unique colors in the image (which will be equal to the number |
17992
b8cd17571a1d
rgb2ind: support for N-dimensional images (bug #40664)
Carnë Draug <carandraug@octave.org>
parents:
17990
diff
changeset
|
34 ## of rows in @var{map}) in order |
b8cd17571a1d
rgb2ind: support for N-dimensional images (bug #40664)
Carnë Draug <carandraug@octave.org>
parents:
17990
diff
changeset
|
35 ## |
b8cd17571a1d
rgb2ind: support for N-dimensional images (bug #40664)
Carnë Draug <carandraug@octave.org>
parents:
17990
diff
changeset
|
36 ## Multi-dimensional indexed images (of size @nospell{MxNx3xK}) are also |
b8cd17571a1d
rgb2ind: support for N-dimensional images (bug #40664)
Carnë Draug <carandraug@octave.org>
parents:
17990
diff
changeset
|
37 ## supported, both via a single input (@var{rgb}) or its three colour channels |
b8cd17571a1d
rgb2ind: support for N-dimensional images (bug #40664)
Carnë Draug <carandraug@octave.org>
parents:
17990
diff
changeset
|
38 ## as separate variables. |
b8cd17571a1d
rgb2ind: support for N-dimensional images (bug #40664)
Carnë Draug <carandraug@octave.org>
parents:
17990
diff
changeset
|
39 ## |
14260
1f911333ed3d
doc: Update docstrings for functions in image/ directory
Rik <octave@nomad.inbox5.com>
parents:
14138
diff
changeset
|
40 ## @seealso{ind2rgb, rgb2hsv, rgb2ntsc} |
3373 | 41 ## @end deftypefn |
42 | |
17990
a40156e8b6a7
rgb2ind: backout 5d6243c2acbf removing all quantization (bug #40669)
Carnë Draug <carandraug@octave.org>
parents:
17744
diff
changeset
|
43 ## FIXME: This function has a very different syntax than the Matlab |
a40156e8b6a7
rgb2ind: backout 5d6243c2acbf removing all quantization (bug #40669)
Carnë Draug <carandraug@octave.org>
parents:
17744
diff
changeset
|
44 ## one of the same name. |
a40156e8b6a7
rgb2ind: backout 5d6243c2acbf removing all quantization (bug #40669)
Carnë Draug <carandraug@octave.org>
parents:
17744
diff
changeset
|
45 ## Octave function does not support N, MAP, DITHER, or TOL arguments. |
a40156e8b6a7
rgb2ind: backout 5d6243c2acbf removing all quantization (bug #40669)
Carnë Draug <carandraug@octave.org>
parents:
17744
diff
changeset
|
46 |
3202 | 47 ## Author: Tony Richardson <arichard@stark.cc.oh.us> |
2312 | 48 ## Created: July 1994 |
49 ## Adapted-By: jwe | |
559 | 50 |
17990
a40156e8b6a7
rgb2ind: backout 5d6243c2acbf removing all quantization (bug #40669)
Carnë Draug <carandraug@octave.org>
parents:
17744
diff
changeset
|
51 function [x, map] = rgb2ind (R, G, B) |
1024 | 52 |
17990
a40156e8b6a7
rgb2ind: backout 5d6243c2acbf removing all quantization (bug #40669)
Carnë Draug <carandraug@octave.org>
parents:
17744
diff
changeset
|
53 if (nargin != 1 && nargin != 3) |
a40156e8b6a7
rgb2ind: backout 5d6243c2acbf removing all quantization (bug #40669)
Carnë Draug <carandraug@octave.org>
parents:
17744
diff
changeset
|
54 print_usage (); |
5922 | 55 endif |
11587
c792872f8942
all script files: untabify and strip trailing whitespace
John W. Eaton <jwe@octave.org>
parents:
11523
diff
changeset
|
56 |
17990
a40156e8b6a7
rgb2ind: backout 5d6243c2acbf removing all quantization (bug #40669)
Carnë Draug <carandraug@octave.org>
parents:
17744
diff
changeset
|
57 if (nargin == 1) |
a40156e8b6a7
rgb2ind: backout 5d6243c2acbf removing all quantization (bug #40669)
Carnë Draug <carandraug@octave.org>
parents:
17744
diff
changeset
|
58 rgb = R; |
17992
b8cd17571a1d
rgb2ind: support for N-dimensional images (bug #40664)
Carnë Draug <carandraug@octave.org>
parents:
17990
diff
changeset
|
59 if (ndims (rgb) > 4 || size (rgb, 3) != 3) |
17990
a40156e8b6a7
rgb2ind: backout 5d6243c2acbf removing all quantization (bug #40669)
Carnë Draug <carandraug@octave.org>
parents:
17744
diff
changeset
|
60 error ("rgb2ind: argument is not an RGB image"); |
a40156e8b6a7
rgb2ind: backout 5d6243c2acbf removing all quantization (bug #40669)
Carnë Draug <carandraug@octave.org>
parents:
17744
diff
changeset
|
61 else |
17992
b8cd17571a1d
rgb2ind: support for N-dimensional images (bug #40664)
Carnë Draug <carandraug@octave.org>
parents:
17990
diff
changeset
|
62 R = rgb(:,:,1,:); |
b8cd17571a1d
rgb2ind: support for N-dimensional images (bug #40664)
Carnë Draug <carandraug@octave.org>
parents:
17990
diff
changeset
|
63 G = rgb(:,:,2,:); |
b8cd17571a1d
rgb2ind: support for N-dimensional images (bug #40664)
Carnë Draug <carandraug@octave.org>
parents:
17990
diff
changeset
|
64 B = rgb(:,:,3,:); |
17990
a40156e8b6a7
rgb2ind: backout 5d6243c2acbf removing all quantization (bug #40669)
Carnë Draug <carandraug@octave.org>
parents:
17744
diff
changeset
|
65 endif |
a40156e8b6a7
rgb2ind: backout 5d6243c2acbf removing all quantization (bug #40669)
Carnë Draug <carandraug@octave.org>
parents:
17744
diff
changeset
|
66 elseif (! size_equal (R, G, B)) |
a40156e8b6a7
rgb2ind: backout 5d6243c2acbf removing all quantization (bug #40669)
Carnë Draug <carandraug@octave.org>
parents:
17744
diff
changeset
|
67 error ("rgb2ind: R, G, and B must have the same size"); |
a40156e8b6a7
rgb2ind: backout 5d6243c2acbf removing all quantization (bug #40669)
Carnë Draug <carandraug@octave.org>
parents:
17744
diff
changeset
|
68 endif |
a40156e8b6a7
rgb2ind: backout 5d6243c2acbf removing all quantization (bug #40669)
Carnë Draug <carandraug@octave.org>
parents:
17744
diff
changeset
|
69 |
a40156e8b6a7
rgb2ind: backout 5d6243c2acbf removing all quantization (bug #40669)
Carnë Draug <carandraug@octave.org>
parents:
17744
diff
changeset
|
70 x = reshape (1:numel (R), size (R)); |
a40156e8b6a7
rgb2ind: backout 5d6243c2acbf removing all quantization (bug #40669)
Carnë Draug <carandraug@octave.org>
parents:
17744
diff
changeset
|
71 |
a40156e8b6a7
rgb2ind: backout 5d6243c2acbf removing all quantization (bug #40669)
Carnë Draug <carandraug@octave.org>
parents:
17744
diff
changeset
|
72 map = unique ([R(:) G(:) B(:)], "rows"); |
a40156e8b6a7
rgb2ind: backout 5d6243c2acbf removing all quantization (bug #40669)
Carnë Draug <carandraug@octave.org>
parents:
17744
diff
changeset
|
73 [~, x] = ismember ([R(:) G(:) B(:)], map, "rows"); |
a40156e8b6a7
rgb2ind: backout 5d6243c2acbf removing all quantization (bug #40669)
Carnë Draug <carandraug@octave.org>
parents:
17744
diff
changeset
|
74 x = reshape (x, size (R)); |
559 | 75 |
15687
89c8d8f8f87b
rgb2ind: find unique RGB values for indexed image and scale colormap for correct range
Carnë Draug <carandraug+dev@gmail.com>
parents:
14260
diff
changeset
|
76 ## a colormap is of class double and values between 0 and 1 |
17990
a40156e8b6a7
rgb2ind: backout 5d6243c2acbf removing all quantization (bug #40669)
Carnë Draug <carandraug@octave.org>
parents:
17744
diff
changeset
|
77 switch (class (R)) |
15687
89c8d8f8f87b
rgb2ind: find unique RGB values for indexed image and scale colormap for correct range
Carnë Draug <carandraug+dev@gmail.com>
parents:
14260
diff
changeset
|
78 case {"single", "double", "logical"} |
89c8d8f8f87b
rgb2ind: find unique RGB values for indexed image and scale colormap for correct range
Carnë Draug <carandraug+dev@gmail.com>
parents:
14260
diff
changeset
|
79 ## do nothing, return the same |
89c8d8f8f87b
rgb2ind: find unique RGB values for indexed image and scale colormap for correct range
Carnë Draug <carandraug+dev@gmail.com>
parents:
14260
diff
changeset
|
80 case {"uint8", "uint16"} |
17990
a40156e8b6a7
rgb2ind: backout 5d6243c2acbf removing all quantization (bug #40669)
Carnë Draug <carandraug@octave.org>
parents:
17744
diff
changeset
|
81 map = double (map) / double (intmax (class (R))); |
15687
89c8d8f8f87b
rgb2ind: find unique RGB values for indexed image and scale colormap for correct range
Carnë Draug <carandraug+dev@gmail.com>
parents:
14260
diff
changeset
|
82 case "int16" |
89c8d8f8f87b
rgb2ind: find unique RGB values for indexed image and scale colormap for correct range
Carnë Draug <carandraug+dev@gmail.com>
parents:
14260
diff
changeset
|
83 map = (double (im) + 32768) / 65535; |
89c8d8f8f87b
rgb2ind: find unique RGB values for indexed image and scale colormap for correct range
Carnë Draug <carandraug+dev@gmail.com>
parents:
14260
diff
changeset
|
84 otherwise |
89c8d8f8f87b
rgb2ind: find unique RGB values for indexed image and scale colormap for correct range
Carnë Draug <carandraug+dev@gmail.com>
parents:
14260
diff
changeset
|
85 error ("unsupported image class %s", im_class); |
89c8d8f8f87b
rgb2ind: find unique RGB values for indexed image and scale colormap for correct range
Carnë Draug <carandraug+dev@gmail.com>
parents:
14260
diff
changeset
|
86 endswitch |
559 | 87 |
15687
89c8d8f8f87b
rgb2ind: find unique RGB values for indexed image and scale colormap for correct range
Carnë Draug <carandraug+dev@gmail.com>
parents:
14260
diff
changeset
|
88 ## we convert to the smallest class necessary to encode the image. Matlab |
89c8d8f8f87b
rgb2ind: find unique RGB values for indexed image and scale colormap for correct range
Carnë Draug <carandraug+dev@gmail.com>
parents:
14260
diff
changeset
|
89 ## documentation does not mention what it does when uint16 is not enough... |
89c8d8f8f87b
rgb2ind: find unique RGB values for indexed image and scale colormap for correct range
Carnë Draug <carandraug+dev@gmail.com>
parents:
14260
diff
changeset
|
90 ## When an indexed image is of integer class, there's a -1 offset to the |
89c8d8f8f87b
rgb2ind: find unique RGB values for indexed image and scale colormap for correct range
Carnë Draug <carandraug+dev@gmail.com>
parents:
14260
diff
changeset
|
91 ## colormap, hence the adjustment |
89c8d8f8f87b
rgb2ind: find unique RGB values for indexed image and scale colormap for correct range
Carnë Draug <carandraug+dev@gmail.com>
parents:
14260
diff
changeset
|
92 if (rows (map) < 256) |
89c8d8f8f87b
rgb2ind: find unique RGB values for indexed image and scale colormap for correct range
Carnë Draug <carandraug+dev@gmail.com>
parents:
14260
diff
changeset
|
93 x = uint8 (x - 1); |
89c8d8f8f87b
rgb2ind: find unique RGB values for indexed image and scale colormap for correct range
Carnë Draug <carandraug+dev@gmail.com>
parents:
14260
diff
changeset
|
94 elseif (rows (map) < 65536) |
89c8d8f8f87b
rgb2ind: find unique RGB values for indexed image and scale colormap for correct range
Carnë Draug <carandraug+dev@gmail.com>
parents:
14260
diff
changeset
|
95 x = uint16 (x - 1); |
89c8d8f8f87b
rgb2ind: find unique RGB values for indexed image and scale colormap for correct range
Carnë Draug <carandraug+dev@gmail.com>
parents:
14260
diff
changeset
|
96 else |
89c8d8f8f87b
rgb2ind: find unique RGB values for indexed image and scale colormap for correct range
Carnë Draug <carandraug+dev@gmail.com>
parents:
14260
diff
changeset
|
97 ## leave it as double |
89c8d8f8f87b
rgb2ind: find unique RGB values for indexed image and scale colormap for correct range
Carnë Draug <carandraug+dev@gmail.com>
parents:
14260
diff
changeset
|
98 endif |
15714
b1cd65881592
Clean up scripts in image directory.
Rik <rik@octave.org>
parents:
15693
diff
changeset
|
99 |
559 | 100 endfunction |
15683
806ea52af230
Overhaul m-files in image directory to provide better support for images stored as integers.
Rik <rik@octave.org>
parents:
14260
diff
changeset
|
101 |
20038
9fc020886ae9
maint: Clean up m-files to follow Octave coding conventions.
Rik <rik@octave.org>
parents:
20001
diff
changeset
|
102 ## Test input validation |
15683
806ea52af230
Overhaul m-files in image directory to provide better support for images stored as integers.
Rik <rik@octave.org>
parents:
14260
diff
changeset
|
103 %!error rgb2ind () |
16713
ab5d0b358b94
rgb2ind.m: fix input validation tests
Mike Miller <mtmiller@ieee.org>
parents:
16633
diff
changeset
|
104 %!error rgb2ind (1,2,3,4,5,6,7) |
17992
b8cd17571a1d
rgb2ind: support for N-dimensional images (bug #40664)
Carnë Draug <carandraug@octave.org>
parents:
17990
diff
changeset
|
105 %!error <RGB> rgb2ind (rand (10, 10, 4)) |
15714
b1cd65881592
Clean up scripts in image directory.
Rik <rik@octave.org>
parents:
15693
diff
changeset
|
106 |
17992
b8cd17571a1d
rgb2ind: support for N-dimensional images (bug #40664)
Carnë Draug <carandraug@octave.org>
parents:
17990
diff
changeset
|
107 ## FIXME: the following tests simply make sure that rgb2ind and ind2rgb |
b8cd17571a1d
rgb2ind: support for N-dimensional images (bug #40664)
Carnë Draug <carandraug@octave.org>
parents:
17990
diff
changeset
|
108 ## reverse each other. We should have better tests for this. |
b8cd17571a1d
rgb2ind: support for N-dimensional images (bug #40664)
Carnë Draug <carandraug@octave.org>
parents:
17990
diff
changeset
|
109 |
b8cd17571a1d
rgb2ind: support for N-dimensional images (bug #40664)
Carnë Draug <carandraug@octave.org>
parents:
17990
diff
changeset
|
110 ## Typical usage |
b8cd17571a1d
rgb2ind: support for N-dimensional images (bug #40664)
Carnë Draug <carandraug@octave.org>
parents:
17990
diff
changeset
|
111 %!test |
b8cd17571a1d
rgb2ind: support for N-dimensional images (bug #40664)
Carnë Draug <carandraug@octave.org>
parents:
17990
diff
changeset
|
112 %! rgb = rand (10, 10, 3); |
b8cd17571a1d
rgb2ind: support for N-dimensional images (bug #40664)
Carnë Draug <carandraug@octave.org>
parents:
17990
diff
changeset
|
113 %! [ind, map] = rgb2ind (rgb); |
b8cd17571a1d
rgb2ind: support for N-dimensional images (bug #40664)
Carnë Draug <carandraug@octave.org>
parents:
17990
diff
changeset
|
114 %! assert (ind2rgb (ind, map), rgb); |
b8cd17571a1d
rgb2ind: support for N-dimensional images (bug #40664)
Carnë Draug <carandraug@octave.org>
parents:
17990
diff
changeset
|
115 %! |
b8cd17571a1d
rgb2ind: support for N-dimensional images (bug #40664)
Carnë Draug <carandraug@octave.org>
parents:
17990
diff
changeset
|
116 %! ## test specifying the RGB channels separated |
b8cd17571a1d
rgb2ind: support for N-dimensional images (bug #40664)
Carnë Draug <carandraug@octave.org>
parents:
17990
diff
changeset
|
117 %! [ind, map] = rgb2ind (rgb(:,:,1), rgb(:,:,2), rgb(:,:,3)); |
b8cd17571a1d
rgb2ind: support for N-dimensional images (bug #40664)
Carnë Draug <carandraug@octave.org>
parents:
17990
diff
changeset
|
118 %! assert (ind2rgb (ind, map), rgb); |
b8cd17571a1d
rgb2ind: support for N-dimensional images (bug #40664)
Carnë Draug <carandraug@octave.org>
parents:
17990
diff
changeset
|
119 |
b8cd17571a1d
rgb2ind: support for N-dimensional images (bug #40664)
Carnë Draug <carandraug@octave.org>
parents:
17990
diff
changeset
|
120 ## Test N-dimensional images |
b8cd17571a1d
rgb2ind: support for N-dimensional images (bug #40664)
Carnë Draug <carandraug@octave.org>
parents:
17990
diff
changeset
|
121 %!test |
b8cd17571a1d
rgb2ind: support for N-dimensional images (bug #40664)
Carnë Draug <carandraug@octave.org>
parents:
17990
diff
changeset
|
122 %! rgb = rand (10, 10, 3, 10); |
b8cd17571a1d
rgb2ind: support for N-dimensional images (bug #40664)
Carnë Draug <carandraug@octave.org>
parents:
17990
diff
changeset
|
123 %! [ind, map] = rgb2ind (rgb); |
b8cd17571a1d
rgb2ind: support for N-dimensional images (bug #40664)
Carnë Draug <carandraug@octave.org>
parents:
17990
diff
changeset
|
124 %! assert (ind2rgb (ind, map), rgb); |
b8cd17571a1d
rgb2ind: support for N-dimensional images (bug #40664)
Carnë Draug <carandraug@octave.org>
parents:
17990
diff
changeset
|
125 %! [ind, map] = rgb2ind (rgb(:,:,1,:), rgb(:,:,2,:), rgb(:,:,3,:)); |
b8cd17571a1d
rgb2ind: support for N-dimensional images (bug #40664)
Carnë Draug <carandraug@octave.org>
parents:
17990
diff
changeset
|
126 %! assert (ind2rgb (ind, map), rgb); |
b8cd17571a1d
rgb2ind: support for N-dimensional images (bug #40664)
Carnë Draug <carandraug@octave.org>
parents:
17990
diff
changeset
|
127 |
b8cd17571a1d
rgb2ind: support for N-dimensional images (bug #40664)
Carnë Draug <carandraug@octave.org>
parents:
17990
diff
changeset
|
128 ## Test output class |
b8cd17571a1d
rgb2ind: support for N-dimensional images (bug #40664)
Carnë Draug <carandraug@octave.org>
parents:
17990
diff
changeset
|
129 %!test |
b8cd17571a1d
rgb2ind: support for N-dimensional images (bug #40664)
Carnë Draug <carandraug@octave.org>
parents:
17990
diff
changeset
|
130 %! ## this should have more than 65536 unique colors |
b8cd17571a1d
rgb2ind: support for N-dimensional images (bug #40664)
Carnë Draug <carandraug@octave.org>
parents:
17990
diff
changeset
|
131 %! rgb = rand (1000, 1000, 3); |
b8cd17571a1d
rgb2ind: support for N-dimensional images (bug #40664)
Carnë Draug <carandraug@octave.org>
parents:
17990
diff
changeset
|
132 %! [ind, map] = rgb2ind (rgb); |
b8cd17571a1d
rgb2ind: support for N-dimensional images (bug #40664)
Carnë Draug <carandraug@octave.org>
parents:
17990
diff
changeset
|
133 %! assert (class (ind), "double"); |
b8cd17571a1d
rgb2ind: support for N-dimensional images (bug #40664)
Carnë Draug <carandraug@octave.org>
parents:
17990
diff
changeset
|
134 %! assert (class (map), "double"); |
b8cd17571a1d
rgb2ind: support for N-dimensional images (bug #40664)
Carnë Draug <carandraug@octave.org>
parents:
17990
diff
changeset
|
135 %! |
b8cd17571a1d
rgb2ind: support for N-dimensional images (bug #40664)
Carnë Draug <carandraug@octave.org>
parents:
17990
diff
changeset
|
136 %! ## and this should have between 255 and 65536 unique colors |
b8cd17571a1d
rgb2ind: support for N-dimensional images (bug #40664)
Carnë Draug <carandraug@octave.org>
parents:
17990
diff
changeset
|
137 %! rgb = rand (20, 20, 3); |
b8cd17571a1d
rgb2ind: support for N-dimensional images (bug #40664)
Carnë Draug <carandraug@octave.org>
parents:
17990
diff
changeset
|
138 %! [ind, map] = rgb2ind (rgb); |
b8cd17571a1d
rgb2ind: support for N-dimensional images (bug #40664)
Carnë Draug <carandraug@octave.org>
parents:
17990
diff
changeset
|
139 %! assert (class (ind), "uint16"); |
b8cd17571a1d
rgb2ind: support for N-dimensional images (bug #40664)
Carnë Draug <carandraug@octave.org>
parents:
17990
diff
changeset
|
140 %! assert (class (map), "double"); |
b8cd17571a1d
rgb2ind: support for N-dimensional images (bug #40664)
Carnë Draug <carandraug@octave.org>
parents:
17990
diff
changeset
|
141 %! |
b8cd17571a1d
rgb2ind: support for N-dimensional images (bug #40664)
Carnë Draug <carandraug@octave.org>
parents:
17990
diff
changeset
|
142 %! ## and this certainly less than 256 unique colors |
b8cd17571a1d
rgb2ind: support for N-dimensional images (bug #40664)
Carnë Draug <carandraug@octave.org>
parents:
17990
diff
changeset
|
143 %! rgb = rand (10, 10, 3); |
b8cd17571a1d
rgb2ind: support for N-dimensional images (bug #40664)
Carnë Draug <carandraug@octave.org>
parents:
17990
diff
changeset
|
144 %! [ind, map] = rgb2ind (rgb); |
b8cd17571a1d
rgb2ind: support for N-dimensional images (bug #40664)
Carnë Draug <carandraug@octave.org>
parents:
17990
diff
changeset
|
145 %! assert (class (ind), "uint8"); |
b8cd17571a1d
rgb2ind: support for N-dimensional images (bug #40664)
Carnë Draug <carandraug@octave.org>
parents:
17990
diff
changeset
|
146 %! assert (class (map), "double"); |
b8cd17571a1d
rgb2ind: support for N-dimensional images (bug #40664)
Carnë Draug <carandraug@octave.org>
parents:
17990
diff
changeset
|
147 |