Mercurial > octave
annotate scripts/image/rgb2hsv.m @ 27898:4d6d21839dfd
remove Author: jwe and Adapted-by: jwe lines from source files
These lines have little meaning now in the age of modern version
control systems.
Files affected: url-transfer.cc, url-transfer.h, acot.m, acoth.m,
acsc.m, acsch.m, asec.m, asech.m, cot.m, coth.m, csc.m, csch.m, sec.m,
sech.m, cart2pol.m, cart2sph.m, deal.m, fliplr.m, flipud.m, int2str.m,
logspace.m, num2str.m, pol2cart.m, rot90.m, sortrows.m, sph2cart.m,
waitbar.m, doc.m, hsv2rgb.m, rgb2hsv.m, beep.m, isstr.m, setstr.m,
strmatch.m, cond.m, rank.m, trace.m, bug_report.m, cast.m, delete.m,
dir.m, list_primes.m, ls.m, ls_command.m, menu.m, pack.m, recycle.m,
substruct.m, version.m, glpk.m, axis.m, box.m, grid.m,
__axis_label__.m, text.m, title.m, view.m, xlabel.m, ylabel.m,
zlabel.m, bar.m, barh.m, comet3.m, hist.m, line.m, loglog.m, mesh.m,
patch.m, plot.m, polar.m, __bar__.m, __line__.m, __plt__.m,
__stem__.m, semilogx.m, semilogy.m, sombrero.m, stairs.m, stem.m,
surface.m, __default_plot_options__.m, __gnuplot_drawnow__.m,
__next_line_color__.m, __plt_get_axis_arg__.m, __pltopt__.m, clf.m,
closereq.m, gca.m, gnuplot_binary.in.m, isfigure.m, meshgrid.m,
__gnuplot_draw_axes__.m, __gnuplot_draw_figure__.m, shg.m, addpref.m,
getpref.m, ispref.m, loadprefs.m, prefsfile.m, saveprefs.m, rmpref.m,
setpref.m, ismember.m, setdiff.m, union.m, hankel.m, hilb.m, vander.m,
median.m, std.m, cstrcat.m, isletter.m, str2num.m, strcat.m,
oruntests.m, rundemos.m, asctime.m, clock.m, ctime.m, date.m, etime.m,
is_leap_year.m.
author | John W. Eaton <jwe@octave.org> |
---|---|
date | Thu, 02 Jan 2020 15:43:01 -0500 |
parents | 00f796120a6d |
children | b442ec6dda5c |
rev | line source |
---|---|
26376
00f796120a6d
maint: Update copyright dates in all source files.
John W. Eaton <jwe@octave.org>
parents:
25054
diff
changeset
|
1 ## Copyright (C) 1999-2019 Kai Habel |
3803 | 2 ## |
3 ## This file is part of Octave. | |
4 ## | |
24534
194eb4bd202b
maint: Update punctuation for GPL v3 license text.
Rik <rik@octave.org>
parents:
23220
diff
changeset
|
5 ## Octave is free software: you can redistribute it and/or modify it |
3803 | 6 ## 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
|
7 ## 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
|
8 ## (at your option) any later version. |
3803 | 9 ## |
10 ## Octave is distributed in the hope that it will be useful, but | |
11 ## WITHOUT ANY WARRANTY; without even the implied warranty of | |
22755
3a2b891d0b33
maint: Standardize Copyright formatting.
Rik <rik@octave.org>
parents:
22323
diff
changeset
|
12 ## MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
3a2b891d0b33
maint: Standardize Copyright formatting.
Rik <rik@octave.org>
parents:
22323
diff
changeset
|
13 ## GNU General Public License for more details. |
3803 | 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 |
24534
194eb4bd202b
maint: Update punctuation for GPL v3 license text.
Rik <rik@octave.org>
parents:
23220
diff
changeset
|
17 ## <https://www.gnu.org/licenses/>. |
3803 | 18 |
19 ## -*- texinfo -*- | |
22766
6033e2e4d5ea
doc: Clarify inputs and outputs for rgb2hsv.
Rik <rik@octave.org>
parents:
22323
diff
changeset
|
20 ## @deftypefn {} {@var{hsv_map} =} rgb2hsv (@var{rgb_map}) |
6033e2e4d5ea
doc: Clarify inputs and outputs for rgb2hsv.
Rik <rik@octave.org>
parents:
22323
diff
changeset
|
21 ## @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
|
22 ## Transform a colormap or image from RGB to HSV color space. |
3803 | 23 ## |
14260
1f911333ed3d
doc: Update docstrings for functions in image/ directory
Rik <octave@nomad.inbox5.com>
parents:
14138
diff
changeset
|
24 ## 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
|
25 ## |
20369
131ce8cfaa80
Relax input in functions that convert between colorspaces (bug #45456)
Carnë Draug <carandraug@octave.org>
parents:
19833
diff
changeset
|
26 ## 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
|
27 ## (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
|
28 ## 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
|
29 ## 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
|
30 ## 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
|
31 ## |
131ce8cfaa80
Relax input in functions that convert between colorspaces (bug #45456)
Carnë Draug <carandraug@octave.org>
parents:
19833
diff
changeset
|
32 ## 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
|
33 ## |
24610
3ad53e4793fc
rgb2gray: New function to convert RGB images to grayscale images.
Rik <rik@octave.org>
parents:
24534
diff
changeset
|
34 ## @seealso{hsv2rgb, rgb2ind, rgb2gray} |
3803 | 35 ## @end deftypefn |
36 | |
37 ## Author: Kai Habel <kai.habel@gmx.de> | |
38 | |
20369
131ce8cfaa80
Relax input in functions that convert between colorspaces (bug #45456)
Carnë Draug <carandraug@octave.org>
parents:
19833
diff
changeset
|
39 function hsv = rgb2hsv (rgb) |
3803 | 40 |
41 if (nargin != 1) | |
6046 | 42 print_usage (); |
3803 | 43 endif |
44 | |
20676
1672bb8882dd
Remove unused arguments in private functions for colorspace arguments.
Carnë Draug <carandraug@octave.org>
parents:
20665
diff
changeset
|
45 [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
|
46 = colorspace_conversion_input_check ("rgb2hsv", "RGB", rgb); |
3803 | 47 |
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
|
48 ## 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
|
49 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
|
50 v = max (rgb, [], 2); |
3803 | 51 |
3904 | 52 ## 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
|
53 h = zeros (rows (rgb), 1); |
3904 | 54 notgray = (s != v); |
11587
c792872f8942
all script files: untabify and strip trailing whitespace
John W. Eaton <jwe@octave.org>
parents:
11523
diff
changeset
|
55 |
3904 | 56 ## blue hue |
57 idx = (v == rgb(:,3) & notgray); | |
58 if (any (idx)) | |
59 h(idx) = 2/3 + 1/6 * (rgb(idx,1) - rgb(idx,2)) ./ (v(idx) - s(idx)); | |
60 endif | |
3803 | 61 |
3904 | 62 ## green hue |
63 idx = (v == rgb(:,2) & notgray); | |
64 if (any (idx)) | |
65 h(idx) = 1/3 + 1/6 * (rgb(idx,3) - rgb(idx,1)) ./ (v(idx) - s(idx)); | |
66 endif | |
3803 | 67 |
3904 | 68 ## red hue |
69 idx = (v == rgb(:,1) & notgray); | |
70 if (any (idx)) | |
71 h(idx) = 1/6 * (rgb(idx,2) - rgb(idx,3)) ./ (v(idx) - s(idx)); | |
72 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
|
73 h(h < 0) += 1; # correct for negative red |
3803 | 74 |
3904 | 75 ## set the saturation |
76 s(! notgray) = 0; | |
77 s(notgray) = 1 - s(notgray) ./ v(notgray); | |
3803 | 78 |
20369
131ce8cfaa80
Relax input in functions that convert between colorspaces (bug #45456)
Carnë Draug <carandraug@octave.org>
parents:
19833
diff
changeset
|
79 hsv = [h, s, v]; |
20676
1672bb8882dd
Remove unused arguments in private functions for colorspace arguments.
Carnë Draug <carandraug@octave.org>
parents:
20665
diff
changeset
|
80 hsv = colorspace_conversion_revert (hsv, sz, is_im, is_nd); |
3803 | 81 |
82 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
|
83 |
21759
b002b4331a12
maint: Use two newlines after endfunction and start of BIST tests.
Rik <rik@octave.org>
parents:
21580
diff
changeset
|
84 |
19833
9fc020886ae9
maint: Clean up m-files to follow Octave coding conventions.
Rik <rik@octave.org>
parents:
19697
diff
changeset
|
85 ## 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
|
86 %!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
|
87 %!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
|
88 %!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
|
89 %!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
|
90 %!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
|
91 %!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
|
92 %!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
|
93 |
20369
131ce8cfaa80
Relax input in functions that convert between colorspaces (bug #45456)
Carnë Draug <carandraug@octave.org>
parents:
19833
diff
changeset
|
94 ## 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
|
95 %!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
|
96 |
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
|
97 %!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
|
98 %! 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
|
99 %! 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
|
100 |
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_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
|
103 %! 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
|
104 |
20369
131ce8cfaa80
Relax input in functions that convert between colorspaces (bug #45456)
Carnë Draug <carandraug@octave.org>
parents:
19833
diff
changeset
|
105 ## support sparse input |
131ce8cfaa80
Relax input in functions that convert between colorspaces (bug #45456)
Carnë Draug <carandraug@octave.org>
parents:
19833
diff
changeset
|
106 %!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
|
107 %!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
|
108 %!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
|
109 |
19833
9fc020886ae9
maint: Clean up m-files to follow Octave coding conventions.
Rik <rik@octave.org>
parents:
19697
diff
changeset
|
110 ## 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
|
111 %!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
|
112 %!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
|
113 %!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
|
114 %!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
|
115 |
20369
131ce8cfaa80
Relax input in functions that convert between colorspaces (bug #45456)
Carnë Draug <carandraug@octave.org>
parents:
19833
diff
changeset
|
116 ## Test ND input |
131ce8cfaa80
Relax input in functions that convert between colorspaces (bug #45456)
Carnë Draug <carandraug@octave.org>
parents:
19833
diff
changeset
|
117 %!test |
131ce8cfaa80
Relax input in functions that convert between colorspaces (bug #45456)
Carnë Draug <carandraug@octave.org>
parents:
19833
diff
changeset
|
118 %! 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
|
119 %! hsv = zeros (size (rgb)); |
131ce8cfaa80
Relax input in functions that convert between colorspaces (bug #45456)
Carnë Draug <carandraug@octave.org>
parents:
19833
diff
changeset
|
120 %! for i = 1:5 |
131ce8cfaa80
Relax input in functions that convert between colorspaces (bug #45456)
Carnë Draug <carandraug@octave.org>
parents:
19833
diff
changeset
|
121 %! 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
|
122 %! endfor |
21580
ecce63c99c3f
maint: Add semicolons to terminate code in %! blocks.
Rik <rik@octave.org>
parents:
21443
diff
changeset
|
123 %! 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
|
124 |
a278de349250
Add more tests for color space conversion functions (patch #8709)
Carnë Draug <carandraug@octave.org>
parents:
20663
diff
changeset
|
125 ## 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
|
126 ## 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
|
127 |
a278de349250
Add more tests for color space conversion functions (patch #8709)
Carnë Draug <carandraug@octave.org>
parents:
20663
diff
changeset
|
128 %!test |
a278de349250
Add more tests for color space conversion functions (patch #8709)
Carnë Draug <carandraug@octave.org>
parents:
20663
diff
changeset
|
129 %! hsv = rgb2hsv (rand (10, 10, 3)); |
21580
ecce63c99c3f
maint: Add semicolons to terminate code in %! blocks.
Rik <rik@octave.org>
parents:
21443
diff
changeset
|
130 %! assert (class (hsv), "double"); |
ecce63c99c3f
maint: Add semicolons to terminate code in %! blocks.
Rik <rik@octave.org>
parents:
21443
diff
changeset
|
131 %! 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
|
132 |
a278de349250
Add more tests for color space conversion functions (patch #8709)
Carnë Draug <carandraug@octave.org>
parents:
20663
diff
changeset
|
133 %!test |
a278de349250
Add more tests for color space conversion functions (patch #8709)
Carnë Draug <carandraug@octave.org>
parents:
20663
diff
changeset
|
134 %! 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
|
135 %! assert (class (hsv), "single"); |
ecce63c99c3f
maint: Add semicolons to terminate code in %! blocks.
Rik <rik@octave.org>
parents:
21443
diff
changeset
|
136 %! 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
|
137 |
a278de349250
Add more tests for color space conversion functions (patch #8709)
Carnë Draug <carandraug@octave.org>
parents:
20663
diff
changeset
|
138 %!test |
a278de349250
Add more tests for color space conversion functions (patch #8709)
Carnë Draug <carandraug@octave.org>
parents:
20663
diff
changeset
|
139 %! 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
|
140 %! hsv = rgb2hsv (rgb); |
21580
ecce63c99c3f
maint: Add semicolons to terminate code in %! blocks.
Rik <rik@octave.org>
parents:
21443
diff
changeset
|
141 %! assert (class (hsv), "double"); |
ecce63c99c3f
maint: Add semicolons to terminate code in %! blocks.
Rik <rik@octave.org>
parents:
21443
diff
changeset
|
142 %! 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
|
143 |
a278de349250
Add more tests for color space conversion functions (patch #8709)
Carnë Draug <carandraug@octave.org>
parents:
20663
diff
changeset
|
144 %!test |
a278de349250
Add more tests for color space conversion functions (patch #8709)
Carnë Draug <carandraug@octave.org>
parents:
20663
diff
changeset
|
145 %! 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
|
146 %! hsv = rgb2hsv (rgb); |
21580
ecce63c99c3f
maint: Add semicolons to terminate code in %! blocks.
Rik <rik@octave.org>
parents:
21443
diff
changeset
|
147 %! assert (class (hsv), "single"); |
ecce63c99c3f
maint: Add semicolons to terminate code in %! blocks.
Rik <rik@octave.org>
parents:
21443
diff
changeset
|
148 %! 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
|
149 |
a278de349250
Add more tests for color space conversion functions (patch #8709)
Carnë Draug <carandraug@octave.org>
parents:
20663
diff
changeset
|
150 %!test |
a278de349250
Add more tests for color space conversion functions (patch #8709)
Carnë Draug <carandraug@octave.org>
parents:
20663
diff
changeset
|
151 %! 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
|
152 %! assert (class (hsv), "double"); |
ecce63c99c3f
maint: Add semicolons to terminate code in %! blocks.
Rik <rik@octave.org>
parents:
21443
diff
changeset
|
153 %! 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
|
154 |
a278de349250
Add more tests for color space conversion functions (patch #8709)
Carnë Draug <carandraug@octave.org>
parents:
20663
diff
changeset
|
155 %!test |
a278de349250
Add more tests for color space conversion functions (patch #8709)
Carnë Draug <carandraug@octave.org>
parents:
20663
diff
changeset
|
156 %! 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
|
157 %! assert (class (hsv), "double"); |
ecce63c99c3f
maint: Add semicolons to terminate code in %! blocks.
Rik <rik@octave.org>
parents:
21443
diff
changeset
|
158 %! 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
|
159 |
a278de349250
Add more tests for color space conversion functions (patch #8709)
Carnë Draug <carandraug@octave.org>
parents:
20663
diff
changeset
|
160 %!test |
21443
acd6e203031d
Alter BIST tests stop emitting warnings during runtests invocation.
Rik <rik@octave.org>
parents:
20852
diff
changeset
|
161 %! 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
|
162 %! assert (class (hsv), "double"); |
ecce63c99c3f
maint: Add semicolons to terminate code in %! blocks.
Rik <rik@octave.org>
parents:
21443
diff
changeset
|
163 %! 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
|
164 |
a278de349250
Add more tests for color space conversion functions (patch #8709)
Carnë Draug <carandraug@octave.org>
parents:
20663
diff
changeset
|
165 %!test |
a278de349250
Add more tests for color space conversion functions (patch #8709)
Carnë Draug <carandraug@octave.org>
parents:
20663
diff
changeset
|
166 %! 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
|
167 %! 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
|
168 %! [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
|
169 %! 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
|
170 %! 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
|
171 %! |
21580
ecce63c99c3f
maint: Add semicolons to terminate code in %! blocks.
Rik <rik@octave.org>
parents:
21443
diff
changeset
|
172 %! assert (rgb2hsv (rgb_double), expected); |
ecce63c99c3f
maint: Add semicolons to terminate code in %! blocks.
Rik <rik@octave.org>
parents:
21443
diff
changeset
|
173 %! assert (rgb2hsv (rgb_uint8), expected, 0.005); |
ecce63c99c3f
maint: Add semicolons to terminate code in %! blocks.
Rik <rik@octave.org>
parents:
21443
diff
changeset
|
174 %! assert (rgb2hsv (single (rgb_double)), single (expected)); |