Mercurial > octave
annotate scripts/image/ind2rgb.m @ 32632:2e484f9f1f18 stable
maint: update Octave Project Developers copyright for the new year
author | John W. Eaton <jwe@octave.org> |
---|---|
date | Fri, 22 Dec 2023 12:08:17 -0500 |
parents | 597f3ee61a48 |
children |
rev | line source |
---|---|
27923
bd51beb6205e
update formatting of copyright notices
John W. Eaton <jwe@octave.org>
parents:
27919
diff
changeset
|
1 ######################################################################## |
bd51beb6205e
update formatting of copyright notices
John W. Eaton <jwe@octave.org>
parents:
27919
diff
changeset
|
2 ## |
32632
2e484f9f1f18
maint: update Octave Project Developers copyright for the new year
John W. Eaton <jwe@octave.org>
parents:
31706
diff
changeset
|
3 ## Copyright (C) 1994-2024 The Octave Project Developers |
27918
b442ec6dda5c
use centralized file for copyright info for individual contributors
John W. Eaton <jwe@octave.org>
parents:
26376
diff
changeset
|
4 ## |
27923
bd51beb6205e
update formatting of copyright notices
John W. Eaton <jwe@octave.org>
parents:
27919
diff
changeset
|
5 ## See the file COPYRIGHT.md in the top-level directory of this |
bd51beb6205e
update formatting of copyright notices
John W. Eaton <jwe@octave.org>
parents:
27919
diff
changeset
|
6 ## distribution or <https://octave.org/copyright/>. |
2313 | 7 ## |
8 ## This file is part of Octave. | |
9 ## | |
24534
194eb4bd202b
maint: Update punctuation for GPL v3 license text.
Rik <rik@octave.org>
parents:
23484
diff
changeset
|
10 ## Octave is free software: you can redistribute it and/or modify it |
2313 | 11 ## under the terms of the GNU General Public License as published by |
24534
194eb4bd202b
maint: Update punctuation for GPL v3 license text.
Rik <rik@octave.org>
parents:
23484
diff
changeset
|
12 ## the Free Software Foundation, either version 3 of the License, or |
22755
3a2b891d0b33
maint: Standardize Copyright formatting.
Rik <rik@octave.org>
parents:
22323
diff
changeset
|
13 ## (at your option) any later version. |
2313 | 14 ## |
15 ## Octave is distributed in the hope that it will be useful, but | |
16 ## WITHOUT ANY WARRANTY; without even the implied warranty of | |
22755
3a2b891d0b33
maint: Standardize Copyright formatting.
Rik <rik@octave.org>
parents:
22323
diff
changeset
|
17 ## MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
3a2b891d0b33
maint: Standardize Copyright formatting.
Rik <rik@octave.org>
parents:
22323
diff
changeset
|
18 ## GNU General Public License for more details. |
2313 | 19 ## |
20 ## You should have received a copy of the GNU General Public License | |
7016 | 21 ## along with Octave; see the file COPYING. If not, see |
24534
194eb4bd202b
maint: Update punctuation for GPL v3 license text.
Rik <rik@octave.org>
parents:
23484
diff
changeset
|
22 ## <https://www.gnu.org/licenses/>. |
27923
bd51beb6205e
update formatting of copyright notices
John W. Eaton <jwe@octave.org>
parents:
27919
diff
changeset
|
23 ## |
bd51beb6205e
update formatting of copyright notices
John W. Eaton <jwe@octave.org>
parents:
27919
diff
changeset
|
24 ######################################################################## |
1024 | 25 |
3381 | 26 ## -*- texinfo -*- |
20852
516bb87ea72e
2015 Code Sprint: remove class of function from docstring for all m-files.
Rik <rik@octave.org>
parents:
19833
diff
changeset
|
27 ## @deftypefn {} {@var{rgb} =} ind2rgb (@var{x}, @var{map}) |
516bb87ea72e
2015 Code Sprint: remove class of function from docstring for all m-files.
Rik <rik@octave.org>
parents:
19833
diff
changeset
|
28 ## @deftypefnx {} {[@var{R}, @var{G}, @var{B}] =} ind2rgb (@var{x}, @var{map}) |
2311 | 29 ## Convert an indexed image to red, green, and blue color components. |
15712
74ff287f41cb
Remove default colormap for ind2rgb and ind2gray.
Carnë Draug <carandraug+dev@gmail.com>
parents:
15693
diff
changeset
|
30 ## |
74ff287f41cb
Remove default colormap for ind2rgb and ind2gray.
Carnë Draug <carandraug+dev@gmail.com>
parents:
15693
diff
changeset
|
31 ## The image @var{x} must be an indexed image which will be converted using the |
15714
b1cd65881592
Clean up scripts in image directory.
Rik <rik@octave.org>
parents:
15712
diff
changeset
|
32 ## colormap @var{map}. If @var{map} does not contain enough colors for the |
15712
74ff287f41cb
Remove default colormap for ind2rgb and ind2gray.
Carnë Draug <carandraug+dev@gmail.com>
parents:
15693
diff
changeset
|
33 ## image, pixels in @var{x} outside the range are mapped to the last color in |
74ff287f41cb
Remove default colormap for ind2rgb and ind2gray.
Carnë Draug <carandraug+dev@gmail.com>
parents:
15693
diff
changeset
|
34 ## the map. |
15683
806ea52af230
Overhaul m-files in image directory to provide better support for images stored as integers.
Rik <rik@octave.org>
parents:
15515
diff
changeset
|
35 ## |
16826
a4969508008e
doc: Periodic spellcheck of the documentation.
Rik <rik@octave.org>
parents:
16816
diff
changeset
|
36 ## The output may be a single RGB image (@nospell{MxNx3} matrix where M and N |
a4969508008e
doc: Periodic spellcheck of the documentation.
Rik <rik@octave.org>
parents:
16816
diff
changeset
|
37 ## are the original image @var{x} dimensions, one for each of the red, green |
a4969508008e
doc: Periodic spellcheck of the documentation.
Rik <rik@octave.org>
parents:
16816
diff
changeset
|
38 ## and blue channels). Alternatively, the individual red, green, and blue |
a4969508008e
doc: Periodic spellcheck of the documentation.
Rik <rik@octave.org>
parents:
16816
diff
changeset
|
39 ## color matrices of size @nospell{MxN} may be returned. |
15712
74ff287f41cb
Remove default colormap for ind2rgb and ind2gray.
Carnë Draug <carandraug+dev@gmail.com>
parents:
15693
diff
changeset
|
40 ## |
16826
a4969508008e
doc: Periodic spellcheck of the documentation.
Rik <rik@octave.org>
parents:
16816
diff
changeset
|
41 ## Multi-dimensional indexed images (of size @nospell{MxNx1xK}) are also |
a4969508008e
doc: Periodic spellcheck of the documentation.
Rik <rik@octave.org>
parents:
16816
diff
changeset
|
42 ## supported. |
16707
4c11e9bcb796
ind2rgb: add support for multidimensional indexed images.
Carnë Draug <carandraug@octave.org>
parents:
16434
diff
changeset
|
43 ## |
24611
afbef2f579c9
ngb2ntsc.m, ntsc2rgb.m: Remove functions moved to image package.
Rik <rik@octave.org>
parents:
24534
diff
changeset
|
44 ## @seealso{rgb2ind, ind2gray, hsv2rgb} |
3373 | 45 ## @end deftypefn |
904 | 46 |
15712
74ff287f41cb
Remove default colormap for ind2rgb and ind2gray.
Carnë Draug <carandraug+dev@gmail.com>
parents:
15693
diff
changeset
|
47 function [R, G, B] = ind2rgb (x, map) |
1024 | 48 |
15712
74ff287f41cb
Remove default colormap for ind2rgb and ind2gray.
Carnë Draug <carandraug+dev@gmail.com>
parents:
15693
diff
changeset
|
49 if (nargin != 2) |
6046 | 50 print_usage (); |
559 | 51 endif |
15689
14b7679891dd
ind2sub ind2gray: merge common code in private function, expanding fix for images when integers, input check, and expansion of colormap to ind2gray.
Carnë Draug <carandraug+dev@gmail.com>
parents:
15688
diff
changeset
|
52 [x, map] = ind2x ("ind2rgb", x, map); |
11587
c792872f8942
all script files: untabify and strip trailing whitespace
John W. Eaton <jwe@octave.org>
parents:
11523
diff
changeset
|
53 |
6247 | 54 ## Compute result |
16434
aa81cfa5c359
ind2x.m and ind2rgb.m: Enable handling of ND images
Adam H Aitkenhead <adamhaitkenhead@gmail.com>
parents:
15714
diff
changeset
|
55 sz = size (x); |
aa81cfa5c359
ind2x.m and ind2rgb.m: Enable handling of ND images
Adam H Aitkenhead <adamhaitkenhead@gmail.com>
parents:
15714
diff
changeset
|
56 R = reshape (map(x(:), 1), sz); |
aa81cfa5c359
ind2x.m and ind2rgb.m: Enable handling of ND images
Adam H Aitkenhead <adamhaitkenhead@gmail.com>
parents:
15714
diff
changeset
|
57 G = reshape (map(x(:), 2), sz); |
aa81cfa5c359
ind2x.m and ind2rgb.m: Enable handling of ND images
Adam H Aitkenhead <adamhaitkenhead@gmail.com>
parents:
15714
diff
changeset
|
58 B = reshape (map(x(:), 3), sz); |
559 | 59 |
16434
aa81cfa5c359
ind2x.m and ind2rgb.m: Enable handling of ND images
Adam H Aitkenhead <adamhaitkenhead@gmail.com>
parents:
15714
diff
changeset
|
60 ## Use ND array if only one output is requested. |
6247 | 61 if (nargout <= 1) |
16707
4c11e9bcb796
ind2rgb: add support for multidimensional indexed images.
Carnë Draug <carandraug@octave.org>
parents:
16434
diff
changeset
|
62 if (ndims (x) == 2) |
4c11e9bcb796
ind2rgb: add support for multidimensional indexed images.
Carnë Draug <carandraug@octave.org>
parents:
16434
diff
changeset
|
63 R = reshape ([R(:); G(:); B(:)], [sz, 3]); |
4c11e9bcb796
ind2rgb: add support for multidimensional indexed images.
Carnë Draug <carandraug@octave.org>
parents:
16434
diff
changeset
|
64 elseif (ndims (x) == 4) |
19833
9fc020886ae9
maint: Clean up m-files to follow Octave coding conventions.
Rik <rik@octave.org>
parents:
19697
diff
changeset
|
65 R = permute (reshape ([R(:); G(:); B(:)], [sz(1) sz(2) sz(4) 3]), ... |
9fc020886ae9
maint: Clean up m-files to follow Octave coding conventions.
Rik <rik@octave.org>
parents:
19697
diff
changeset
|
66 [1 2 4 3]); |
16707
4c11e9bcb796
ind2rgb: add support for multidimensional indexed images.
Carnë Draug <carandraug@octave.org>
parents:
16434
diff
changeset
|
67 else |
4c11e9bcb796
ind2rgb: add support for multidimensional indexed images.
Carnë Draug <carandraug@octave.org>
parents:
16434
diff
changeset
|
68 ## we should never reach here since ind2x() should filter them out |
28905
89a425f2c202
maint: Use Octave convention that error() messages don't end with a period.
Rik <rik@octave.org>
parents:
28896
diff
changeset
|
69 error ("ind2rgb: an indexed image must have 2 or 4 dimensions"); |
16707
4c11e9bcb796
ind2rgb: add support for multidimensional indexed images.
Carnë Draug <carandraug@octave.org>
parents:
16434
diff
changeset
|
70 endif |
6247 | 71 endif |
15683
806ea52af230
Overhaul m-files in image directory to provide better support for images stored as integers.
Rik <rik@octave.org>
parents:
15515
diff
changeset
|
72 |
559 | 73 endfunction |
15683
806ea52af230
Overhaul m-files in image directory to provide better support for images stored as integers.
Rik <rik@octave.org>
parents:
15515
diff
changeset
|
74 |
15714
b1cd65881592
Clean up scripts in image directory.
Rik <rik@octave.org>
parents:
15712
diff
changeset
|
75 |
15688
4db08f52a6ed
ind2rgb: correction for indexes when image is uint class. Added tests block.
Carnë Draug <carandraug+dev@gmail.com>
parents:
15515
diff
changeset
|
76 %!shared img, map, ergb, rgb, r, g, b |
4db08f52a6ed
ind2rgb: correction for indexes when image is uint class. Added tests block.
Carnë Draug <carandraug+dev@gmail.com>
parents:
15515
diff
changeset
|
77 %! img = [2 4 5; 3 2 5; 1 2 4]; |
4db08f52a6ed
ind2rgb: correction for indexes when image is uint class. Added tests block.
Carnë Draug <carandraug+dev@gmail.com>
parents:
15515
diff
changeset
|
78 %! map = [0.0 0.0 0.0 |
4db08f52a6ed
ind2rgb: correction for indexes when image is uint class. Added tests block.
Carnë Draug <carandraug+dev@gmail.com>
parents:
15515
diff
changeset
|
79 %! 0.2 0.4 0.6 |
4db08f52a6ed
ind2rgb: correction for indexes when image is uint class. Added tests block.
Carnë Draug <carandraug+dev@gmail.com>
parents:
15515
diff
changeset
|
80 %! 0.4 0.4 0.5 |
4db08f52a6ed
ind2rgb: correction for indexes when image is uint class. Added tests block.
Carnë Draug <carandraug+dev@gmail.com>
parents:
15515
diff
changeset
|
81 %! 0.3 0.7 1.0 |
4db08f52a6ed
ind2rgb: correction for indexes when image is uint class. Added tests block.
Carnë Draug <carandraug+dev@gmail.com>
parents:
15515
diff
changeset
|
82 %! 0.1 0.5 0.8]; |
4db08f52a6ed
ind2rgb: correction for indexes when image is uint class. Added tests block.
Carnë Draug <carandraug+dev@gmail.com>
parents:
15515
diff
changeset
|
83 %! ergb(:,:,1) = [0.2 0.3 0.1; 0.4 0.2 0.1; 0.0 0.2 0.3]; |
4db08f52a6ed
ind2rgb: correction for indexes when image is uint class. Added tests block.
Carnë Draug <carandraug+dev@gmail.com>
parents:
15515
diff
changeset
|
84 %! ergb(:,:,2) = [0.4 0.7 0.5; 0.4 0.4 0.5; 0.0 0.4 0.7]; |
4db08f52a6ed
ind2rgb: correction for indexes when image is uint class. Added tests block.
Carnë Draug <carandraug+dev@gmail.com>
parents:
15515
diff
changeset
|
85 %! ergb(:,:,3) = [0.6 1.0 0.8; 0.5 0.6 0.8; 0.0 0.6 1.0]; |
4db08f52a6ed
ind2rgb: correction for indexes when image is uint class. Added tests block.
Carnë Draug <carandraug+dev@gmail.com>
parents:
15515
diff
changeset
|
86 %! ## test basic usage with 1 and 3 outputs |
4db08f52a6ed
ind2rgb: correction for indexes when image is uint class. Added tests block.
Carnë Draug <carandraug+dev@gmail.com>
parents:
15515
diff
changeset
|
87 %! [rgb] = ind2rgb (img, map); |
4db08f52a6ed
ind2rgb: correction for indexes when image is uint class. Added tests block.
Carnë Draug <carandraug+dev@gmail.com>
parents:
15515
diff
changeset
|
88 %! [r, g, b] = ind2rgb (img, map); |
18566
875f4510d6dc
Accept indexed images with color values below the first colormap entry (bug #41851).
Rik <rik@octave.org>
parents:
17744
diff
changeset
|
89 %! |
875f4510d6dc
Accept indexed images with color values below the first colormap entry (bug #41851).
Rik <rik@octave.org>
parents:
17744
diff
changeset
|
90 %!assert (ergb, rgb) |
875f4510d6dc
Accept indexed images with color values below the first colormap entry (bug #41851).
Rik <rik@octave.org>
parents:
17744
diff
changeset
|
91 %!assert (ergb, reshape ([r(:) g(:) b(:)], [size(img) 3])) |
875f4510d6dc
Accept indexed images with color values below the first colormap entry (bug #41851).
Rik <rik@octave.org>
parents:
17744
diff
changeset
|
92 %!test |
15688
4db08f52a6ed
ind2rgb: correction for indexes when image is uint class. Added tests block.
Carnë Draug <carandraug+dev@gmail.com>
parents:
15515
diff
changeset
|
93 %! ## test correction for integers |
18566
875f4510d6dc
Accept indexed images with color values below the first colormap entry (bug #41851).
Rik <rik@octave.org>
parents:
17744
diff
changeset
|
94 %! img = uint8 (img - 1); |
15688
4db08f52a6ed
ind2rgb: correction for indexes when image is uint class. Added tests block.
Carnë Draug <carandraug+dev@gmail.com>
parents:
15515
diff
changeset
|
95 %! [rgb] = ind2rgb (img, map); |
18566
875f4510d6dc
Accept indexed images with color values below the first colormap entry (bug #41851).
Rik <rik@octave.org>
parents:
17744
diff
changeset
|
96 %! assert (ergb, rgb); |
875f4510d6dc
Accept indexed images with color values below the first colormap entry (bug #41851).
Rik <rik@octave.org>
parents:
17744
diff
changeset
|
97 %!test |
19597
db92e7e28e1f
strip trailing whitespace from most source files
John W. Eaton <jwe@octave.org>
parents:
18566
diff
changeset
|
98 %! ## Check that values below lower bound are mapped to first color value |
19670
e5facc6eec13
Silence warning messages in %!test code.
Rik <rik@octave.org>
parents:
19597
diff
changeset
|
99 %! warning ("off", "Octave:ind2rgb:invalid-idx-img", "local"); |
18566
875f4510d6dc
Accept indexed images with color values below the first colormap entry (bug #41851).
Rik <rik@octave.org>
parents:
17744
diff
changeset
|
100 %! rgb = ind2rgb ([-1 0 2], gray (64)); |
875f4510d6dc
Accept indexed images with color values below the first colormap entry (bug #41851).
Rik <rik@octave.org>
parents:
17744
diff
changeset
|
101 %! assert (rgb(:,1:2,:), zeros (1,2,3)); |
875f4510d6dc
Accept indexed images with color values below the first colormap entry (bug #41851).
Rik <rik@octave.org>
parents:
17744
diff
changeset
|
102 %! assert (rgb(:,3,:), 1/63 * ones (1,1,3)); |
15683
806ea52af230
Overhaul m-files in image directory to provide better support for images stored as integers.
Rik <rik@octave.org>
parents:
15515
diff
changeset
|
103 |
19833
9fc020886ae9
maint: Clean up m-files to follow Octave coding conventions.
Rik <rik@octave.org>
parents:
19697
diff
changeset
|
104 ## Test input validation |
28896
90fea9cc9caa
test: Add expected error message <Invalid call> to BIST tests for nargin.
Rik <rik@octave.org>
parents:
28885
diff
changeset
|
105 %!error <Invalid call> ind2rgb () |
90fea9cc9caa
test: Add expected error message <Invalid call> to BIST tests for nargin.
Rik <rik@octave.org>
parents:
28885
diff
changeset
|
106 %!error <Invalid call> ind2rgb (1) |
18566
875f4510d6dc
Accept indexed images with color values below the first colormap entry (bug #41851).
Rik <rik@octave.org>
parents:
17744
diff
changeset
|
107 %!error <X must be an indexed image> ind2rgb (ones (3,3,3), jet (64)) |
15714
b1cd65881592
Clean up scripts in image directory.
Rik <rik@octave.org>
parents:
15712
diff
changeset
|
108 %!error <X must be an indexed image> ind2rgb (1+i, jet (64)) |
b1cd65881592
Clean up scripts in image directory.
Rik <rik@octave.org>
parents:
15712
diff
changeset
|
109 %!error <X must be an indexed image> ind2rgb (sparse (1), jet (64)) |
b1cd65881592
Clean up scripts in image directory.
Rik <rik@octave.org>
parents:
15712
diff
changeset
|
110 %!error <X must be an indexed image> ind2rgb (1.1, jet (64)) |
18566
875f4510d6dc
Accept indexed images with color values below the first colormap entry (bug #41851).
Rik <rik@octave.org>
parents:
17744
diff
changeset
|
111 %!error <X must be an indexed image> ind2rgb ({1}, jet (64)) |
15683
806ea52af230
Overhaul m-files in image directory to provide better support for images stored as integers.
Rik <rik@octave.org>
parents:
15515
diff
changeset
|
112 %!error <MAP must be a valid colormap> ind2rgb (1, {1}) |
806ea52af230
Overhaul m-files in image directory to provide better support for images stored as integers.
Rik <rik@octave.org>
parents:
15515
diff
changeset
|
113 %!error <MAP must be a valid colormap> ind2rgb (1, 1+i) |
806ea52af230
Overhaul m-files in image directory to provide better support for images stored as integers.
Rik <rik@octave.org>
parents:
15515
diff
changeset
|
114 %!error <MAP must be a valid colormap> ind2rgb (1, ones (2,2,2)) |
806ea52af230
Overhaul m-files in image directory to provide better support for images stored as integers.
Rik <rik@octave.org>
parents:
15515
diff
changeset
|
115 %!error <MAP must be a valid colormap> ind2rgb (1, ones (2,4)) |
806ea52af230
Overhaul m-files in image directory to provide better support for images stored as integers.
Rik <rik@octave.org>
parents:
15515
diff
changeset
|
116 %!error <MAP must be a valid colormap> ind2rgb (1, [-1]) |
806ea52af230
Overhaul m-files in image directory to provide better support for images stored as integers.
Rik <rik@octave.org>
parents:
15515
diff
changeset
|
117 %!error <MAP must be a valid colormap> ind2rgb (1, [2]) |
15714
b1cd65881592
Clean up scripts in image directory.
Rik <rik@octave.org>
parents:
15712
diff
changeset
|
118 |
18566
875f4510d6dc
Accept indexed images with color values below the first colormap entry (bug #41851).
Rik <rik@octave.org>
parents:
17744
diff
changeset
|
119 %!warning <contains colors outside of colormap> ind2rgb ([-1 1], jet (64)); |
875f4510d6dc
Accept indexed images with color values below the first colormap entry (bug #41851).
Rik <rik@octave.org>
parents:
17744
diff
changeset
|
120 %!warning <contains colors outside of colormap> ind2rgb ([0 1 2], gray (5)); |
875f4510d6dc
Accept indexed images with color values below the first colormap entry (bug #41851).
Rik <rik@octave.org>
parents:
17744
diff
changeset
|
121 %!warning <contains colors outside of colormap> ind2rgb ([1 2 6], gray (5)); |
875f4510d6dc
Accept indexed images with color values below the first colormap entry (bug #41851).
Rik <rik@octave.org>
parents:
17744
diff
changeset
|
122 %!warning <contains colors outside of colormap> ind2rgb (uint8 ([1 2 5]), gray (5)); |
23484
3ace16b8f062
Support uint32 and uint64 on image conversion functions (bug #47115)
Carnë Draug <carandraug@octave.org>
parents:
23220
diff
changeset
|
123 |
3ace16b8f062
Support uint32 and uint64 on image conversion functions (bug #47115)
Carnë Draug <carandraug@octave.org>
parents:
23220
diff
changeset
|
124 ## We support any unsigned integer type which Matlab does not. See |
3ace16b8f062
Support uint32 and uint64 on image conversion functions (bug #47115)
Carnë Draug <carandraug@octave.org>
parents:
23220
diff
changeset
|
125 ## bug #47115. |
3ace16b8f062
Support uint32 and uint64 on image conversion functions (bug #47115)
Carnë Draug <carandraug@octave.org>
parents:
23220
diff
changeset
|
126 %!test |
3ace16b8f062
Support uint32 and uint64 on image conversion functions (bug #47115)
Carnë Draug <carandraug@octave.org>
parents:
23220
diff
changeset
|
127 %! cmap = repmat (linspace (0, 1, 9)(:), [1 3]); |
3ace16b8f062
Support uint32 and uint64 on image conversion functions (bug #47115)
Carnë Draug <carandraug@octave.org>
parents:
23220
diff
changeset
|
128 %! ind = [0 3 6; 1 4 7; 2 5 8]; |
3ace16b8f062
Support uint32 and uint64 on image conversion functions (bug #47115)
Carnë Draug <carandraug@octave.org>
parents:
23220
diff
changeset
|
129 %! rgb = repmat (reshape (linspace (0, 1, 9), [3 3]), [1 1 3]); |
28929
9e43deb9bfc3
maint: Use semicolon after assert statement inside %!test blocks.
Rik <rik@octave.org>
parents:
28905
diff
changeset
|
130 %! assert (ind2rgb (uint8 (ind), cmap), rgb); |
9e43deb9bfc3
maint: Use semicolon after assert statement inside %!test blocks.
Rik <rik@octave.org>
parents:
28905
diff
changeset
|
131 %! assert (ind2rgb (uint16 (ind), cmap), rgb); |
9e43deb9bfc3
maint: Use semicolon after assert statement inside %!test blocks.
Rik <rik@octave.org>
parents:
28905
diff
changeset
|
132 %! assert (ind2rgb (uint32 (ind), cmap), rgb); |
9e43deb9bfc3
maint: Use semicolon after assert statement inside %!test blocks.
Rik <rik@octave.org>
parents:
28905
diff
changeset
|
133 %! assert (ind2rgb (uint64 (ind), cmap), rgb); |
23484
3ace16b8f062
Support uint32 and uint64 on image conversion functions (bug #47115)
Carnë Draug <carandraug@octave.org>
parents:
23220
diff
changeset
|
134 %! fail ("ind2rgb (int8 (ind), cmap)", "X must be an indexed image") |
3ace16b8f062
Support uint32 and uint64 on image conversion functions (bug #47115)
Carnë Draug <carandraug@octave.org>
parents:
23220
diff
changeset
|
135 %! fail ("ind2rgb (int16 (ind), cmap)", "X must be an indexed image") |
3ace16b8f062
Support uint32 and uint64 on image conversion functions (bug #47115)
Carnë Draug <carandraug@octave.org>
parents:
23220
diff
changeset
|
136 %! fail ("ind2rgb (int32 (ind), cmap)", "X must be an indexed image") |
3ace16b8f062
Support uint32 and uint64 on image conversion functions (bug #47115)
Carnë Draug <carandraug@octave.org>
parents:
23220
diff
changeset
|
137 %! fail ("ind2rgb (int64 (ind), cmap)", "X must be an indexed image") |
3ace16b8f062
Support uint32 and uint64 on image conversion functions (bug #47115)
Carnë Draug <carandraug@octave.org>
parents:
23220
diff
changeset
|
138 %! |
3ace16b8f062
Support uint32 and uint64 on image conversion functions (bug #47115)
Carnë Draug <carandraug@octave.org>
parents:
23220
diff
changeset
|
139 %! cmap(65541,:) = cmap(9,:); # index outside the uint16 range |
3ace16b8f062
Support uint32 and uint64 on image conversion functions (bug #47115)
Carnë Draug <carandraug@octave.org>
parents:
23220
diff
changeset
|
140 %! cmap(9,:) = 0; |
3ace16b8f062
Support uint32 and uint64 on image conversion functions (bug #47115)
Carnë Draug <carandraug@octave.org>
parents:
23220
diff
changeset
|
141 %! ind(3,3) = 65540; |
28929
9e43deb9bfc3
maint: Use semicolon after assert statement inside %!test blocks.
Rik <rik@octave.org>
parents:
28905
diff
changeset
|
142 %! assert (ind2rgb (uint32 (ind), cmap), rgb); |
9e43deb9bfc3
maint: Use semicolon after assert statement inside %!test blocks.
Rik <rik@octave.org>
parents:
28905
diff
changeset
|
143 %! assert (ind2rgb (uint64 (ind), cmap), rgb); |
28885
25b7ffb514f3
ind2x.m: Fix for integer saturation (bug #59242).
Markus Mützel <markus.muetzel@gmx.de>
parents:
27985
diff
changeset
|
144 |
25b7ffb514f3
ind2x.m: Fix for integer saturation (bug #59242).
Markus Mützel <markus.muetzel@gmx.de>
parents:
27985
diff
changeset
|
145 %!test <*59242> |
25b7ffb514f3
ind2x.m: Fix for integer saturation (bug #59242).
Markus Mützel <markus.muetzel@gmx.de>
parents:
27985
diff
changeset
|
146 %! warning ("off", "Octave:ind2rgb:invalid-idx-img", "local"); |
25b7ffb514f3
ind2x.m: Fix for integer saturation (bug #59242).
Markus Mützel <markus.muetzel@gmx.de>
parents:
27985
diff
changeset
|
147 %! assert (ind2rgb (uint64 (intmax ("uint64")), jet (64)), ... |
25b7ffb514f3
ind2x.m: Fix for integer saturation (bug #59242).
Markus Mützel <markus.muetzel@gmx.de>
parents:
27985
diff
changeset
|
148 %! reshape ([0.5,0,0], [1,1,3])); |