Mercurial > octave
annotate scripts/image/rgb2hsv.m @ 27918:b442ec6dda5c
use centralized file for copyright info for individual contributors
* COPYRIGHT.md: New file.
* In most other files, use "Copyright (C) YYYY-YYYY The Octave Project
Developers" instead of tracking individual names in separate source
files. The motivation is to reduce the effort required to update the
notices each year.
Until now, the Octave source files contained copyright notices that
list individual contributors. I adopted these file-scope copyright
notices because that is what everyone was doing 30 years ago in the
days before distributed version control systems. But now, with many
contributors and modern version control systems, having these
file-scope copyright notices causes trouble when we update copyright
years or refactor code.
Over time, the file-scope copyright notices may become outdated as new
contributions are made or code is moved from one file to
another. Sometimes people contribute significant patches but do not
add a line claiming copyright. Other times, people add a copyright
notice for their contribution but then a later refactoring moves part
or all of their contribution to another file and the notice is not
moved with the code. As a practical matter, moving such notices is
difficult -- determining what parts are due to a particular
contributor requires a time-consuming search through the project
history. Even managing the yearly update of copyright years is
problematic. We have some contributors who are no longer
living. Should we update the copyright dates for their contributions
when we release new versions? Probably not, but we do still want to
claim copyright for the project as a whole.
To minimize the difficulty of maintaining the copyright notices, I
would like to change Octave's sources to use what is described here:
https://softwarefreedom.org/resources/2012/ManagingCopyrightInformation.html
in the section "Maintaining centralized copyright notices":
The centralized notice approach consolidates all copyright
notices in a single location, usually a top-level file.
This file should contain all of the copyright notices
provided project contributors, unless the contribution was
clearly insignificant. It may also credit -- without a copyright
notice -- anyone who helped with the project but did not
contribute code or other copyrighted material.
This approach captures less information about contributions
within individual files, recognizing that the DVCS is better
equipped to record those details. As we mentioned before, it
does have one disadvantage as compared to the file-scope
approach: if a single file is separated from the distribution,
the recipient won't see the contributors' copyright notices.
But this can be easily remedied by including a single
copyright notice in each file's header, pointing to the
top-level file:
Copyright YYYY-YYYY The Octave Project Developers
See the COPYRIGHT file at the top-level directory
of this distribution or at https://octave.org/COPYRIGHT.html.
followed by the usual GPL copyright statement.
For more background, see the discussion here:
https://lists.gnu.org/archive/html/octave-maintainers/2020-01/msg00009.html
Most files in the following directories have been skipped intentinally
in this changeset:
doc
libgui/qterminal
liboctave/external
m4
author | John W. Eaton <jwe@octave.org> |
---|---|
date | Mon, 06 Jan 2020 15:38:17 -0500 |
parents | 4d6d21839dfd |
children | 1891570abac8 |
rev | line source |
---|---|
27918
b442ec6dda5c
use centralized file for copyright info for individual contributors
John W. Eaton <jwe@octave.org>
parents:
27898
diff
changeset
|
1 ## Copyright (C) 1999-2019 The Octave Project Developers |
b442ec6dda5c
use centralized file for copyright info for individual contributors
John W. Eaton <jwe@octave.org>
parents:
27898
diff
changeset
|
2 ## |
b442ec6dda5c
use centralized file for copyright info for individual contributors
John W. Eaton <jwe@octave.org>
parents:
27898
diff
changeset
|
3 ## See the file COPYRIGHT.md in the top-level directory of this distribution |
b442ec6dda5c
use centralized file for copyright info for individual contributors
John W. Eaton <jwe@octave.org>
parents:
27898
diff
changeset
|
4 ## or <https://octave.org/COPYRIGHT.html/>. |
b442ec6dda5c
use centralized file for copyright info for individual contributors
John W. Eaton <jwe@octave.org>
parents:
27898
diff
changeset
|
5 ## |
3803 | 6 ## |
7 ## This file is part of Octave. | |
8 ## | |
24534
194eb4bd202b
maint: Update punctuation for GPL v3 license text.
Rik <rik@octave.org>
parents:
23220
diff
changeset
|
9 ## Octave is free software: you can redistribute it and/or modify it |
3803 | 10 ## 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:
23220
diff
changeset
|
11 ## 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
|
12 ## (at your option) any later version. |
3803 | 13 ## |
14 ## Octave is distributed in the hope that it will be useful, but | |
15 ## WITHOUT ANY WARRANTY; without even the implied warranty of | |
22755
3a2b891d0b33
maint: Standardize Copyright formatting.
Rik <rik@octave.org>
parents:
22323
diff
changeset
|
16 ## MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
3a2b891d0b33
maint: Standardize Copyright formatting.
Rik <rik@octave.org>
parents:
22323
diff
changeset
|
17 ## GNU General Public License for more details. |
3803 | 18 ## |
19 ## You should have received a copy of the GNU General Public License | |
7016 | 20 ## 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:
23220
diff
changeset
|
21 ## <https://www.gnu.org/licenses/>. |
3803 | 22 |
23 ## -*- texinfo -*- | |
22766
6033e2e4d5ea
doc: Clarify inputs and outputs for rgb2hsv.
Rik <rik@octave.org>
parents:
22323
diff
changeset
|
24 ## @deftypefn {} {@var{hsv_map} =} rgb2hsv (@var{rgb_map}) |
6033e2e4d5ea
doc: Clarify inputs and outputs for rgb2hsv.
Rik <rik@octave.org>
parents:
22323
diff
changeset
|
25 ## @deftypefnx {} {@var{hsv_img} =} rgb2hsv (@var{rgb_img}) |
20369
131ce8cfaa80
Relax input in functions that convert between colorspaces (bug #45456)
Carnë Draug <carandraug@octave.org>
parents:
19833
diff
changeset
|
26 ## Transform a colormap or image from RGB to HSV color space. |
3803 | 27 ## |
14260
1f911333ed3d
doc: Update docstrings for functions in image/ directory
Rik <octave@nomad.inbox5.com>
parents:
14138
diff
changeset
|
28 ## A color in the RGB space consists of red, green, and blue intensities. |
1f911333ed3d
doc: Update docstrings for functions in image/ directory
Rik <octave@nomad.inbox5.com>
parents:
14138
diff
changeset
|
29 ## |
20369
131ce8cfaa80
Relax input in functions that convert between colorspaces (bug #45456)
Carnë Draug <carandraug@octave.org>
parents:
19833
diff
changeset
|
30 ## A color in HSV space is represented by hue, saturation and value |
131ce8cfaa80
Relax input in functions that convert between colorspaces (bug #45456)
Carnë Draug <carandraug@octave.org>
parents:
19833
diff
changeset
|
31 ## (brightness) levels in a cylindrical coordinate system. Hue is the |
131ce8cfaa80
Relax input in functions that convert between colorspaces (bug #45456)
Carnë Draug <carandraug@octave.org>
parents:
19833
diff
changeset
|
32 ## azimuth and describes the dominant color. Saturation is the radial |
131ce8cfaa80
Relax input in functions that convert between colorspaces (bug #45456)
Carnë Draug <carandraug@octave.org>
parents:
19833
diff
changeset
|
33 ## distance and gives the amount of hue mixed into the color. Value is |
131ce8cfaa80
Relax input in functions that convert between colorspaces (bug #45456)
Carnë Draug <carandraug@octave.org>
parents:
19833
diff
changeset
|
34 ## the height and is the amount of light in the color. |
131ce8cfaa80
Relax input in functions that convert between colorspaces (bug #45456)
Carnë Draug <carandraug@octave.org>
parents:
19833
diff
changeset
|
35 ## |
131ce8cfaa80
Relax input in functions that convert between colorspaces (bug #45456)
Carnë Draug <carandraug@octave.org>
parents:
19833
diff
changeset
|
36 ## Output class and size will be the same as input. |
131ce8cfaa80
Relax input in functions that convert between colorspaces (bug #45456)
Carnë Draug <carandraug@octave.org>
parents:
19833
diff
changeset
|
37 ## |
24610
3ad53e4793fc
rgb2gray: New function to convert RGB images to grayscale images.
Rik <rik@octave.org>
parents:
24534
diff
changeset
|
38 ## @seealso{hsv2rgb, rgb2ind, rgb2gray} |
3803 | 39 ## @end deftypefn |
40 | |
41 ## Author: Kai Habel <kai.habel@gmx.de> | |
42 | |
20369
131ce8cfaa80
Relax input in functions that convert between colorspaces (bug #45456)
Carnë Draug <carandraug@octave.org>
parents:
19833
diff
changeset
|
43 function hsv = rgb2hsv (rgb) |
3803 | 44 |
45 if (nargin != 1) | |
6046 | 46 print_usage (); |
3803 | 47 endif |
48 | |
20676
1672bb8882dd
Remove unused arguments in private functions for colorspace arguments.
Carnë Draug <carandraug@octave.org>
parents:
20665
diff
changeset
|
49 [rgb, sz, is_im, is_nd] ... |
20369
131ce8cfaa80
Relax input in functions that convert between colorspaces (bug #45456)
Carnë Draug <carandraug@octave.org>
parents:
19833
diff
changeset
|
50 = colorspace_conversion_input_check ("rgb2hsv", "RGB", rgb); |
3803 | 51 |
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
|
52 ## get the max and min for each row |
806ea52af230
Overhaul m-files in image directory to provide better support for images stored as integers.
Rik <rik@octave.org>
parents:
14260
diff
changeset
|
53 s = min (rgb, [], 2); |
806ea52af230
Overhaul m-files in image directory to provide better support for images stored as integers.
Rik <rik@octave.org>
parents:
14260
diff
changeset
|
54 v = max (rgb, [], 2); |
3803 | 55 |
3904 | 56 ## set hue to zero for undefined values (gray has no hue) |
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
|
57 h = zeros (rows (rgb), 1); |
3904 | 58 notgray = (s != v); |
11587
c792872f8942
all script files: untabify and strip trailing whitespace
John W. Eaton <jwe@octave.org>
parents:
11523
diff
changeset
|
59 |
3904 | 60 ## blue hue |
61 idx = (v == rgb(:,3) & notgray); | |
62 if (any (idx)) | |
63 h(idx) = 2/3 + 1/6 * (rgb(idx,1) - rgb(idx,2)) ./ (v(idx) - s(idx)); | |
64 endif | |
3803 | 65 |
3904 | 66 ## green hue |
67 idx = (v == rgb(:,2) & notgray); | |
68 if (any (idx)) | |
69 h(idx) = 1/3 + 1/6 * (rgb(idx,3) - rgb(idx,1)) ./ (v(idx) - s(idx)); | |
70 endif | |
3803 | 71 |
3904 | 72 ## red hue |
73 idx = (v == rgb(:,1) & notgray); | |
74 if (any (idx)) | |
75 h(idx) = 1/6 * (rgb(idx,2) - rgb(idx,3)) ./ (v(idx) - s(idx)); | |
76 endif | |
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
|
77 h(h < 0) += 1; # correct for negative red |
3803 | 78 |
3904 | 79 ## set the saturation |
80 s(! notgray) = 0; | |
81 s(notgray) = 1 - s(notgray) ./ v(notgray); | |
3803 | 82 |
20369
131ce8cfaa80
Relax input in functions that convert between colorspaces (bug #45456)
Carnë Draug <carandraug@octave.org>
parents:
19833
diff
changeset
|
83 hsv = [h, s, v]; |
20676
1672bb8882dd
Remove unused arguments in private functions for colorspace arguments.
Carnë Draug <carandraug@octave.org>
parents:
20665
diff
changeset
|
84 hsv = colorspace_conversion_revert (hsv, sz, is_im, is_nd); |
3803 | 85 |
86 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
|
87 |
21759
b002b4331a12
maint: Use two newlines after endfunction and start of BIST tests.
Rik <rik@octave.org>
parents:
21580
diff
changeset
|
88 |
19833
9fc020886ae9
maint: Clean up m-files to follow Octave coding conventions.
Rik <rik@octave.org>
parents:
19697
diff
changeset
|
89 ## Test pure colors and gray |
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
|
90 %!assert (rgb2hsv ([1 0 0]), [0 1 1]) |
806ea52af230
Overhaul m-files in image directory to provide better support for images stored as integers.
Rik <rik@octave.org>
parents:
14260
diff
changeset
|
91 %!assert (rgb2hsv ([0 1 0]), [1/3 1 1]) |
806ea52af230
Overhaul m-files in image directory to provide better support for images stored as integers.
Rik <rik@octave.org>
parents:
14260
diff
changeset
|
92 %!assert (rgb2hsv ([0 0 1]), [2/3 1 1]) |
20369
131ce8cfaa80
Relax input in functions that convert between colorspaces (bug #45456)
Carnë Draug <carandraug@octave.org>
parents:
19833
diff
changeset
|
93 %!assert (rgb2hsv ([1 1 0]), [1/6 1 1]) |
131ce8cfaa80
Relax input in functions that convert between colorspaces (bug #45456)
Carnë Draug <carandraug@octave.org>
parents:
19833
diff
changeset
|
94 %!assert (rgb2hsv ([0 1 1]), [1/2 1 1]) |
131ce8cfaa80
Relax input in functions that convert between colorspaces (bug #45456)
Carnë Draug <carandraug@octave.org>
parents:
19833
diff
changeset
|
95 %!assert (rgb2hsv ([1 0 1]), [5/6 1 1]) |
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
|
96 %!assert (rgb2hsv ([0.5 0.5 0.5]), [0 0 0.5]) |
806ea52af230
Overhaul m-files in image directory to provide better support for images stored as integers.
Rik <rik@octave.org>
parents:
14260
diff
changeset
|
97 |
20369
131ce8cfaa80
Relax input in functions that convert between colorspaces (bug #45456)
Carnë Draug <carandraug@octave.org>
parents:
19833
diff
changeset
|
98 ## Test tolarant input checking on floats |
131ce8cfaa80
Relax input in functions that convert between colorspaces (bug #45456)
Carnë Draug <carandraug@octave.org>
parents:
19833
diff
changeset
|
99 %!assert (rgb2hsv ([1.5 1 1]), [0 1/3 1.5], eps) |
131ce8cfaa80
Relax input in functions that convert between colorspaces (bug #45456)
Carnë Draug <carandraug@octave.org>
parents:
19833
diff
changeset
|
100 |
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 %!test |
806ea52af230
Overhaul m-files in image directory to provide better support for images stored as integers.
Rik <rik@octave.org>
parents:
14260
diff
changeset
|
102 %! rgb_map = rand (64, 3); |
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 %! assert (hsv2rgb (rgb2hsv (rgb_map)), rgb_map, 1e-6); |
806ea52af230
Overhaul m-files in image directory to provide better support for images stored as integers.
Rik <rik@octave.org>
parents:
14260
diff
changeset
|
104 |
806ea52af230
Overhaul m-files in image directory to provide better support for images stored as integers.
Rik <rik@octave.org>
parents:
14260
diff
changeset
|
105 %!test |
806ea52af230
Overhaul m-files in image directory to provide better support for images stored as integers.
Rik <rik@octave.org>
parents:
14260
diff
changeset
|
106 %! rgb_img = rand (64, 64, 3); |
806ea52af230
Overhaul m-files in image directory to provide better support for images stored as integers.
Rik <rik@octave.org>
parents:
14260
diff
changeset
|
107 %! assert (hsv2rgb (rgb2hsv (rgb_img)), rgb_img, 1e-6); |
806ea52af230
Overhaul m-files in image directory to provide better support for images stored as integers.
Rik <rik@octave.org>
parents:
14260
diff
changeset
|
108 |
20369
131ce8cfaa80
Relax input in functions that convert between colorspaces (bug #45456)
Carnë Draug <carandraug@octave.org>
parents:
19833
diff
changeset
|
109 ## support sparse input |
131ce8cfaa80
Relax input in functions that convert between colorspaces (bug #45456)
Carnë Draug <carandraug@octave.org>
parents:
19833
diff
changeset
|
110 %!assert (rgb2hsv (sparse ([0 0 1])), sparse ([2/3 1 1])) |
131ce8cfaa80
Relax input in functions that convert between colorspaces (bug #45456)
Carnë Draug <carandraug@octave.org>
parents:
19833
diff
changeset
|
111 %!assert (rgb2hsv (sparse ([0 1 1])), sparse ([1/2 1 1])) |
131ce8cfaa80
Relax input in functions that convert between colorspaces (bug #45456)
Carnë Draug <carandraug@octave.org>
parents:
19833
diff
changeset
|
112 %!assert (rgb2hsv (sparse ([1 1 1])), sparse ([0 0 1])) |
131ce8cfaa80
Relax input in functions that convert between colorspaces (bug #45456)
Carnë Draug <carandraug@octave.org>
parents:
19833
diff
changeset
|
113 |
19833
9fc020886ae9
maint: Clean up m-files to follow Octave coding conventions.
Rik <rik@octave.org>
parents:
19697
diff
changeset
|
114 ## 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
|
115 %!error rgb2hsv () |
806ea52af230
Overhaul m-files in image directory to provide better support for images stored as integers.
Rik <rik@octave.org>
parents:
14260
diff
changeset
|
116 %!error rgb2hsv (1,2) |
806ea52af230
Overhaul m-files in image directory to provide better support for images stored as integers.
Rik <rik@octave.org>
parents:
14260
diff
changeset
|
117 %!error <invalid data type 'cell'> rgb2hsv ({1}) |
20369
131ce8cfaa80
Relax input in functions that convert between colorspaces (bug #45456)
Carnë Draug <carandraug@octave.org>
parents:
19833
diff
changeset
|
118 %!error <RGB must be a colormap or RGB image> rgb2hsv (ones (2,2)) |
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
|
119 |
20369
131ce8cfaa80
Relax input in functions that convert between colorspaces (bug #45456)
Carnë Draug <carandraug@octave.org>
parents:
19833
diff
changeset
|
120 ## Test ND input |
131ce8cfaa80
Relax input in functions that convert between colorspaces (bug #45456)
Carnë Draug <carandraug@octave.org>
parents:
19833
diff
changeset
|
121 %!test |
131ce8cfaa80
Relax input in functions that convert between colorspaces (bug #45456)
Carnë Draug <carandraug@octave.org>
parents:
19833
diff
changeset
|
122 %! rgb = rand (16, 16, 3, 5); |
131ce8cfaa80
Relax input in functions that convert between colorspaces (bug #45456)
Carnë Draug <carandraug@octave.org>
parents:
19833
diff
changeset
|
123 %! hsv = zeros (size (rgb)); |
131ce8cfaa80
Relax input in functions that convert between colorspaces (bug #45456)
Carnë Draug <carandraug@octave.org>
parents:
19833
diff
changeset
|
124 %! for i = 1:5 |
131ce8cfaa80
Relax input in functions that convert between colorspaces (bug #45456)
Carnë Draug <carandraug@octave.org>
parents:
19833
diff
changeset
|
125 %! hsv(:,:,:,i) = rgb2hsv (rgb(:,:,:,i)); |
131ce8cfaa80
Relax input in functions that convert between colorspaces (bug #45456)
Carnë Draug <carandraug@octave.org>
parents:
19833
diff
changeset
|
126 %! endfor |
21580
ecce63c99c3f
maint: Add semicolons to terminate code in %! blocks.
Rik <rik@octave.org>
parents:
21443
diff
changeset
|
127 %! assert (rgb2hsv (rgb), hsv); |
20664
a278de349250
Add more tests for color space conversion functions (patch #8709)
Carnë Draug <carandraug@octave.org>
parents:
20663
diff
changeset
|
128 |
a278de349250
Add more tests for color space conversion functions (patch #8709)
Carnë Draug <carandraug@octave.org>
parents:
20663
diff
changeset
|
129 ## Test output class and size for input images. |
a278de349250
Add more tests for color space conversion functions (patch #8709)
Carnë Draug <carandraug@octave.org>
parents:
20663
diff
changeset
|
130 ## Most of the tests only test for colormap input. |
a278de349250
Add more tests for color space conversion functions (patch #8709)
Carnë Draug <carandraug@octave.org>
parents:
20663
diff
changeset
|
131 |
a278de349250
Add more tests for color space conversion functions (patch #8709)
Carnë Draug <carandraug@octave.org>
parents:
20663
diff
changeset
|
132 %!test |
a278de349250
Add more tests for color space conversion functions (patch #8709)
Carnë Draug <carandraug@octave.org>
parents:
20663
diff
changeset
|
133 %! hsv = rgb2hsv (rand (10, 10, 3)); |
21580
ecce63c99c3f
maint: Add semicolons to terminate code in %! blocks.
Rik <rik@octave.org>
parents:
21443
diff
changeset
|
134 %! assert (class (hsv), "double"); |
ecce63c99c3f
maint: Add semicolons to terminate code in %! blocks.
Rik <rik@octave.org>
parents:
21443
diff
changeset
|
135 %! assert (size (hsv), [10 10 3]); |
20664
a278de349250
Add more tests for color space conversion functions (patch #8709)
Carnë Draug <carandraug@octave.org>
parents:
20663
diff
changeset
|
136 |
a278de349250
Add more tests for color space conversion functions (patch #8709)
Carnë Draug <carandraug@octave.org>
parents:
20663
diff
changeset
|
137 %!test |
a278de349250
Add more tests for color space conversion functions (patch #8709)
Carnë Draug <carandraug@octave.org>
parents:
20663
diff
changeset
|
138 %! hsv = rgb2hsv (rand (10, 10, 3, "single")); |
21580
ecce63c99c3f
maint: Add semicolons to terminate code in %! blocks.
Rik <rik@octave.org>
parents:
21443
diff
changeset
|
139 %! assert (class (hsv), "single"); |
ecce63c99c3f
maint: Add semicolons to terminate code in %! blocks.
Rik <rik@octave.org>
parents:
21443
diff
changeset
|
140 %! assert (size (hsv), [10 10 3]); |
20664
a278de349250
Add more tests for color space conversion functions (patch #8709)
Carnë Draug <carandraug@octave.org>
parents:
20663
diff
changeset
|
141 |
a278de349250
Add more tests for color space conversion functions (patch #8709)
Carnë Draug <carandraug@octave.org>
parents:
20663
diff
changeset
|
142 %!test |
a278de349250
Add more tests for color space conversion functions (patch #8709)
Carnë Draug <carandraug@octave.org>
parents:
20663
diff
changeset
|
143 %! rgb = (rand (10, 10, 3) * 3 ) - 0.5; # values outside range [0 1] |
a278de349250
Add more tests for color space conversion functions (patch #8709)
Carnë Draug <carandraug@octave.org>
parents:
20663
diff
changeset
|
144 %! hsv = rgb2hsv (rgb); |
21580
ecce63c99c3f
maint: Add semicolons to terminate code in %! blocks.
Rik <rik@octave.org>
parents:
21443
diff
changeset
|
145 %! assert (class (hsv), "double"); |
ecce63c99c3f
maint: Add semicolons to terminate code in %! blocks.
Rik <rik@octave.org>
parents:
21443
diff
changeset
|
146 %! assert (size (hsv), [10 10 3]); |
20664
a278de349250
Add more tests for color space conversion functions (patch #8709)
Carnë Draug <carandraug@octave.org>
parents:
20663
diff
changeset
|
147 |
a278de349250
Add more tests for color space conversion functions (patch #8709)
Carnë Draug <carandraug@octave.org>
parents:
20663
diff
changeset
|
148 %!test |
a278de349250
Add more tests for color space conversion functions (patch #8709)
Carnë Draug <carandraug@octave.org>
parents:
20663
diff
changeset
|
149 %! rgb = (rand (10, 10, 3, "single") * 3 ) - 0.5; # values outside range [0 1] |
a278de349250
Add more tests for color space conversion functions (patch #8709)
Carnë Draug <carandraug@octave.org>
parents:
20663
diff
changeset
|
150 %! hsv = rgb2hsv (rgb); |
21580
ecce63c99c3f
maint: Add semicolons to terminate code in %! blocks.
Rik <rik@octave.org>
parents:
21443
diff
changeset
|
151 %! assert (class (hsv), "single"); |
ecce63c99c3f
maint: Add semicolons to terminate code in %! blocks.
Rik <rik@octave.org>
parents:
21443
diff
changeset
|
152 %! assert (size (hsv), [10 10 3]); |
20664
a278de349250
Add more tests for color space conversion functions (patch #8709)
Carnë Draug <carandraug@octave.org>
parents:
20663
diff
changeset
|
153 |
a278de349250
Add more tests for color space conversion functions (patch #8709)
Carnë Draug <carandraug@octave.org>
parents:
20663
diff
changeset
|
154 %!test |
a278de349250
Add more tests for color space conversion functions (patch #8709)
Carnë Draug <carandraug@octave.org>
parents:
20663
diff
changeset
|
155 %! hsv = rgb2hsv (randi ([0 255], 10, 10, 3, "uint8")); |
21580
ecce63c99c3f
maint: Add semicolons to terminate code in %! blocks.
Rik <rik@octave.org>
parents:
21443
diff
changeset
|
156 %! assert (class (hsv), "double"); |
ecce63c99c3f
maint: Add semicolons to terminate code in %! blocks.
Rik <rik@octave.org>
parents:
21443
diff
changeset
|
157 %! assert (size (hsv), [10 10 3]); |
20664
a278de349250
Add more tests for color space conversion functions (patch #8709)
Carnë Draug <carandraug@octave.org>
parents:
20663
diff
changeset
|
158 |
a278de349250
Add more tests for color space conversion functions (patch #8709)
Carnë Draug <carandraug@octave.org>
parents:
20663
diff
changeset
|
159 %!test |
a278de349250
Add more tests for color space conversion functions (patch #8709)
Carnë Draug <carandraug@octave.org>
parents:
20663
diff
changeset
|
160 %! hsv = rgb2hsv (randi ([0 65535], 10, 10, 3, "uint16")); |
21580
ecce63c99c3f
maint: Add semicolons to terminate code in %! blocks.
Rik <rik@octave.org>
parents:
21443
diff
changeset
|
161 %! assert (class (hsv), "double"); |
ecce63c99c3f
maint: Add semicolons to terminate code in %! blocks.
Rik <rik@octave.org>
parents:
21443
diff
changeset
|
162 %! assert (size (hsv), [10 10 3]); |
20664
a278de349250
Add more tests for color space conversion functions (patch #8709)
Carnë Draug <carandraug@octave.org>
parents:
20663
diff
changeset
|
163 |
a278de349250
Add more tests for color space conversion functions (patch #8709)
Carnë Draug <carandraug@octave.org>
parents:
20663
diff
changeset
|
164 %!test |
21443
acd6e203031d
Alter BIST tests stop emitting warnings during runtests invocation.
Rik <rik@octave.org>
parents:
20852
diff
changeset
|
165 %! hsv = rgb2hsv (randi ([-128 127], 10, 10, 3, "int8")); |
21580
ecce63c99c3f
maint: Add semicolons to terminate code in %! blocks.
Rik <rik@octave.org>
parents:
21443
diff
changeset
|
166 %! assert (class (hsv), "double"); |
ecce63c99c3f
maint: Add semicolons to terminate code in %! blocks.
Rik <rik@octave.org>
parents:
21443
diff
changeset
|
167 %! assert (size (hsv), [10 10 3]); |
20664
a278de349250
Add more tests for color space conversion functions (patch #8709)
Carnë Draug <carandraug@octave.org>
parents:
20663
diff
changeset
|
168 |
a278de349250
Add more tests for color space conversion functions (patch #8709)
Carnë Draug <carandraug@octave.org>
parents:
20663
diff
changeset
|
169 %!test |
a278de349250
Add more tests for color space conversion functions (patch #8709)
Carnë Draug <carandraug@octave.org>
parents:
20663
diff
changeset
|
170 %! rgb_double = reshape ([1 0 1 .5 1 1 0 .5 0 1 1 .5], [2 2 3]); |
a278de349250
Add more tests for color space conversion functions (patch #8709)
Carnë Draug <carandraug@octave.org>
parents:
20663
diff
changeset
|
171 %! rgb_uint8 = reshape (uint8 ([255 0 255 128 255 255 0 128 0 255 255 128]), |
a278de349250
Add more tests for color space conversion functions (patch #8709)
Carnë Draug <carandraug@octave.org>
parents:
20663
diff
changeset
|
172 %! [2 2 3]); |
20665
67e6343cd29a
Add support for colorspace conversion of signed integers images (patch #8709)
Carnë Draug <carandraug@octave.org>
parents:
20664
diff
changeset
|
173 %! rgb_int16 = int16 (double (rgb_double * uint16 (65535)) -32768); |
20664
a278de349250
Add more tests for color space conversion functions (patch #8709)
Carnë Draug <carandraug@octave.org>
parents:
20663
diff
changeset
|
174 %! expected = reshape ([1/6 1/2 5/6 0 1 1 1 0 1 1 1 .5], [2 2 3]); |
a278de349250
Add more tests for color space conversion functions (patch #8709)
Carnë Draug <carandraug@octave.org>
parents:
20663
diff
changeset
|
175 %! |
21580
ecce63c99c3f
maint: Add semicolons to terminate code in %! blocks.
Rik <rik@octave.org>
parents:
21443
diff
changeset
|
176 %! assert (rgb2hsv (rgb_double), expected); |
ecce63c99c3f
maint: Add semicolons to terminate code in %! blocks.
Rik <rik@octave.org>
parents:
21443
diff
changeset
|
177 %! assert (rgb2hsv (rgb_uint8), expected, 0.005); |
ecce63c99c3f
maint: Add semicolons to terminate code in %! blocks.
Rik <rik@octave.org>
parents:
21443
diff
changeset
|
178 %! assert (rgb2hsv (single (rgb_double)), single (expected)); |