1 autopkgtest [11:04:11]: version 4.4
2 autopkgtest [11:04:11]: host dev; command line: /usr/bin/autopkgtest -B . -- null
3 autopkgtest [11:04:11]: testbed dpkg architecture: amd64
4 autopkgtest [11:04:11]: testbed running kernel: Linux 4.9.0-3-amd64
5 autopkgtest [11:04:11]: @@@@@@@@@@@@@@@@@@@@ unbuilt-tree .
6 dpkg-source: info: using options from real-tree/debian/source/options: --extend-diff-ignore=inst/im2double.m|src/Makefile|src/config.h|src/config.log|src/config.status
7 autopkgtest [11:04:11]: testing package octave-image version 2.6.1-2
8 autopkgtest [11:04:11]: build not needed
9 autopkgtest [11:04:11]: test unit-tests: preparing testbed
10 Starting pkgProblemResolver with broken count: 0
11 Starting 2 pkgProblemResolver with broken count: 0
12 Done
13 autopkgtest [11:04:12]: test unit-tests: [-----------------------
14 /usr/share/octave-pkg-dev/check-pkg
15 Checking package...
16 echo Checking m files ...
17 warning: function /usr/share/octave/packages/image-2.6.1/im2double.m shadows a core library function
18 warning: called from
19 load_packages_and_dependencies at line 48 column 5
20 load_packages at line 47 column 3
21 pkg at line 411 column 7
22 /var/tmp/file8moa2S at line 6 column 5
23 [stdfilt]
24 >>>>> /usr/share/octave/packages/image-2.6.1/stdfilt.m
25 ***** test
26 im = stdfilt (ones (5));
27 assert (im, zeros (5));
28 1 test, 1 passed, 0 known failure, 0 skipped
29 [rangefilt]
30 >>>>> /usr/share/octave/packages/image-2.6.1/rangefilt.m
31 ***** test
32 im = rangefilt (ones (5));
33 assert (im, zeros (5));
34 1 test, 1 passed, 0 known failure, 0 skipped
35 [imtransform]
36 >>>>> /usr/share/octave/packages/image-2.6.1/imtransform.m
37 ***** demo
38 ## Various linear transforms
39 figure ();
40 im = [checkerboard(20, 2, 4); checkerboard(40, 1, 2)];
41 %input space corners
42 incp = [1 1; 160 1; 160 160; 1 160];
43 udata = [min(incp(:,1)) max(incp(:,1))];
44 vdata = [min(incp(:,2)) max(incp(:,2))];
45 subplot (2,3,1);
46 imshow (im)
47 hold on
48 plot (incp(:,1), incp(:,2), 'ob')
49 axis on
50 xlabel ('Original')
51
52 % Translation and scaling
53 outcp = incp * 2;
54 outcp(:,1) += 200;
55 outcp(:,2) += 500;
56 T = maketform ('affine', incp(1:3,:), outcp(1:3,:));
57 subplot (2,3,2);
58 [im2 xdata ydata] = imtransform (im, T, 'udata', udata,
59 'vdata', vdata, 'fillvalues', 1);
60 imh = imshow (im2); set (imh, 'xdata', xdata, 'ydata', ydata)
61 set (gca, 'xlim', xdata, 'ylim', ydata)
62 axis on, hold on, xlabel ('Translation / Scaling');
63 plot (outcp(:,1), outcp(:,2), 'or')
64
65 % Shear
66 outcp = [1 1; 160 1; 140 160; -19 160]; % affine only needs 3 control points
67 T = maketform ('affine', incp(1:3,:), outcp(1:3,:));
68 subplot (2,3,3);
69 [im2 xdata ydata] = imtransform (im, T, 'udata', udata,
70 'vdata', vdata, 'fillvalues', 1);
71 imh = imshow (im2); set (imh, 'xdata', xdata, 'ydata', ydata)
72 set (gca, 'xlim', xdata, 'ylim', ydata)
73 axis on, hold on, xlabel ('Shear');
74 plot (outcp(:,1), outcp(:,2), 'or')
75
76 % Rotation
77 theta = pi/4;
78 T = maketform ('affine', [cos(theta) -sin(theta); ...
79 sin(theta) cos(theta); 0 0]);
80 outcp = tformfwd (T, incp);
81 subplot (2,3,4);
82 [im2 xdata ydata] = imtransform (im, T, 'udata', udata,
83 'vdata', vdata, 'fillvalues', 1 );
84 imh = imshow (im2); set (imh, 'xdata', xdata, 'ydata', ydata)
85 set (gca, 'xlim', xdata, 'ylim', ydata)
86 axis on, hold on, xlabel ('Rotation');
87 plot (outcp(:,1), outcp(:,2), 'or')
88
89 % Reflection around x axis
90 outcp = incp;
91 outcp(:,2) *= -1;
92 T = cp2tform (incp, outcp, 'similarity');
93 subplot (2,3,5);
94 [im2 xdata ydata] = imtransform (im, T, 'udata', udata,
95 'vdata', vdata, 'fillvalues', 1 );
96 imh = imshow (im2); set (imh, 'xdata', xdata, 'ydata', ydata)
97 set (gca, 'xlim', xdata, 'ylim', ydata)
98 axis on, hold on, xlabel ('Reflection');
99 plot (outcp(:,1), outcp(:,2), 'or')
100
101 % Projection
102 outcp = [1 1; 160 -40; 220 220; 12 140];
103 T = maketform ('projective', incp, outcp);
104 subplot (2,3,6);
105 [im2 xdata ydata] = imtransform (im, T, 'udata', udata,
106 'vdata', vdata, 'fillvalues', 1 );
107 imh = imshow (im2); set (imh, 'xdata', xdata, 'ydata', ydata)
108 set (gca, 'xlim', xdata, 'ylim', ydata)
109 axis on, hold on, xlabel ('Projection');
110 plot (outcp(:,1), outcp(:,2), 'or')
111 ***** demo
112 ## Streched image
113 rad = 2; % minimum value: 4/pi
114 [uu vv] = meshgrid ((-2:2)/rad, (-2:2)/rad);
115 rescfactor = sin ((uu.^2 + vv.^2).^.5);
116 inpts = [(reshape (uu, numel (uu), 1)), (reshape (vv, numel (uu), 1))];
117 xx = rescfactor .* sign(uu);
118 yy = rescfactor .* sign(vv);
119 outpts = [reshape(xx, numel (xx), 1) reshape(yy, numel (yy), 1)];
120
121 T = cp2tform (inpts, outpts, "polynomial", 4);
122 figure;
123 subplot (1,2,1)
124 im = zeros (800, 800, 3);
125 im(:,:,1) = checkerboard (100) > 0.2;
126 im(:,:,3) = checkerboard (100) < 0.2;
127 [im2 xdata ydata] = imtransform (im, T, 'udata', [-2 2],
128 'vdata', [-2 2], 'fillvalues',
129 [0 1 0]);
130 imh = imshow (im2);
131 set (imh, 'xdata', xdata, 'ydata', ydata)
132 set (gca, 'xlim', xdata, 'ylim', ydata)
133 [im cmap] = imread ('default.img');
134 subplot (1,2,2)
135 [im2 xdata ydata] = imtransform (im, T, 'udata', [-1 1],
136 'vdata', [-1 1], 'fillvalues',
137 round (length (cmap) / 2));
138 imh = imshow (im2, cmap);
139 ***** test
140 im = checkerboard ();
141 incp = [0 0; 0 1; 1 1];
142 scl = 10;
143 outcp = scl * incp;
144 T = maketform ('affine', incp, outcp);
145 [im2 xdata ydata] = imtransform (im, T, 'udata', [0 1],
146 'vdata', [0 1], 'size', [500 500]);
147 assert (xdata, scl * ([0 1]))
148 assert (ydata, scl * ([0 1]))
149 assert (size (im2), [500 500])
150 ***** test
151 im = checkerboard ();
152 incp = [0 0; 0 1; 1 1];
153 scl = 10;
154 outcp = scl * incp;
155 xyscale = scl;
156 T = maketform ('affine', incp, outcp);
157 [im2 xdata ydata] = imtransform (im, T, 'xyscale', xyscale);
158 assert (size (im2), size (im), 1)
159 ***** test
160 im = checkerboard (100, 10, 4);
161 theta = 2 * pi;
162 T = maketform ("affine", [cos(theta) -sin(theta); ...
163 sin(theta) cos(theta); 0 0]);
164 im2 = imtransform (im, T, "nearest", "xdata", [1 800], "ydata", [1 2000]);
165 im = im(2:end-1, 2:end-1); %avoid boundaries
166 im2 = im2(2:end-1, 2:end-1);
167 assert (im, im2)
168 ***** test
169 im = checkerboard (20, 10, 4);
170 theta = pi/6;
171 T = maketform ('affine', [cos(theta) -sin(theta); ...
172 sin(theta) cos(theta); 0 0]);
173 [im2, xdata] = imtransform (im, T);
174 nu = columns(im);
175 nv = rows(im);
176 nx = xdata(2);
177 diag = sqrt (nu^2 + nv^2);
178 ang = atan (nv / nu);
179 assert (nx, diag * abs (cos (theta - ang)),
180 diag * 1 / size (im2, 2))
181 ***** test
182 im = rand (2);
183 tmat = [eye(2); 0 0];
184 T = maketform ("affine", tmat);
185 im2 = imtransform (im, T, "xdata", [1 3]);
186 assert (im2(:,3), zeros (2,1))
187 ***** test
188 im = rand (2);
189 tmat = [eye(2); 0 0];
190 T = maketform ('affine', tmat);
191 im2 = imtransform (im, T, "xdata", [1 3]);
192 assert (size (im2), [2 3])
193 ***** test
194 im = rand (2);
195 tmat = [eye(2); 0 0];
196 T = maketform ('affine', tmat);
197 im2 = imtransform (im, T, "xyscale", [0.5 0.5]);
198 assert (size (im2), [3 3])
199 7 tests, 7 passed, 0 known failure, 0 skipped
200 [iptcheckmap]
201 >>>>> /usr/share/octave/packages/image-2.6.1/iptcheckmap.m
202 ***** test ("iptcheckmap (jet(64), 'func', 'var', 2)");
203 ***** fail ("iptcheckmap (3, 'func', 'var', 2)");
204 2 tests, 2 passed, 0 known failure, 0 skipped
205 [bwhitmiss]
206 >>>>> /usr/share/octave/packages/image-2.6.1/bwhitmiss.m
207 ***** test
208 bw1 = repmat ([0 1 0 1 1], [3 1]);
209 bw2 = repmat ([0 1 0 0 0], [3 1]);
210 assert (bwhitmiss (bw1, [1; 0; 1], [1 0 1]), logical (bw2))
211 assert (bwhitmiss (bw1, [0 1 0; -1 0 -1; 0 1 0]), logical (bw2))
212 1 test, 1 passed, 0 known failure, 0 skipped
213 [padarray]
214 >>>>> /usr/share/octave/packages/image-2.6.1/padarray.m
215 ***** demo
216 padarray([1,2,3;4,5,6],[2,1])
217 % pads [1,2,3;4,5,6] with a whole border of 2 rows and 1 columns of 0
218 ***** demo
219 padarray([1,2,3;4,5,6],[2,1],5)
220 % pads [1,2,3;4,5,6] with a whole border of 2 rows and 1 columns of 5
221 ***** demo
222 padarray([1,2,3;4,5,6],[2,1],0,'pre')
223 % pads [1,2,3;4,5,6] with a left and top border of 2 rows and 1 columns of 0
224 ***** demo
225 padarray([1,2,3;4,5,6],[2,1],'circular')
226 % pads [1,2,3;4,5,6] with a whole 'circular' border of 2 rows and 1 columns
227 % border 'repeats' data as if we tiled blocks of data
228 ***** demo
229 padarray([1,2,3;4,5,6],[2,1],'replicate')
230 % pads [1,2,3;4,5,6] with a whole border of 2 rows and 1 columns which
231 % 'replicates' edge data
232 ***** demo
233 padarray([1,2,3;4,5,6],[2,1],'symmetric')
234 % pads [1,2,3;4,5,6] with a whole border of 2 rows and 1 columns which
235 % is symmetric to the data on the edge
236 ***** assert (padarray ([1;2], [1]), [0;1;2;0]);
237 ***** assert (padarray ([3 4], [0 2]), [0 0 3 4 0 0]);
238 ***** assert (padarray ([1 2 3; 4 5 6], [1 2]),
239 [zeros(1, 7); 0 0 1 2 3 0 0; 0 0 4 5 6 0 0; zeros(1, 7)]);
240 ***** test
241 assert (padarray ([1 2 3; 4 5 6], [3 2 1]),
242 cat(3, zeros(8, 7),
243 [ [ zeros(3, 7) ]
244 [zeros(2, 2) [1 2 3; 4 5 6] zeros(2, 2) ]
245 [ zeros(3,7)] ],
246 zeros (8, 7)));
247 ***** assert (padarray ([1 2], [4 5]), padarray ([1 2], [4 5], 0));
248 ***** assert (padarray ([1 2], [4 5]), padarray ([1 2], [4 5], "both"));
249 ***** assert (padarray ([1;2], [1], i), [i; 1; 2; i]);
250 ***** assert (padarray ([1;2], [1], i, "pre"), [i; 1; 2]);
251 ***** assert (padarray ([1;2], [1], i, "post"), [1; 2; i]);
252 ***** assert (padarray ([1;2], [1], i, "both"), [i; 1; 2; i]);
253 ***** assert (padarray ([1 2], [0 1], i, "pre"), [i 1 2]);
254 ***** assert (padarray ([1 2], [0 1], i, "post"), [1 2 i]);
255 ***** assert (padarray ([1 2], [0 1], i, "both"), [i 1 2 i]);
256 ***** assert (padarray ([1 2], [0;1], i, "both"), [i 1 2 i]);
257 ***** test
258 A = [1 2 3; 4 5 6];
259 B = repmat (A, 7, 9);
260 assert (padarray (A, [1 2], "circular", "pre"), B(2:4,2:6));
261 assert (padarray (A, [1 2], "circular", "post"), B(3:5,4:8));
262 assert (padarray (A, [1 2], "circular", "both"), B(2:5,2:8));
263 ## This tests when padding is bigger than data
264 assert (padarray (A, [5 10], "circular", "both"), B(2:13,3:25));
265 ***** test
266 A = int8 ([1 2 3; 4 5 6]);
267 B = repmat (A, 7, 9);
268 assert (padarray (A, [1 2], "circular", "pre"), B(2:4,2:6));
269 assert (padarray (A, [1 2], "circular", "post"), B(3:5,4:8));
270 assert (padarray (A, [1 2], "circular", "both"), B(2:5,2:8));
271 ## This tests when padding is bigger than data
272 assert (padarray (A, [5 10], "circular", "both"), B(2:13,3:25));
273 ***** test
274 A = [1 2; 3 4];
275 B = kron (A, ones (10, 5));
276 assert (padarray (A, [9 4], "replicate", "pre"), B(1:11,1:6));
277 assert (padarray (A, [9 4], "replicate", "post"), B(10:20,5:10));
278 assert (padarray (A, [9 4], "replicate", "both"), B);
279 ## same with uint class
280 assert (padarray (uint8 (A), [9 4], "replicate", "pre"), uint8 (B(1:11,1:6)));
281 assert (padarray (uint8 (A), [9 4], "replicate", "post"), uint8 (B(10:20,5:10)));
282 assert (padarray (uint8 (A), [9 4], "replicate", "both"), uint8 (B));
283 ***** test
284 A = [1:3
285 4:6];
286 HA = [3:-1:1
287 6:-1:4];
288 VA = [4:6
289 1:3];
290 VHA = [6:-1:4
291 3:-1:1];
292 B = [VHA VA VHA
293 HA A HA
294 VHA VA VHA];
295 assert (padarray (A, [1 2], "symmetric", "pre"), B(2:4,2:6));
296 assert (padarray (A, [1 2], "symmetric", "post"), B(3:5,4:8));
297 assert (padarray (A, [1 2], "symmetric", "both"), B(2:5,2:8));
298 ## same with int class
299 assert (padarray (int16 (A), [1 2], "symmetric", "pre"), int16 (B(2:4,2:6)));
300 assert (padarray (int16 (A), [1 2], "symmetric", "post"), int16 (B(3:5,4:8)));
301 assert (padarray (int16 (A), [1 2], "symmetric", "both"), int16 (B(2:5,2:8)));
302 ***** assert (padarray (int8 ([1; 2]), [1]), int8 ([0; 1; 2; 0]));
303 ***** assert (padarray (uint8 ([3 4]), [0 2]), uint8 ([0 0 3 4 0 0]));
304 ***** assert (padarray (int16 ([1; 2]), [1], 4), int16 ([4; 1; 2; 4]));
305 ***** assert (padarray (uint16 ([1; 2]), [1], 0), uint16 ([0; 1; 2; 0]));
306 ***** assert (padarray (uint32 ([1; 2]), [1], 6, "post"), uint32 ([1; 2; 6]));
307 ***** assert (padarray (int32 ([1; 2]), [1], int32 (4), "pre"), int32 ([4; 1; 2]));
308 ***** test
309 in = [ 7 5 1 3
310 5 3 3 4
311 7 5 2 3
312 6 1 3 8];
313 padded = [
314 3 5 5 3 3 4 4 3 3 5 5 3 3 4 4 3 3 5 5 3 3 4 4 3
315 5 7 7 5 1 3 3 1 5 7 7 5 1 3 3 1 5 7 7 5 1 3 3 1
316 5 7 7 5 1 3 3 1 5 7 7 5 1 3 3 1 5 7 7 5 1 3 3 1
317 3 5 5 3 3 4 4 3 3 5 5 3 3 4 4 3 3 5 5 3 3 4 4 3
318 5 7 7 5 2 3 3 2 5 7 7 5 2 3 3 2 5 7 7 5 2 3 3 2
319 1 6 6 1 3 8 8 3 1 6 6 1 3 8 8 3 1 6 6 1 3 8 8 3
320 1 6 6 1 3 8 8 3 1 6 6 1 3 8 8 3 1 6 6 1 3 8 8 3
321 5 7 7 5 2 3 3 2 5 7 7 5 2 3 3 2 5 7 7 5 2 3 3 2
322 3 5 5 3 3 4 4 3 3 5 5 3 3 4 4 3 3 5 5 3 3 4 4 3
323 5 7 7 5 1 3 3 1 5 7 7 5 1 3 3 1 5 7 7 5 1 3 3 1
324 5 7 7 5 1 3 3 1 5 7 7 5 1 3 3 1 5 7 7 5 1 3 3 1
325 3 5 5 3 3 4 4 3 3 5 5 3 3 4 4 3 3 5 5 3 3 4 4 3
326 5 7 7 5 2 3 3 2 5 7 7 5 2 3 3 2 5 7 7 5 2 3 3 2
327 1 6 6 1 3 8 8 3 1 6 6 1 3 8 8 3 1 6 6 1 3 8 8 3
328 1 6 6 1 3 8 8 3 1 6 6 1 3 8 8 3 1 6 6 1 3 8 8 3
329 5 7 7 5 2 3 3 2 5 7 7 5 2 3 3 2 5 7 7 5 2 3 3 2
330 3 5 5 3 3 4 4 3 3 5 5 3 3 4 4 3 3 5 5 3 3 4 4 3
331 5 7 7 5 1 3 3 1 5 7 7 5 1 3 3 1 5 7 7 5 1 3 3 1
332 5 7 7 5 1 3 3 1 5 7 7 5 1 3 3 1 5 7 7 5 1 3 3 1
333 3 5 5 3 3 4 4 3 3 5 5 3 3 4 4 3 3 5 5 3 3 4 4 3
334 5 7 7 5 2 3 3 2 5 7 7 5 2 3 3 2 5 7 7 5 2 3 3 2
335 1 6 6 1 3 8 8 3 1 6 6 1 3 8 8 3 1 6 6 1 3 8 8 3
336 1 6 6 1 3 8 8 3 1 6 6 1 3 8 8 3 1 6 6 1 3 8 8 3
337 5 7 7 5 2 3 3 2 5 7 7 5 2 3 3 2 5 7 7 5 2 3 3 2];
338 for ite = 1:10
339 assert (padarray (in, [ite ite], "symmetric"), padded((11-ite):(14+ite),(11-ite):(14+ite)));
340 assert (padarray (in, [ite ite], "symmetric", "pre"), padded((11-ite):14,(11-ite):14));
341 assert (padarray (in, [ite ite], "symmetric", "post"), padded(11:(14+ite),11:(14+ite)));
342 endfor
343 ***** test
344 in = [ 7 5 4 9
345 6 4 5 1
346 5 3 3 3
347 2 6 7 3];
348 padded = [
349 3 3 3 3 5 3 3 3 3 3 5 3 3 3 3 3 5 3 3 3 3 3 5 3
350 7 3 7 6 2 6 7 3 7 6 2 6 7 3 7 6 2 6 7 3 7 6 2 6
351 3 3 3 3 5 3 3 3 3 3 5 3 3 3 3 3 5 3 3 3 3 3 5 3
352 5 1 5 4 6 4 5 1 5 4 6 4 5 1 5 4 6 4 5 1 5 4 6 4
353 4 9 4 5 7 5 4 9 4 5 7 5 4 9 4 5 7 5 4 9 4 5 7 5
354 5 1 5 4 6 4 5 1 5 4 6 4 5 1 5 4 6 4 5 1 5 4 6 4
355 3 3 3 3 5 3 3 3 3 3 5 3 3 3 3 3 5 3 3 3 3 3 5 3
356 7 3 7 6 2 6 7 3 7 6 2 6 7 3 7 6 2 6 7 3 7 6 2 6
357 3 3 3 3 5 3 3 3 3 3 5 3 3 3 3 3 5 3 3 3 3 3 5 3
358 5 1 5 4 6 4 5 1 5 4 6 4 5 1 5 4 6 4 5 1 5 4 6 4
359 4 9 4 5 7 5 4 9 4 5 7 5 4 9 4 5 7 5 4 9 4 5 7 5
360 5 1 5 4 6 4 5 1 5 4 6 4 5 1 5 4 6 4 5 1 5 4 6 4
361 3 3 3 3 5 3 3 3 3 3 5 3 3 3 3 3 5 3 3 3 3 3 5 3
362 7 3 7 6 2 6 7 3 7 6 2 6 7 3 7 6 2 6 7 3 7 6 2 6
363 3 3 3 3 5 3 3 3 3 3 5 3 3 3 3 3 5 3 3 3 3 3 5 3
364 5 1 5 4 6 4 5 1 5 4 6 4 5 1 5 4 6 4 5 1 5 4 6 4
365 4 9 4 5 7 5 4 9 4 5 7 5 4 9 4 5 7 5 4 9 4 5 7 5
366 5 1 5 4 6 4 5 1 5 4 6 4 5 1 5 4 6 4 5 1 5 4 6 4
367 3 3 3 3 5 3 3 3 3 3 5 3 3 3 3 3 5 3 3 3 3 3 5 3
368 7 3 7 6 2 6 7 3 7 6 2 6 7 3 7 6 2 6 7 3 7 6 2 6
369 3 3 3 3 5 3 3 3 3 3 5 3 3 3 3 3 5 3 3 3 3 3 5 3
370 5 1 5 4 6 4 5 1 5 4 6 4 5 1 5 4 6 4 5 1 5 4 6 4
371 4 9 4 5 7 5 4 9 4 5 7 5 4 9 4 5 7 5 4 9 4 5 7 5
372 5 1 5 4 6 4 5 1 5 4 6 4 5 1 5 4 6 4 5 1 5 4 6 4];
373 for ite = 1:10
374 assert (padarray (in, [ite ite], "reflect"), padded((11-ite):(14+ite),(11-ite):(14+ite)));
375 assert (padarray (in, [ite ite], "reflect", "pre"), padded((11-ite):14,(11-ite):14));
376 assert (padarray (in, [ite ite], "reflect", "post"), padded(11:(14+ite),11:(14+ite)));
377 endfor
378 26 tests, 26 passed, 0 known failure, 0 skipped
379 [lab2uint8]
380 >>>>> /usr/share/octave/packages/image-2.6.1/lab2uint8.m
381 ***** test
382 cm_uint8 = uint8 ([0 1 2 3 4 127 128 200 254 255]);
383 cm_uint8 = repmat (cm_uint8(:), [1 3]);
384 im2d_uint8 = reshape (cm_uint8, [5 2 3]);
385 imnd_uint8 = permute (im2d_uint8, [1 4 3 2]);
386
387 cm_uint16 = uint16 ([0 256 512 768 1024 32512 32768 51200 65024 65280]);
388 cm_uint16 = repmat (cm_uint16(:), [1 3]);
389 assert (lab2uint16 (cm_uint8), cm_uint16)
390 im2d_uint16 = reshape (cm_uint16, [5 2 3]);
391 assert (lab2uint16 (im2d_uint8), im2d_uint16)
392 assert (lab2uint16 (imnd_uint8), permute (im2d_uint16, [1 4 3 2]))
393
394 l1 = 100/255;
395 cm = [
396 0 -128 -128
397 l1 -127 -127
398 2*l1 -126 -126
399 3*l1 -125 -125
400 4*l1 -124 -124
401 127*l1 -1 -1
402 128*l1 0 0
403 200*l1 72 72
404 254*l1 126 126
405 100 127 127];
406 im2d = reshape (cm, [5 2 3]);
407 imnd = permute (im2d, [1 4 3 2]);
408
409 assert (lab2double (cm_uint8), cm)
410 assert (lab2double (im2d_uint8), im2d)
411 assert (lab2double (imnd_uint8), imnd)
412
413 assert (lab2single (cm_uint8), single (cm))
414 assert (lab2single (im2d_uint8), single (im2d))
415 assert (lab2single (imnd_uint8), single (imnd))
416 1 test, 1 passed, 0 known failure, 0 skipped
417 [imabsdiff]
418 >>>>> /usr/share/octave/packages/image-2.6.1/imabsdiff.m
419 ***** assert (imabsdiff (uint8 ([23 250]), uint8 ([26 50])), uint8 ([ 3 200]));
420 ***** assert (imabsdiff (uint8 ([23 250]), uint8 ([24 50]), "uint16"), uint16 ([ 1 200]));
421 ***** assert (imabsdiff (uint8 ([23 250]), uint8 ([24 255]), "int8"), int8 ([ 1 5]));
422 ***** assert (imabsdiff (logical ([ 1 0]), logical ([ 1 1])), double ([ 0 1]));
423 ***** fail ("imabsdiff (uint8 ([23 250]), 30");
424 ***** fail ("imabsdiff (uint8 ([23 250]), uint16 ([23 250]))");
425 6 tests, 6 passed, 0 known failure, 0 skipped
426 [imcast]
427 >>>>> /usr/share/octave/packages/image-2.6.1/imcast.m
428 ***** test
429 im = randi ([0 255], 40, "uint8");
430 assert (imcast (im, "uint8"), im2uint8 (im))
431 assert (imcast (im, "uint16"), im2uint16 (im))
432 assert (imcast (im, "single"), im2single (im))
433 assert (imcast (im, "uint8", "indexed"), im2uint8 (im, "indexed"))
434 assert (imcast (im, "uint16", "indexed"), im2uint16 (im, "indexed"))
435 assert (imcast (im, "single", "indexed"), im2single (im, "indexed"))
436 ***** test
437 im = randi ([1 256], 40, "double");
438 assert (imcast (im, "uint8"), im2uint8 (im))
439 assert (imcast (im, "uint8", "indexed"), im2uint8 (im, "indexed"))
440 assert (imcast (im, "single", "indexed"), im2single (im, "indexed"))
441 ***** test
442 im = randi ([0 65535], 40, "uint16");
443 assert (imcast (im, "uint8"), im2uint8 (im))
444 assert (imcast (im, "single"), im2single (im))
445 assert (imcast (im, "single", "indexed"), im2single (im, "indexed"))
446 ***** test
447 im = randi ([1 255], 40, "double");
448 assert (imcast (im, "uint8", "indexed"), im2uint8 (im, "indexed"))
449 assert (imcast (im, "single", "indexed"), im2single (im, "indexed"))
450 ***** test
451 im = rand (40);
452 assert (imcast (im, "uint8"), im2uint8 (im))
453 ***** error <unknown image of class> imcast (randi (127, 40, "int8"), "uint8")
454 ***** error <unsupported TYPE> imcast (randi (255, 40, "uint8"), "uint32")
455 ***** error <unsupported TYPE> imcast (randi (255, 40, "uint8"), "not a class")
456 ***** error <range of values> imcast (randi ([0 65535], 40, "uint16"), "uint8", "indexed")
457 9 tests, 9 passed, 0 known failure, 0 skipped
458 [label2rgb]
459 >>>>> /usr/share/octave/packages/image-2.6.1/label2rgb.m
460 ***** function map = test_colormap ()
461 map = [0 0 0; 0.5 0.5 0.5; 0.125 0.125 0.125];
462 ***** endfunction
463 ***** shared in, out, cmap
464 in = [ 0 1 1 0 2 2 0 3 3
465 0 1 1 0 2 2 0 3 3];
466
467 out = [255 0 0 255 128 128 255 32 32
468 255 0 0 255 128 128 255 32 32];
469 out(:,:,2) = out(:,:,3) = out(:,:,1);
470 out = uint8(out);
471
472 cmap = [0 0 0; 0.5 0.5 0.5; 0.125 0.125 0.125];
473 ***** assert (label2rgb (in, cmap), out);
474 ***** assert (label2rgb (uint8 (in), cmap), out);
475 ***** assert (label2rgb (in, "test_colormap"), out);
476 ***** assert (label2rgb (in, @test_colormap), out);
477
478 out(find (in == 0)) = 0;
479 ***** assert (label2rgb (in, cmap, "cyan"), out);
480 ***** assert (label2rgb (in, cmap, [0 1 1]), out);
481
482 in(1) = 10;
483 ***** error label2rgb (in, cmap);
484 ***** error label2rgb (in, cmap, 89);
485 ***** error label2rgb (in, cmap, "g", "wrong");
486 9 tests, 9 passed, 0 known failure, 0 skipped
487 [lab2rgb]
488 >>>>> /usr/share/octave/packages/image-2.6.1/lab2rgb.m
489 ***** assert (lab2rgb ([0 0 0]), [0, 0, 0], 1e-3)
490 ***** assert (lab2rgb ([53.24, 80.09, 67.20]), [1 0 0], 1e-3)
491 ***** assert (lab2rgb ([97.14, -21.55, 94.48]), [1 1 0], 1e-3)
492 ***** assert (lab2rgb ([87.74, -86.18, 83.18]), [0 1 0], 1e-3)
493 ***** assert (lab2rgb ([91.11, -48.09, -14.13]), [0 1 1], 1e-3)
494 ***** assert (lab2rgb ([32.30, 79.19, -107.86]), [0 0 1], 1e-3)
495 ***** assert (lab2rgb ([60.32, 98.24, -60.83]), [1 0 1], 1e-3)
496 ***** assert (lab2rgb ([100, 0.00, 0.00]), [1 1 1], 1e-3)
497 ***** assert (lab2rgb ([53.39, 0.00, 0.00]), [0.5 0.5 0.5], 1e-3)
498 ***** assert (lab2rgb ([39.77, 64.51, 54.13]), [0.75 0 0], 1e-3)
499 ***** assert (lab2rgb ([25.42, 47.91, 37.91]), [0.5 0 0], 1e-3)
500 ***** assert (lab2rgb ([9.66, 29.68, 15.24]), [0.25 0 0], 1e-3)
501 ***** assert (lab2rgb ([68.11, 48.39, 22.83]), [1 0.5 0.5], 1e-3)
502 ***** assert (lab2rgb ([150 130 130]), [2.714, 1.028, 0.492], 1e-3)
503 ***** test
504 lab_map = rand (64, 3);
505 lab_map(:,1) = lab_map(:,1) .* 100;
506 lab_map(:,2) = lab_map(:,2) .* 254 - 127;
507 lab_map(:,3) = lab_map(:,3) .* 254 - 127;
508 assert (rgb2lab (lab2rgb (lab_map)), lab_map, 5e-3);
509 ***** test
510 lab_img = rand (64, 64, 3);
511 lab_img(:,:,1) = lab_img(:,:,1) .* 100;
512 lab_img(:,:,2) = lab_img(:,:,2) .* 254 - 127;
513 lab_img(:,:,3) = lab_img(:,:,3) .* 254 - 127;
514 assert (rgb2lab (lab2rgb (lab_img)), lab_img, 5e-3);
515 ***** assert (lab2rgb (sparse ([0 0 0])), [0 0 0], 1e-3)
516 ***** assert (lab2rgb (sparse ([100, 0.00, 0.00])), [1 1 1], 1e-3)
517 ***** assert (class (lab2rgb (single([50 50 50]))), 'single')
518 ***** error lab2rgb ()
519 ***** error lab2rgb (1,2)
520 ***** error <invalid data type 'cell'> lab2rgb ({1})
521 ***** error <Lab must be a colormap or Lab image> lab2rgb (ones (2,2))
522 ***** test
523 lab = rand (16, 16, 3, 5);
524 lab(:,:,1,:) = lab(:,:,1,:) .* 100;
525 lab(:,:,2,:) = lab(:,:,2,:) .* 254 - 127;
526 lab(:,:,3,:) = lab(:,:,3,:) .* 254 - 127;
527 rgb = zeros (size (lab));
528 for i = 1:5
529 rgb(:,:,:,i) = lab2rgb (lab(:,:,:,i));
530 endfor
531 assert (lab2rgb (lab), rgb)
532 24 tests, 24 passed, 0 known failure, 0 skipped
533 [imnoise]
534 >>>>> /usr/share/octave/packages/image-2.6.1/imnoise.m
535 ***** assert(var(imnoise(ones(10)/2,'gaussian')(:)),0.01,0.005)
536 ***** assert(length(find(imnoise(ones(10)/2,'salt & pepper')~=0.5)),5,10)
537 ***** assert(var(imnoise(ones(10)/2,'speckle')(:)),0.01,0.005)
538 ***** test
539 A = imnoise (.5 * ones (100), 'poisson');
540 assert (class (A), 'double')
541 ***** test
542 A = imnoise (.5 * ones (100, 'single'), 'poisson');
543 assert (class (A), 'single')
544 ***** test
545 A = imnoise (128 * ones (100, 'uint8'), 'poisson');
546 assert (class (A), 'uint8')
547 ***** test
548 A = imnoise (256 * ones (100, 'uint16'), 'poisson');
549 assert (class (A), 'uint16')
550 ***** demo
551 A = imnoise (2^7 * ones (100, 'uint8'), 'poisson');
552 subplot (2, 2, 1)
553 imshow (A)
554 title ('uint8 image with poisson noise')
555 A = imnoise (2^15 * ones (100, 'uint16'), 'poisson');
556 subplot (2, 2, 2)
557 imshow (A)
558 title ('uint16 image with poisson noise')
559 A = imnoise (.5 * ones (100), 'poisson');
560 subplot (2, 2, 3)
561 imshow (A)
562 title ('double image with poisson noise')
563 A = imnoise (.5 * ones (100, 'single'), 'poisson');
564 subplot (2, 2, 4)
565 imshow (A)
566 title ('single image with poisson noise')
567 7 tests, 7 passed, 0 known failure, 0 skipped
568 [imtranslate]
569 >>>>> /usr/share/octave/packages/image-2.6.1/imtranslate.m
570 ***** test
571 obs = imtranslate (ones (5, 5), 2, 1, "crop");
572 exp = zeros (5, 5);
573 exp(1:4, 3:5) = 1;
574 assert (obs, exp, eps * 10)
575
576 obs = imtranslate (ones (5, 5), -2, -1, "crop");
577 exp = zeros (5, 5);
578 exp(2:5, 1:3) = 1;
579 assert (obs, exp, eps * 10)
580 1 test, 1 passed, 0 known failure, 0 skipped
581 [rgb2lab]
582 >>>>> /usr/share/octave/packages/image-2.6.1/rgb2lab.m
583 ***** assert (rgb2lab ([0 0 0]), [0, 0, 0], 1e-2)
584 ***** assert (rgb2lab ([1 0 0]), [53.24, 80.09, 67.20], 1e-2)
585 ***** assert (rgb2lab ([1 1 0]), [97.14, -21.55, 94.48], 1e-2)
586 ***** assert (rgb2lab ([0 1 0]), [87.74, -86.18, 83.18], 1e-2)
587 ***** assert (rgb2lab ([0 1 1]), [91.11, -48.09, -14.13], 1e-2)
588 ***** assert (rgb2lab ([0 0 1]), [32.30, 79.19, -107.86], 1e-2)
589 ***** assert (rgb2lab ([1 0 1]), [60.32, 98.24, -60.83], 1e-2)
590 ***** assert (rgb2lab ([1 1 1]), [100, 0.00, 0.00], 1e-2)
591 ***** assert (rgb2lab ([0.5 0.5 0.5]), [53.39, 0.00, 0.00], 1e-2)
592 ***** assert (rgb2lab ([0.75 0 0]), [39.77, 64.51, 54.13], 1e-2)
593 ***** assert (rgb2lab ([0.5 0 0]), [25.42, 47.91, 37.91], 1e-2)
594 ***** assert (rgb2lab ([0.25 0 0]), [9.66, 29.68, 15.24], 1e-2)
595 ***** assert (rgb2lab ([1 0.5 0.5]), [68.11, 48.39, 22.83], 1e-2)
596 ***** assert (rgb2lab ([1.5 1 1]), [111.47, 43.42, 17.98], 1e-2)
597 ***** test
598 rgb_map = rand (64, 3);
599 assert (lab2rgb (rgb2lab (rgb_map)), rgb_map, 2e-5);
600 ***** test
601 rgb_img = rand (64, 64, 3);
602 assert (lab2rgb (rgb2lab (rgb_img)), rgb_img, 2e-5);
603 ***** assert (rgb2lab (sparse ([0 0 1])), sparse ([32.30, 79.19, -107.86]), 1e-2)
604 ***** assert (rgb2lab (sparse ([0 1 1])), sparse ([91.11, -48.09, -14.13]), 1e-2)
605 ***** assert (rgb2lab (sparse ([1 1 1])), sparse ([100, 0.00, 0.00]), 1e-2)
606 ***** assert (rgb2lab (uint8([255 255 255])), [100, 0.00, 0.00], 1e-2)
607 ***** assert (class (rgb2lab (single([1 1 1]))), 'single')
608 ***** error rgb2lab ()
609 ***** error rgb2lab (1,2)
610 ***** error <invalid data type 'cell'> rgb2lab ({1})
611 ***** error <RGB must be a colormap or RGB image> rgb2lab (ones (2,2))
612 ***** test
613 rgb = rand (16, 16, 3, 5);
614 lab = zeros (size (rgb));
615 for i = 1:5
616 lab(:,:,:,i) = rgb2lab (rgb(:,:,:,i));
617 endfor
618 assert (rgb2lab (rgb), lab)
619 26 tests, 26 passed, 0 known failure, 0 skipped
620 [imregionalmin]
621 >>>>> /usr/share/octave/packages/image-2.6.1/imregionalmin.m
622 ***** test
623 a = [
624 7 3 9 3 10 3
625 4 2 3 10 1 3
626 1 4 6 9 4 10
627 8 7 9 3 4 8
628 5 9 3 3 8 9
629 3 6 9 4 1 10];
630
631 a4 = logical ([
632 0 0 0 1 0 0
633 0 1 0 0 1 0
634 1 0 0 0 0 0
635 0 0 0 1 0 0
636 0 0 1 1 0 0
637 1 0 0 0 1 0]);
638 assert (imregionalmin (a, 4), a4)
639 assert (imregionalmin (uint8 (a), 4), a4)
640 assert (imregionalmin (int8 (a), 4), a4)
641
642 a8 = logical ([
643 0 0 0 0 0 0
644 0 0 0 0 1 0
645 1 0 0 0 0 0
646 0 0 0 0 0 0
647 0 0 0 0 0 0
648 1 0 0 0 1 0]);
649 assert (imregionalmin (a), a8)
650 assert (imregionalmin (a, 8), a8)
651 assert (imregionalmin (uint8 (a), 8), a8)
652 assert (imregionalmin (int8 (a), 8), a8)
653 ***** test
654 a = [
655 4 8 5 -1 8 7
656 -1 4 0 7 1 1
657 6 1 2 6 7 0
658 6 1 5 -2 5 9
659 1 4 -1 0 0 2
660 4 6 1 0 7 1];
661
662 a4 = logical ([
663 0 0 0 1 0 0
664 1 0 1 0 0 0
665 0 1 0 0 0 1
666 0 1 0 1 0 0
667 1 0 1 0 0 0
668 0 0 0 0 0 1]);
669 assert (imregionalmin (a, 4), a4)
670 assert (imregionalmin (int8 (a), 4), a4)
671
672 a8 = logical ([
673 0 0 0 1 0 0
674 1 0 0 0 0 0
675 0 0 0 0 0 1
676 0 0 0 1 0 0
677 0 0 0 0 0 0
678 0 0 0 0 0 0]);
679 assert (imregionalmin (a), a8)
680 assert (imregionalmin (a, 8), a8)
681 assert (imregionalmin (int8 (a), 8), a8)
682 2 tests, 2 passed, 0 known failure, 0 skipped
683 [xyz2rgb]
684 >>>>> /usr/share/octave/packages/image-2.6.1/xyz2rgb.m
685 ***** assert (xyz2rgb ([0, 0, 0]), [0 0 0], 1e-3)
686 ***** assert (xyz2rgb ([0.4125, 0.2127, 0.0193]), [1 0 0], 1e-3)
687 ***** assert (xyz2rgb ([0.7700, 0.9278, 0.1385]), [1 1 0], 1e-3)
688 ***** assert (xyz2rgb ([0.3576, 0.7152, 0.1192]), [0 1 0], 1e-3)
689 ***** assert (xyz2rgb ([0.5380, 0.7873, 1.0694]), [0 1 1], 1e-3)
690 ***** assert (xyz2rgb ([0.1804, 0.07217, 0.9502]), [0 0 1], 1e-3)
691 ***** assert (xyz2rgb ([0.5929, 0.28484, 0.9696]), [1 0 1], 1e-3)
692 ***** assert (xyz2rgb ([0.9505, 1.0000, 1.0888]), [1 1 1], 1e-3)
693 ***** assert (xyz2rgb ([0.2034, 0.2140, 0.2330]), [0.5 0.5 0.5], 1e-3)
694 ***** assert (xyz2rgb ([0.2155, 0.1111, 0.0101]), [0.75 0 0], 1e-3)
695 ***** assert (xyz2rgb ([0.0883, 0.0455, 0.0041]), [0.5 0 0], 1e-3)
696 ***** assert (xyz2rgb ([0.0210, 0.0108, 0.0010]), [0.25 0 0], 1e-3)
697 ***** assert (xyz2rgb ([0.5276, 0.3812, 0.2482]), [1 0.5 0.5], 1e-3)
698 ***** assert (xyz2rgb ([1.5 1 1]), [1.5712, 0.7109 0.9717], 1e-3)
699 ***** test
700 xyz_map = rand (64, 3);
701 assert (rgb2xyz (xyz2rgb (xyz_map)), xyz_map, 3e-4);
702 ***** test
703 xyz_img = rand (64, 64, 3);
704 assert (rgb2xyz (xyz2rgb (xyz_img)), xyz_img, 3e-4);
705 ***** assert (xyz2rgb (sparse ([0 0 0])), [0 0 0], 1e-3)
706 ***** assert (class (xyz2rgb (single([0.5 0.5 0.5]))), 'single')
707 ***** error xyz2rgb ()
708 ***** error xyz2rgb (1,2)
709 ***** error <invalid data type 'cell'> xyz2rgb ({1})
710 ***** error <XYZ must be a colormap or XYZ image> xyz2rgb (ones (2,2))
711 ***** test
712 xyz = rand (16, 16, 3, 5);
713 rgb = zeros (size (xyz));
714 for i = 1:5
715 rgb(:,:,:,i) = xyz2rgb (xyz(:,:,:,i));
716 endfor
717 assert (xyz2rgb (xyz), rgb)
718 23 tests, 23 passed, 0 known failure, 0 skipped
719 [graythresh]
720 >>>>> /usr/share/octave/packages/image-2.6.1/graythresh.m
721 ***** shared img, histo
722 ## this is the old default.img that came with GNU Octave. While the current
723 ## is very very similar, is off just enough for us to get precision errors
724 img = uint8 (reshape ([138 138 138 142 142 138 142 138 138 117 105 81 69 61 53 40 49 45 40 36 40 45 53 49 65 73 121 166 210 243 247 247 247 239 235 178 154 170 150 150 162 174 190 190 194 186 178 170 154 182 198 174 117 138 138 142 138 142 142 146 142 138 138 130 109 97 81 73 69 57 53 53 57 61 61 69 73 77 105 121 158 219 243 243 247 243 243 243 206 150 158 158 158 150 158 182 186 190 194 186 174 190 206 198 162 138 142 138 142 146 138 142 142 138 146 142 134 142 130 121 101 97 85 85 81 81 81 85 93 85 73 57 61 93 150 194 215 239 243 243 243 223 166 138 158 158 154 142 162 178 190 190 198 186 182 186 174 162 182 146 142 138 142 142 146 142 146 146 146 146 142 142 142 134 125 101 85 73 65 69 73 73 57 40 53 49 57 69 85 125 166 182 178 178 174 150 130 121 146 146 150 142 166 182 190 182 174 166 162 170 194 198 138 138 146 146 138 146 146 146 146 142 150 146 146 142 130 93 65 45 45 49 45 40 49 40 49 49 49 49 61 81 113 142 150 154 154 146 142 134 125 125 138 134 125 146 162 178 178 178 166 186 202 206 186 142 142 142 134 142 146 142 150 142 146 142 146 146 130 81 53 49 49 45 49 40 36 36 32 36 36 36 53 73 89 125 150 146 134 138 146 138 146 138 142 117 117 113 117 146 166 174 178 182 178 178 170 146 142 142 138 142 146 142 142 146 150 138 146 142 130 73 49 40 49 57 65 69 73 61 61 53 57 53 61 77 77 97 113 138 134 130 138 142 150 146 150 134 138 121 121 101 121 150 158 154 142 150 162 166 178 138 138 146 142 142 142 142 146 146 142 142 130 73 57 49 36 49 65 77 85 89 85 81 81 81 85 93 93 97 105 117 125 150 158 154 162 162 166 154 134 150 130 125 113 138 182 174 154 130 178 227 239 239 134 138 142 138 142 142 146 146 138 150 125 61 49 32 32 45 49 57 65 85 101 105 101 101 109 125 117 113 109 138 134 125 166 178 170 162 150 170 162 170 150 146 150 138 125 162 186 182 142 206 247 247 243 138 138 138 138 142 142 146 146 146 130 85 45 45 36 40 53 45 57 69 97 125 130 130 134 138 146 142 134 142 158 138 117 146 174 170 174 178 170 174 170 166 154 162 158 130 134 170 178 158 190 243 247 247 142 142 142 142 142 146 146 142 138 89 53 45 40 45 45 49 57 77 93 125 138 150 154 158 158 162 154 150 166 174 142 73 125 174 178 174 182 182 178 178 174 166 174 174 162 125 154 170 174 170 227 247 251 142 138 142 142 142 142 142 138 105 61 40 40 32 40 40 49 61 89 117 146 154 158 162 170 170 174 162 166 174 182 150 65 146 166 174 186 198 198 198 190 178 178 174 174 158 134 154 198 194 174 202 251 251 146 142 142 142 146 150 138 134 69 40 40 36 32 40 45 45 65 101 134 150 158 166 174 178 174 174 174 170 170 174 142 73 150 162 178 194 202 202 194 194 178 178 154 134 125 138 154 198 194 186 190 243 251 150 146 146 146 146 150 130 109 53 45 28 40 40 36 32 49 73 101 130 154 162 170 170 170 178 182 178 178 174 158 142 121 146 158 178 174 186 190 186 186 174 146 105 109 113 130 150 178 202 190 186 243 251 146 146 146 146 150 142 109 73 49 40 32 40 40 45 40 53 69 93 130 154 162 170 174 178 182 182 186 182 178 154 146 130 138 142 150 170 182 178 174 166 150 117 97 105 113 130 150 150 174 182 190 243 251 146 146 154 146 150 134 105 53 40 45 45 40 40 36 36 40 69 105 134 162 170 174 178 182 182 182 186 190 186 178 170 158 154 150 162 182 182 174 174 174 150 113 109 113 113 130 150 162 186 186 190 239 251 154 150 146 150 146 125 77 49 36 40 36 40 36 28 40 36 77 113 138 150 170 170 174 186 190 190 190 194 190 186 194 190 170 162 174 194 174 182 170 170 158 121 113 113 113 146 158 170 210 215 215 206 243 150 146 150 150 150 113 57 49 40 45 45 49 49 40 32 45 85 113 142 170 178 174 182 194 190 194 194 198 198 198 210 210 182 162 170 190 182 186 170 170 162 130 121 113 121 146 154 150 198 215 206 210 215 150 150 150 150 150 105 49 45 40 49 49 57 40 49 49 53 85 121 158 182 178 174 182 198 194 194 194 194 202 202 194 186 174 154 162 166 178 174 170 170 170 158 117 113 130 150 154 121 182 194 206 215 206 158 150 150 150 146 97 45 36 49 49 49 40 40 49 49 65 97 130 154 174 174 174 186 194 194 194 194 198 198 186 170 158 154 158 138 158 162 170 190 182 174 170 138 138 142 154 134 142 146 170 206 219 215 150 150 158 158 150 85 36 40 40 40 40 45 45 49 49 65 97 130 146 166 166 174 182 190 194 194 194 194 190 182 162 158 150 158 182 186 178 198 206 198 190 174 154 174 174 142 142 170 170 166 202 223 219 158 150 150 150 146 85 40 45 40 40 36 45 53 45 49 53 93 117 130 154 162 174 190 186 194 194 194 190 186 178 162 162 170 174 182 198 210 206 210 198 198 182 170 178 174 158 154 194 194 174 198 210 215 150 154 158 150 150 85 49 45 40 40 32 36 53 40 45 53 81 109 142 158 158 174 178 182 190 190 194 190 190 178 170 174 178 186 190 190 206 215 202 206 194 186 178 182 174 154 170 198 210 186 186 202 215 150 154 150 154 150 97 45 40 40 40 36 36 45 40 45 73 89 113 142 158 158 174 174 182 186 186 194 186 182 178 174 170 105 166 206 186 190 202 198 194 190 182 182 174 166 154 162 198 215 202 182 202 219 154 150 154 150 146 117 61 45 45 45 36 53 53 49 53 77 93 101 125 158 162 174 174 178 174 186 190 182 182 186 182 182 77 125 198 194 186 190 190 178 178 178 162 162 162 154 186 210 227 210 190 206 223 154 150 154 150 154 138 65 45 45 45 40 49 49 40 53 65 77 89 113 150 158 166 166 170 178 182 186 182 170 170 170 162 81 117 186 190 186 182 178 186 174 166 162 150 130 154 194 227 227 219 202 202 219 154 154 150 154 146 146 89 45 40 45 40 49 49 36 40 57 65 89 109 138 146 158 158 170 170 178 182 178 162 150 158 154 113 146 186 182 178 182 178 170 170 162 146 138 138 146 202 223 231 219 210 190 215 130 130 130 130 130 130 109 45 53 40 32 36 40 45 53 61 65 81 97 117 130 138 150 158 158 178 170 162 158 138 142 150 146 166 178 174 174 170 170 170 162 158 138 117 117 142 202 223 239 223 215 186 206 61 61 65 69 69 65 57 36 40 36 32 40 40 53 57 53 57 69 93 105 109 130 138 142 154 162 150 138 142 125 121 150 162 170 170 166 170 170 170 166 162 138 121 113 130 170 202 223 227 231 202 178 182 45 49 45 40 40 40 45 45 45 45 36 40 32 49 61 61 57 65 73 81 101 109 121 130 142 146 121 89 93 117 113 134 154 174 166 162 166 170 170 162 154 150 142 150 223 186 194 215 231 227 206 182 174 49 40 45 45 49 49 45 49 49 49 49 40 36 45 57 69 65 61 65 69 85 93 109 109 117 109 89 57 57 81 97 113 154 162 166 162 170 158 158 162 154 162 174 231 239 178 186 210 231 239 210 194 178 49 36 49 45 49 49 49 45 45 49 49 36 40 40 45 36 53 53 53 57 57 69 69 73 69 61 57 45 45 65 89 105 125 142 146 150 150 154 162 170 174 223 235 247 231 178 178 206 227 227 223 198 190 40 53 36 45 40 40 40 40 45 40 40 45 45 45 45 40 53 49 49 45 53 45 32 36 36 36 36 40 49 45 61 73 89 93 97 113 125 142 186 202 239 239 243 251 239 198 166 194 215 235 227 215 202 40 45 36 32 36 40 40 45 40 40 45 49 45 49 45 49 40 40 45 49 40 45 45 45 49 49 32 40 49 40 49 57 69 81 101 134 170 206 235 243 243 239 247 251 247 210 170 186 202 231 231 227 210 49 45 49 40 40 40 49 45 40 40 45 45 45 40 45 45 45 49 40 49 40 49 45 45 36 40 40 45 45 45 45 65 121 150 210 239 243 243 247 243 243 247 251 251 239 223 178 174 194 219 239 231 219 36 45 45 40 40 49 40 45 49 49 40 40 45 49 40 40 45 49 45 40 49 45 40 40 40 49 40 45 40 49 49 121 162 215 247 247 247 247 247 243 247 251 251 251 247 239 223 194 186 202 215 210 210 36 45 45 40 40 49 40 45 32 36 49 36 45 49 40 40 45 40 36 40 45 45 40 40 40 36 45 32 40 49 57 121 142 215 243 247 243 247 243 247 251 251 251 251 247 247 247 227 186 194 190 190 182 40 32 45 32 45 40 45 45 49 45 40 45 49 36 40 45 32 40 45 45 49 45 45 45 45 53 49 53 45 45 40 69 97 186 239 243 247 247 247 251 251 251 251 251 243 243 231 202 202 206 206 186 170 53 40 40 40 40 40 36 32 32 36 45 53 49 32 36 32 36 32 40 49 40 40 45 40 40 53 45 49 49 40 32 40 49 138 219 235 247 247 251 251 251 251 251 247 243 235 198 206 210 198 190 186 186 73 69 61 57 61 49 53 40 49 45 40 49 49 49 57 57 53 49 53 53 45 40 45 40 45 49 45 49 45 40 32 53 69 101 215 231 247 247 247 247 251 251 251 243 235 219 194 202 202 186 186 190 194], [53 40]));
725 ***** assert (graythresh (img, "percentile"), 142/255);
726 ***** assert (graythresh (img, "percentile", 0.5), 142/255);
727 ***** assert (graythresh (img, "moments"), 142/255);
728 ***** assert (graythresh (img, "minimum"), 93/255);
729 ***** assert (graythresh (img, "maxentropy"), 150/255);
730 ***** assert (graythresh (img, "intermodes"), 99/255);
731 ***** assert (graythresh (img, "otsu"), 115/255);
732 histo = hist (img(:), 0:255);
733 ***** assert (graythresh (histo, "otsu"), 115/255);
734 ***** assert (graythresh (img, "mean"), 0.51445615982, 0.000000001);
735 9 tests, 9 passed, 0 known failure, 0 skipped
736 [im2bw]
737 >>>>> /usr/share/octave/packages/image-2.6.1/im2bw.m
738 ***** assert(im2bw ([0 0.4 0.5 0.6 1], 0.5), logical([0 0 0 1 1]));
739 ***** assert(im2bw (uint8 ([0 100 255]), 0.5), logical([0 0 1]));
740 ***** warning <is already binary so nothing is done> bw = im2bw (logical ([0 1 0]));
741 ***** warning <is already binary so nothing is done> bw = im2bw (logical ([0 1 0]), 1);
742 ***** test
743 warning ("off", "all", "local");
744 assert (im2bw (logical ([0 1 0])), logical ([0 1 0]))
745 assert (im2bw (logical ([0 1 0]), 0), logical ([0 1 0]))
746 assert (im2bw (logical ([0 1 0]), 1), logical ([0 1 0]))
747 ***** assert (nnz (im2bw (uint8 ([0:255]), 0.9)), 26)
748 ***** test
749 img = uint8 ([0:255]);
750 s = 0;
751 for i=0:.1:1
752 s += nnz (im2bw (img, i));
753 endfor
754 assert (s, 1405)
755 ***** assert (nnz (im2bw (int16 ([-128:127]), 0.499)), 194)
756 ***** assert (nnz (im2bw (int16 ([-128:127]), 0.500)), 128)
757 ***** assert (nnz (im2bw (int16 ([-128:127]), 0.501)), 62)
758 ***** test
759 img = uint16 ([0:intmax("uint16")]);
760 s = 0;
761 for i=0:.1:1
762 s += nnz (im2bw (img, i));
763 endfor
764 assert (s, 360445)
765 ***** test
766 img = int16 ([intmin("int16"):intmax("int16")]);
767 s = 0;
768 for i=0:.1:1
769 s += nnz (im2bw (img, i));
770 endfor
771 assert (s, 360445)
772 ***** test
773 im = [((randn(10)/10)+.3) ((randn(10)/10)+.7)];
774 assert (im2bw (im, "Otsu"), im2bw (im, graythresh (im(:), "Otsu")))
775 assert (im2bw (im, "moments"), im2bw (im, graythresh (im(:), "moments")))
776 !!!!! test failed
777 horizontal dimensions mismatch (1x1 vs 199x1)
778 ***** test
779 im = [((randn(10)/10)+.3) ((randn(10)/10)+.7)];
780 im = reshape (im, [10 10 1 2]);
781 assert (im2bw (im, "Otsu"), im2bw (im, graythresh (im(:), "Otsu")))
782 assert (im2bw (im, "moments"), im2bw (im, graythresh (im(:), "moments")))
783 !!!!! test failed
784 graythresh: input must be an image or an histogram.
785 14 tests, 12 passed, 0 known failure, 0 skipped
786 [cp2tform]
787 >>>>> /usr/share/octave/packages/image-2.6.1/cp2tform.m
788 ***** function [crw, cap] = coords (npt = 1000, scale = 2, dtheta = pi/3, dx = 2, dy = -6, sig2noise = 1e32)
789 theta = (rand(npt, 1)*2-1)*2*pi;
790 R = rand(npt,1);
791 y = R.*sin(theta);
792 x = R.*cos(theta);
793 crw = [y x];
794
795 thetap = theta + dtheta;
796 Rap = R * scale;
797
798 yap = Rap.*sin(thetap);
799 yap = yap + dy;
800 yap = yap + rand (size (yap)) * norm (yap) / sig2noise;
801
802 xap = Rap.*cos(thetap);
803 xap = xap + dx;
804 xap = xap + rand (size (xap)) * norm (xap) / sig2noise;
805 cap = [yap xap];
806 ***** endfunction
807 ***** test
808 npt = 100000;
809 [crw, cap] = coords (npt);
810 ttype = 'projective';
811 T = cp2tform (crw, cap, ttype);
812 crw2 = tforminv (T, cap);
813 finalerr = norm (crw - crw2)/npt;
814 assert (finalerr < eps, "norm = %3.2e ( > eps)", finalerr)
815 ***** test
816 npt = 100000;
817 [crw, cap] = coords (npt);
818 ttype = 'affine';
819 T = cp2tform (crw, cap, ttype);
820 crw2 = tforminv (T, cap);
821 finalerr = norm (crw - crw2)/npt;
822 assert (finalerr < eps, "norm = %3.2e ( > eps)", finalerr)
823 ***** test
824 npt = 100000;
825 [crw, cap] = coords (npt);
826 ttype = 'nonreflective similarity';
827 T = cp2tform (crw, cap, ttype);
828 crw2 = tforminv (T, cap);
829 finalerr = norm (crw - crw2)/npt;
830 assert (finalerr < eps, "norm = %3.2e ( > eps)", finalerr)
831 ***** test
832 npt = 100000;
833 [crw, cap] = coords (npt);
834 cap(:,2) *= -1; % reflection around y axis
835 ttype = 'similarity';
836 T = cp2tform (crw, cap, ttype);
837 crw2 = tforminv (T, cap);
838 finalerr = norm (crw - crw2)/npt;
839 assert (finalerr < eps, "norm = %3.2e ( > eps)", finalerr)
840 ***** xtest
841 npt = 100000;
842 [crw, cap] = coords (npt);
843 ttype = 'polynomial';
844 ord = 2;
845 T = cp2tform (crw, cap, ttype, ord);
846 crw2 = tforminv (T, cap);
847 finalerr = norm (crw - crw2)/npt;
848 assert (finalerr < eps, "norm = %3.2e ( > eps)", finalerr)
849 ***** xtest
850 npt = 100000;
851 [crw, cap] = coords (npt);
852 ttype = 'polynomial';
853 ord = 3;
854 T = cp2tform (crw, cap, ttype, ord);
855 crw2 = tforminv (T, cap);
856 finalerr = norm (crw - crw2)/npt;
857 assert (finalerr < eps, "norm = %3.2e ( > eps)", finalerr)
858 ***** xtest
859 npt = 100000;
860 [crw, cap] = coords (npt);
861 ttype = 'polynomial';
862 ord = 4;
863 T = cp2tform (crw, cap, ttype, ord);
864 crw2 = tforminv (T, cap);
865 finalerr = norm (crw - crw2)/npt;
866 assert (finalerr < eps, "norm = %3.2e ( > eps)", finalerr)
867 !!!!! known failure
868 norm = 7.52e-16 ( > eps)
869 7 tests, 6 passed, 1 known failure, 0 skipped
870 [getrangefromclass]
871 >>>>> /usr/share/octave/packages/image-2.6.1/getrangefromclass.m
872 ***** shared img
873 img = ones (5);
874 ***** assert (getrangefromclass (double (img)), [0 1]);
875 ***** assert (getrangefromclass (single (img)), [0 1]);
876 ***** assert (getrangefromclass (logical (img)), [0 1]);
877 ***** assert (getrangefromclass (int8 (img)), [-128 127]);
878 ***** assert (getrangefromclass (uint8 (img)), [0 255]);
879 ***** fail ("getrangefromclass ('string')");
880 ***** fail ("getrangefromclass ({3, 4})");
881 7 tests, 7 passed, 0 known failure, 0 skipped
882 [qtgetblk]
883 >>>>> /usr/share/octave/packages/image-2.6.1/qtgetblk.m
884 ***** demo
885 [vals,r,c]=qtgetblk(eye(4),qtdecomp(eye(4)),2)
886 % Returns 2 blocks, at [1,3] and [3,1] (2*2 zeros blocks)
887 ***** shared A,S
888 A=[ 1, 4, 2, 5,54,55,61,62;
889 3, 6, 3, 1,58,53,67,65;
890 3, 6, 3, 1,58,53,67,65;
891 3, 6, 3, 1,58,53,67,65;
892 23,42,42,42,99,99,99,99;
893 27,42,42,42,99,99,99,99;
894 23,22,26,25,99,99,99,99;
895 22,22,24,22,99,99,99,99];
896 S=qtdecomp(A,10);
897 ***** test
898 [va]=qtgetblk(A,S,8);
899 [vb,r,c]=qtgetblk(A,S,8);
900 [vc,i]=qtgetblk(A,S,8);
901 assert(va, vb);
902 assert(va, vc);
903 assert(i,[]);
904 assert(r,[]);
905 assert(c,[]);
906 R=[];
907 assert(va,R);
908 ***** test
909 [va]=qtgetblk(A,S,4);
910 [vb,r,c]=qtgetblk(A,S,4);
911 [vc,i]=qtgetblk(A,S,4);
912 assert(va, vb);
913 assert(va, vc);
914 assert(i, find(full(S)==4));
915 assert(r,[1;5]);
916 assert(c,[1;5]);
917 R=zeros(4,4,2);
918 R(:,:,1)=A(1:4,1:4);
919 R(:,:,2)=A(5:8,5:8);
920 assert(va,R);
921 ***** test
922 [va]=qtgetblk(A,S,2);
923 [vb,r,c]=qtgetblk(A,S,2);
924 [vc,i]=qtgetblk(A,S,2);
925 assert(va, vb);
926 assert(va, vc);
927 assert(i, find(full(S)==2));
928 assert(r,[7;5;7;1;3;1;3]);
929 assert(c,[1;3;3;5;5;7;7]);
930 R=zeros(2,2,7);
931 R(:,:,1)=A(7:8,1:2);
932 R(:,:,2)=A(5:6,3:4);
933 R(:,:,3)=A(7:8,3:4);
934 R(:,:,4)=A(1:2,5:6);
935 R(:,:,5)=A(3:4,5:6);
936 R(:,:,6)=A(1:2,7:8);
937 R(:,:,7)=A(3:4,7:8);
938 assert(va,R);
939 3 tests, 3 passed, 0 known failure, 0 skipped
940 [bwperim]
941 >>>>> /usr/share/octave/packages/image-2.6.1/bwperim.m
942 ***** test
943 in = [ 1 1 1 1 0 1 1 0 1 1
944 1 1 0 1 1 1 1 1 1 0
945 1 1 1 0 1 1 1 1 1 1
946 1 1 1 1 0 1 1 1 0 1
947 1 1 1 0 1 1 1 1 1 0
948 1 1 1 1 1 1 0 1 0 1
949 1 1 1 1 1 1 1 1 1 0
950 1 1 1 1 1 1 1 1 1 1
951 1 1 1 1 1 1 0 0 1 1
952 1 1 1 1 0 1 0 1 1 0];
953
954 out = [1 1 1 1 0 1 1 0 1 1
955 1 1 0 1 1 0 0 1 1 0
956 1 0 1 0 1 0 0 0 1 1
957 1 0 0 1 0 1 0 1 0 1
958 1 0 1 0 1 0 1 0 1 0
959 1 0 0 1 0 1 0 1 0 1
960 1 0 0 0 0 0 1 0 1 0
961 1 0 0 0 0 0 1 1 0 1
962 1 0 0 0 1 1 0 0 1 1
963 1 1 1 1 0 1 0 1 1 0];
964 assert (bwperim (in), logical (out))
965 assert (bwperim (in, 4), logical (out))
966
967 out = [1 1 1 1 0 1 1 0 1 1
968 1 1 0 1 1 1 1 1 1 0
969 1 1 1 0 1 1 0 1 1 1
970 1 0 1 1 0 1 0 1 0 1
971 1 0 1 0 1 1 1 1 1 0
972 1 0 1 1 1 1 0 1 0 1
973 1 0 0 0 0 1 1 1 1 0
974 1 0 0 0 0 1 1 1 1 1
975 1 0 0 1 1 1 0 0 1 1
976 1 1 1 1 0 1 0 1 1 0];
977 assert (bwperim (in, 8), logical (out))
978
979 out = [1 1 1 1 0 1 1 0 1 1
980 1 0 0 0 0 1 0 0 1 0
981 1 0 0 0 0 0 0 1 0 1
982 1 0 1 0 0 0 0 0 0 1
983 1 0 0 0 0 1 0 1 0 0
984 1 0 0 0 1 0 0 0 0 1
985 1 0 0 0 0 0 0 1 0 0
986 1 0 0 0 0 1 1 0 0 1
987 1 0 0 1 0 1 0 0 1 1
988 1 1 1 1 0 1 0 1 1 0];
989 assert (bwperim (in, [1 0 0; 0 1 0; 0 0 1]), logical (out))
990 ***** test
991 in = [ 0 0 0 0 0 0 0
992 0 0 5 0 0 1 9
993 0 Inf 9 7 0 0 0
994 0 1.5 5 7 1 0 0
995 0 0.5 -1 89 i 0 0
996 0 4 10 15 1 0 0
997 0 0 0 0 0 0 0];
998 out = [0 0 0 0 0 0 0
999 0 0 1 0 0 1 1
1000 0 1 0 1 0 0 0
1001 0 1 0 0 1 0 0
1002 0 1 0 0 1 0 0
1003 0 1 1 1 1 0 0
1004 0 0 0 0 0 0 0];
1005 assert (bwperim (in), logical (out))
1006 ***** test
1007 in = reshape (magic(16), [8 8 4]) > 50;
1008 out(:,:,1) = [
1009 1 1 0 1 0 1 1 1
1010 0 1 1 1 1 1 0 1
1011 0 1 1 1 1 1 0 1
1012 1 1 0 1 1 1 1 1
1013 1 1 1 1 1 1 1 1
1014 1 1 1 0 1 0 1 1
1015 1 1 1 0 1 0 1 1
1016 1 0 1 1 1 1 1 0];
1017 out(:,:,2) = [
1018 1 1 0 1 0 1 1 1
1019 0 1 1 0 1 1 0 1
1020 0 1 0 0 0 1 0 1
1021 1 0 1 0 0 0 1 1
1022 1 0 0 1 0 1 0 1
1023 1 0 1 0 1 0 1 1
1024 1 1 1 0 1 0 1 1
1025 1 0 1 1 1 1 1 0];
1026 out(:,:,3) = [
1027 1 1 0 1 0 1 1 1
1028 0 1 1 0 1 1 0 1
1029 0 1 0 0 0 1 0 1
1030 1 0 0 0 0 0 1 1
1031 1 0 0 1 0 1 0 1
1032 1 0 1 0 1 0 1 1
1033 1 1 1 0 1 0 1 1
1034 1 0 1 1 1 1 1 0];
1035 out(:,:,4) = [
1036 1 1 0 1 0 1 1 1
1037 0 1 1 1 1 1 0 1
1038 0 1 1 1 1 1 0 1
1039 1 1 1 1 1 1 1 1
1040 1 1 1 1 1 1 1 0
1041 1 1 1 0 1 0 1 1
1042 1 1 1 0 1 0 1 1
1043 1 0 1 1 1 1 1 0];
1044 assert (bwperim (in), logical (out))
1045
1046 out(:,:,1) = [
1047 1 1 0 1 0 1 1 1
1048 0 1 1 1 1 1 0 1
1049 0 1 1 1 1 1 0 1
1050 1 1 0 1 1 1 1 1
1051 1 1 1 1 1 1 1 1
1052 1 1 1 0 1 0 1 1
1053 1 1 1 0 1 0 1 1
1054 1 0 1 1 1 1 1 0];
1055 out(:,:,2) = [
1056 1 1 0 1 0 1 1 1
1057 0 1 1 1 1 1 0 1
1058 0 1 1 0 0 1 0 1
1059 1 1 1 1 0 1 1 1
1060 1 0 1 1 1 1 1 1
1061 1 0 1 0 1 0 1 1
1062 1 1 1 0 1 0 1 1
1063 1 0 1 1 1 1 1 0];
1064 out(:,:,3) = [
1065 1 1 0 1 0 1 1 1
1066 0 1 1 1 1 1 0 1
1067 0 1 0 0 0 1 0 1
1068 1 1 0 0 0 1 1 1
1069 1 0 1 1 1 1 1 1
1070 1 0 1 0 1 0 1 1
1071 1 1 1 0 1 0 1 1
1072 1 0 1 1 1 1 1 0];
1073 out(:,:,4) = [
1074 1 1 0 1 0 1 1 1
1075 0 1 1 1 1 1 0 1
1076 0 1 1 1 1 1 0 1
1077 1 1 1 1 1 1 1 1
1078 1 1 1 1 1 1 1 0
1079 1 1 1 0 1 0 1 1
1080 1 1 1 0 1 0 1 1
1081 1 0 1 1 1 1 1 0];
1082 assert (bwperim (in, 18), logical (out))
1083 ***** error bwperim ("text")
1084 ***** error bwperim (rand (10), 5)
1085 ***** error bwperim (rand (10), "text")
1086 ***** test
1087 a = false (5);
1088 a(1:4,2:4) = true;
1089
1090 p = false (5);
1091 p(1:4,[2 4]) = true;
1092 assert (bwperim (a, [0 0 0; 1 1 1; 0 0 0]), p)
1093 ***** test
1094 a = false (8, 8, 5);
1095 a(4:5,4:5,2:4) = true;
1096 a(2:7,2:7,3) = true;
1097 assert (bwperim (a, 26), a)
1098
1099 ## It is easy to forget that is correct
1100 b = a;
1101 b(4:5, 4:5, 3) = false;
1102 assert (bwperim (a), b)
1103
1104 c = a;
1105 c(3:6,3:6,3) = false;
1106 assert (bwperim (a, 4), c)
1107 8 tests, 8 passed, 0 known failure, 0 skipped
1108 [nlfilter]
1109 >>>>> /usr/share/octave/packages/image-2.6.1/nlfilter.m
1110 ***** demo
1111 ## creates a "wide" diagonal (although it can be performed more
1112 ## efficiently with "imdilate (A, true (3))")
1113 nlfilter (eye (10), [3 3], @(x) any (x(:) > 0))
1114 ***** assert (nlfilter (eye (4), [2 3], @(x) sum (x(:))),
1115 [2 2 1 0
1116 1 2 2 1
1117 0 1 2 2
1118 0 0 1 1]);
1119 ***** assert (nlfilter (eye (4), "indexed", [2 3], @(x) sum (x(:))),
1120 [4 2 1 2
1121 3 2 2 3
1122 2 1 2 4
1123 4 3 4 5]);
1124 ***** assert (nlfilter (eye (4), "indexed", [2 3], @(x, y) sum (x(:)) == y, 2),
1125 logical ([0 1 0 1
1126 0 1 1 0
1127 1 0 1 0
1128 0 0 0 0]));
1129 ***** assert (nlfilter (uint8 (eye (4)), "indexed", [2 3], @(x) sum (x(:))),
1130 [2 2 1 0
1131 1 2 2 1
1132 0 1 2 2
1133 0 0 1 1]);
1134 ***** assert (nlfilter (int16 (eye (4)), "indexed", [2 3], @(x) sum (x(:))),
1135 [4 2 1 2
1136 3 2 2 3
1137 2 1 2 4
1138 4 3 4 5]);
1139 ***** assert (nlfilter (uint8 (eye (4)), "indexed", [2 3], @(x) int8 (sum (x(:)))),
1140 int8 ([2 2 1 0
1141 1 2 2 1
1142 0 1 2 2
1143 0 0 1 1]));
1144 ***** test
1145 a = randi (10, 20, 20, 20);
1146 ## extra dimensions on matrix only
1147 assert (nlfilter (a, [5 5], @(x) max(x(:))), imdilate (a, ones (5)))
1148 ## extra dimensions on both matrix and block
1149 assert (nlfilter (a, [5 5 5], @(x) max(x(:))), imdilate (a, ones ([5 5 5])))
1150 ## extra dimensions and padding
1151 assert (nlfilter (a, [3 7], @(x) max(x(:))), imdilate (a, ones ([3 7])))
1152 assert (nlfilter (a, [3 7 3], @(x) max(x(:))), imdilate (a, ones ([3 7 3])))
1153 ***** test
1154 a = randi (10, 15, 15, 4, 8, 3);
1155 assert (nlfilter (a, [3 4 7 5], @(x) max(x(:))),
1156 imdilate (a, ones ([3 4 7 5])))
1157 ***** test
1158 a = randi (10, 15, 15, 4, 3, 8);
1159 ord = ordfiltn (a, 3, ones ([3 7 3 1 5]));
1160 assert (nlfilter (a, [3 7 3 1 5], @(x) sort (x(:))(3)), ord)
1161 assert (nlfilter (a, [3 7 3 1 5], @(x, y) sort (x(:))(y), 3), ord)
1162 9 tests, 9 passed, 0 known failure, 0 skipped
1163 [imclose]
1164 >>>>> /usr/share/octave/packages/image-2.6.1/imclose.m
1165 ***** shared in, out
1166 in = [ 0 0 0 1 1 1 0 0 1 1
1167 0 1 0 1 1 1 0 0 0 1
1168 1 1 1 1 1 0 0 0 0 0
1169 0 1 1 1 1 0 0 0 0 0
1170 0 0 0 1 0 0 0 0 1 0
1171 0 0 0 0 0 0 0 1 1 1
1172 0 0 0 0 1 0 1 0 1 0
1173 0 0 0 1 1 1 1 1 0 0
1174 0 0 0 0 1 1 1 0 0 0
1175 0 0 0 1 1 1 0 0 0 0];
1176
1177 out = [ 1 1 1 1 1 1 1 1 1 1
1178 1 1 1 1 1 1 0 0 0 1
1179 1 1 1 1 1 0 0 0 0 1
1180 1 1 1 1 1 0 0 0 0 1
1181 0 0 0 1 1 0 0 0 1 1
1182 0 0 0 1 1 1 1 1 1 1
1183 0 0 0 1 1 1 1 1 1 1
1184 0 0 0 1 1 1 1 1 0 0
1185 0 0 0 1 1 1 1 0 0 0
1186 0 0 0 1 1 1 1 0 0 0];
1187 ***** assert (imclose (logical (in), ones (3)), logical (out));
1188
1189 out = [99 99 16 16 16 73 74 64 64 64
1190 98 88 16 16 16 73 71 64 64 64
1191 93 88 88 61 61 61 68 70 70 70
1192 93 88 88 61 61 61 68 71 71 71
1193 93 93 88 61 61 61 68 75 66 66
1194 79 79 82 90 90 49 49 49 49 66
1195 79 79 82 91 91 48 46 46 46 66
1196 79 79 82 95 97 48 46 46 46 72
1197 18 18 94 96 84 48 46 46 46 59
1198 18 18 100 96 84 50 50 50 50 59];
1199 ***** assert (imclose (magic (10), ones (3)), out);
1200 ***** assert (imclose (uint8 (magic (10)), strel ("square", 3)), uint8 (out));
1201
1202 ## using a se that will be decomposed in 2 pieces
1203 out =[ 99 99 88 74 74 74 74 70 70 70
1204 98 93 88 74 74 74 74 70 70 70
1205 93 93 88 74 74 74 74 70 70 70
1206 93 93 88 74 74 74 74 71 71 71
1207 93 93 88 75 75 75 75 75 75 75
1208 93 93 90 90 90 72 72 72 72 72
1209 93 93 91 91 91 72 72 72 72 72
1210 93 93 93 95 97 72 72 72 72 72
1211 94 94 94 96 97 72 72 72 72 72
1212 100 100 100 97 97 72 72 72 72 72];
1213 ***** assert (imclose (magic (10), ones(5)), out);
1214
1215 ## using a weird non-symmetric and even-size se
1216 out =[ 92 99 16 16 16 70 74 58 58 58
1217 98 88 60 73 16 73 69 70 64 58
1218 88 81 88 60 60 60 69 69 70 70
1219 87 87 61 68 61 60 68 69 71 69
1220 86 93 87 61 61 61 68 75 68 69
1221 23 82 89 89 90 45 68 45 68 66
1222 23 23 82 89 91 48 45 45 45 66
1223 79 23 82 95 97 46 48 46 45 72
1224 18 79 94 96 78 50 46 46 46 59
1225 18 18 100 94 94 78 50 50 46 59];
1226 ***** assert (imclose (magic (10), [1 0 0 0; 1 1 1 0; 0 1 0 1]), out);
1227 5 tests, 5 passed, 0 known failure, 0 skipped
1228 [imfill]
1229 >>>>> /usr/share/octave/packages/image-2.6.1/imfill.m
1230 ***** test
1231 I = uint8 (5.*[1 1 1; 1 0 1; 1 1 1]);
1232 bw = logical ([1 1 1; 1 0 1; 1 1 1]);
1233 I2 = uint8 (5.*ones (3));
1234 bw2 = logical (ones (3));
1235
1236 assert (imfill (int8 (I)), int8 (I2))
1237 assert (imfill (int16 (I)), int16 (I2))
1238 assert (imfill (int32 (I)), int32 (I2))
1239 assert (imfill (int64 (I)), int64 (I2))
1240 assert (imfill (uint8 (I)), uint8 (I2))
1241 assert (imfill (uint16 (I)), uint16 (I2))
1242 assert (imfill (uint32 (I)), uint32 (I2))
1243 assert (imfill (uint64 (I)), uint64 (I2))
1244 assert (imfill (single (I)), single (I2))
1245 assert (imfill (double (I)), double (I2))
1246 assert (imfill (bw, "holes"), bw2)
1247 assert (imfill (uint8 (bw)), uint8 (bw2))
1248 ***** error <must be a binary or grayscale image>
1249 imfill (i + ones (3, 3));
1250 ***** error <must be a binary or grayscale image>
1251 imfill (sparse (double (I)));
1252 ***** error
1253 imfill ();
1254 ***** error
1255 imfill (true (3), 4, "holes", 5)
1256 ***** error <LOCATIONS must be a n-by-1 or n-by-d sized index array>
1257 imfill (false (3), ones (2, 3))
1258 ***** error <LOCATIONS must be a n-by-1 or n-by-d sized index array>
1259 imfill (false (3), ones (2, 3), 4)
1260 ***** error <interactive usage is not yet supported>
1261 imfill (false (3))
1262 ***** error <interactive usage is not yet supported>
1263 imfill (false (3), 0, 4)
1264 ***** warning <ignored LOCATIONS outside of image borders>
1265 bw = logical ([1 1 1; 1 0 1; 1 1 1]);
1266 assert (imfill (bw, [5 5]), bw)
1267 assert (imfill (bw, 15), bw)
1268
1269 bw = repmat (bw, [1 1 3]);
1270 assert (imfill (bw, 30), bw)
1271 assert (imfill (bw, [2 2 5]), bw)
1272 ***** test
1273 bw = logical ([1 0 0 0 0 0 0 0
1274 1 1 1 1 1 0 0 0
1275 1 0 0 0 1 0 1 0
1276 1 0 0 0 1 1 1 0
1277 1 1 1 1 0 1 1 1
1278 1 0 0 1 1 0 1 0
1279 1 0 0 0 1 0 1 0
1280 1 0 0 0 1 1 1 0]);
1281 bw2 = logical ([1 0 0 0 0 0 0 0
1282 1 1 1 1 1 0 0 0
1283 1 1 1 1 1 0 1 0
1284 1 1 1 1 1 1 1 0
1285 1 1 1 1 1 1 1 1
1286 1 0 0 1 1 1 1 0
1287 1 0 0 0 1 1 1 0
1288 1 0 0 0 1 1 1 0]);
1289 bw3 = logical ([1 0 0 0 0 0 0 0
1290 1 1 1 1 1 0 0 0
1291 1 1 1 1 1 0 1 0
1292 1 1 1 1 1 1 1 0
1293 1 1 1 1 0 1 1 1
1294 1 0 0 1 1 0 1 0
1295 1 0 0 0 1 0 1 0
1296 1 0 0 0 1 1 1 0]);
1297 assert (imfill (bw, "holes"), bw2)
1298 assert (imfill (bw, 8, "holes"), bw2)
1299 assert (imfill (bw, 4, "holes"), bw2)
1300 assert (imfill (bw, [3 3]), bw3)
1301 assert (imfill (bw, 19), bw3)
1302 assert (imfill (bw, [3 3], 4), bw3)
1303 assert (imfill (bw, 19, 4), bw3)
1304 assert (imfill (bw, [3 3], 8), bw2)
1305 assert (imfill (bw, 19, 8), bw2)
1306 assert (imfill (bw, [19; 20]), bw3)
1307 assert (imfill (bw, [19; 20], 4), bw3)
1308 assert (imfill (bw, [19; 20], 8), bw2)
1309 ***** warning <ignored LOCATIONS outside of image borders>
1310 bw = logical ([1 1 1 1 1 1 1
1311 1 0 0 0 0 0 1
1312 1 0 1 1 1 0 1
1313 1 0 1 0 1 0 1
1314 1 0 1 1 1 0 1
1315 1 0 0 0 0 0 1
1316 1 1 1 1 1 1 1]);
1317 bw44 = logical ([1 1 1 1 1 1 1
1318 1 0 0 0 0 0 1
1319 1 0 1 1 1 0 1
1320 1 0 1 1 1 0 1
1321 1 0 1 1 1 0 1
1322 1 0 0 0 0 0 1
1323 1 1 1 1 1 1 1]);
1324 bw9 = logical ([1 1 1 1 1 1 1
1325 1 1 1 1 1 1 1
1326 1 1 1 1 1 1 1
1327 1 1 1 0 1 1 1
1328 1 1 1 1 1 1 1
1329 1 1 1 1 1 1 1
1330 1 1 1 1 1 1 1]);
1331 assert (imfill (bw, "holes"), logical (ones (7)))
1332 assert (imfill (bw, [4 4]), bw44)
1333 assert (imfill (bw, 9), bw9)
1334 assert (imfill (bw, [4 4; 10 10]), bw44)
1335 ***** test
1336 bw = logical ([1 1 0 1 1]);
1337 assert (imfill (bw, "holes"), bw)
1338 bw = logical([1 1 0 1 1; 1 1 1 1 1]);
1339 assert (imfill (bw, "holes"), bw)
1340 ***** test
1341 I = zeros (5);
1342 I(:, [2 4]) = 1;
1343 I2_expected = [0 1 1 1 0
1344 0 1 1 1 0
1345 0 1 1 1 0
1346 0 1 1 1 0
1347 0 1 1 1 0];
1348 I2 = imfill (I, [0 0 0; 1 1 1; 0 0 0], "holes");
1349 assert (I2, I2_expected)
1350 ***** test
1351 I = zeros (5);
1352 I(:, [2 4]) = 1;
1353 I2_expected = I;
1354 I2 = imfill (I, [0 1 0; 0 1 0; 0 1 0], "holes");
1355 assert (I2, I2_expected)
1356 ***** test
1357 I = zeros (5);
1358 I(:, [2 4]) = 1;
1359 I2_expected = inf .* ones (5);
1360 I2 = imfill (I, [0 0 0; 0 1 0; 0 0 0], "holes");
1361 assert (I2, I2_expected)
1362 ***** test
1363 I = false (5);
1364 I(:, [2 4]) = true;
1365 I2_expected = true (5);
1366 I2 = imfill (I, [0 0 0; 0 1 0; 0 0 0], "holes");
1367 assert (I2, I2_expected)
1368 ***** test
1369 I = uint8 ([10 20 80 85 20
1370 15 90 03 25 88
1371 05 85 02 50 83
1372 90 04 03 80 80
1373 10 81 83 85 30]);
1374 I2 = uint8 ([10 20 80 85 20
1375 15 90 80 80 88
1376 05 85 80 80 83
1377 90 80 80 80 80
1378 10 81 83 85 30]);
1379 I3 = uint8 ([10 20 80 85 20
1380 15 90 05 25 88
1381 05 85 05 50 83
1382 90 05 05 80 80
1383 10 81 83 85 30]);
1384 assert (imfill (I), I2)
1385 assert (imfill (I, 4), I2)
1386 assert (imfill (I, 4, "holes"), I2)
1387 assert (imfill (I, 8), I3)
1388 assert (imfill (I, "holes"), I2)
1389 ***** test
1390 v_line = [0 1 0; 0 1 0; 0 1 0];
1391 h_line = [0 0 0; 1 1 1; 0 0 0];
1392 im = [0 1 0 0 1 0];
1393
1394 assert (imfill (im, h_line, "holes"), [0 1 1 1 1 0])
1395 assert (imfill (im, v_line, "holes"), [0 1 0 0 1 0])
1396 assert (imfill (im', h_line, "holes"), [0 1 0 0 1 0]')
1397 assert (imfill (im', v_line, "holes"), [0 1 1 1 1 0]')
1398
1399 im = repmat (im, [1 1 5]);
1400 assert (imfill (im, h_line, "holes"), repmat ([0 1 1 1 1 0], [1 1 5]))
1401 assert (imfill (im, v_line, "holes"), im)
1402
1403 im = permute (im, [2 1 3]);
1404 assert (imfill (im, h_line, "holes"), im)
1405 assert (imfill (im, v_line, "holes"), repmat ([0 1 1 1 1 0]', [1 1 5]))
1406 ***** test
1407 im = logical ([0 0 0 0 0 0
1408 0 1 1 1 1 0
1409 0 1 0 0 1 0
1410 0 1 1 1 1 0
1411 0 0 0 0 0 0]);
1412 fi = logical ([0 0 0 0 0 0
1413 0 1 1 1 1 0
1414 0 1 1 1 1 0
1415 0 1 1 1 1 0
1416 0 0 0 0 0 0]);
1417
1418 assert (imfill (cat (3, im, im, im), 8, 'holes'), cat (3, fi, fi, fi))
1419 assert (imfill (cat (3, im, im, im), 'holes'), cat (3, im, im, im))
1420 assert (imfill (cat (3, fi, im, fi), 'holes'), cat (3, fi, fi, fi))
1421 ***** test
1422 emp = false (5, 6);
1423 im = logical ([0 0 0 0 0 0
1424 0 1 1 1 1 0
1425 0 1 0 1 0 1
1426 0 1 1 1 1 0
1427 0 0 0 0 0 0]);
1428 fi = logical ([0 0 0 0 0 0
1429 0 1 1 1 1 0
1430 0 1 1 1 1 1
1431 0 1 1 1 1 0
1432 0 0 0 0 0 0]);
1433 fi1 = logical ([0 0 0 0 0 0
1434 0 1 1 1 1 0
1435 0 1 1 1 0 1
1436 0 1 1 1 1 0
1437 0 0 0 0 0 0]);
1438 fi2 = logical ([0 0 0 0 0 0
1439 0 1 1 1 1 0
1440 0 1 0 1 1 1
1441 0 1 1 1 1 0
1442 0 0 0 0 0 0]);
1443
1444 assert (imfill (cat (3, im, im, im), [3 3 2]), cat (3, fi1, fi1, fi1))
1445 assert (imfill (cat (3, im, im, im), [3 5 2]), cat (3, fi2, fi2, fi2))
1446 assert (imfill (cat (3, im, im, im), [3 3 2; 3 5 2]), cat (3, fi, fi, fi))
1447 assert (imfill (cat (3, emp, im, emp), [3 3 2]), true (5, 6, 3))
1448 21 tests, 21 passed, 0 known failure, 0 skipped
1449 [makelut]
1450 >>>>> /usr/share/octave/packages/image-2.6.1/makelut.m
1451 ***** demo
1452 makelut(inline('sum(x(:))>=3','x'), 2)
1453 % Returns '1' if one or more values
1454 % in the input matrix are 1
1455 ***** assert(prod(makelut(inline('sum(x(:))==2','x'),2)==makelut(inline('sum(x(:))==a*b*c*d','x','a','b','c','d'),2,2/(3*4*5),3,4,5)));
1456 ***** assert(prod(makelut(inline('x(1,1)==1','x'),2)==[zeros(2^3,1);ones(2^3,1)])==1);
1457 ***** assert(prod(makelut(inline('x(1,1)==1','x'),3)==[zeros(2^8,1);ones(2^8,1)])==1);
1458 ***** assert(prod(makelut(inline('x(1,1)==1','x'),4)==[zeros(2^15,1);ones(2^15,1)])==1);
1459 ***** assert(prod(makelut(inline('x(2,1)==1','x'),3)==[zeros(2^7,1);ones(2^7,1);zeros(2^7,1);ones(2^7,1)])==1);
1460 5 tests, 5 passed, 0 known failure, 0 skipped
1461 [checkerboard]
1462 >>>>> /usr/share/octave/packages/image-2.6.1/checkerboard.m
1463 ***** demo
1464 ## Simplest case, default checkerboard size:
1465 ## 8 by 8 checkerboard, with squares 10 pixel wide
1466 board = checkerboard ();
1467 imshow (board)
1468 ***** demo
1469 ## Simplest case, default checkerboard size:
1470 ## 8 by 16 checkerboard, with squares 5 pixel wide
1471 board = checkerboard (5, 4, 8);
1472 imshow (board)
1473 ***** assert (checkerboard (0), zeros (0, 0))
1474 ***** assert (checkerboard (0, 3), zeros (0, 0))
1475 ***** assert (checkerboard (0, 2, 4), zeros (0, 0))
1476 ***** assert (checkerboard (0, 2, 4, 3), zeros (0, 0, 0))
1477 ***** assert (checkerboard (0, 2, 4, 3, 2), zeros (0, 0, 0, 0))
1478 ***** assert (checkerboard (1, 4, 2, 3, 0), zeros (8, 4, 6, 0))
1479 ***** assert (checkerboard (1, 4, 0, 3, 2), zeros (8, 0, 6, 4))
1480 ***** assert (checkerboard (2, 4, 0, 3, 2), zeros (16, 0, 12, 8))
1481 ***** test
1482 out = zeros (80);
1483 i1 = ((1:20:80) .+ (0:9)')(:);
1484 i2 = ((11:20:80) .+ (0:9)')(:);
1485 out(i1, i2) = 1;
1486 out(i2, i1) = 1;
1487 i1r = ((41:20:80) .+ (0:9)')(:);
1488 i2r = ((51:20:80) .+ (0:9)')(:);
1489 out(i2, i1r) = 0.7;
1490 out(i1, i2r) = 0.7;
1491 assert (checkerboard (), out)
1492 assert (checkerboard (10, 4, 4), out)
1493 assert (checkerboard (10, [4 4]), out)
1494 assert (checkerboard (10, [4; 4]), out)
1495 ***** test
1496 out = zeros (8);
1497 out(2:2:8, 1:2:8) = 1;
1498 out(1:2:8, 2:2:8) = 1;
1499 out(1:2:8, 6:2:8) = 0.7;
1500 out(2:2:8, 5:2:8) = 0.7;
1501 assert (checkerboard (1), out)
1502 assert (checkerboard (1, 4), out)
1503 assert (checkerboard (1, 4, 4), out)
1504 assert (checkerboard (1, [4 4]), out)
1505 ***** test
1506 out = zeros (10);
1507 out(2:2:10, 1:2:10) = 1;
1508 out(1:2:10, 2:2:10) = 1;
1509 out(1:2:10, 6:2:10) = 0.7;
1510 out(2:2:10, 7:2:10) = 0.7;
1511 assert (checkerboard (1, 5), out)
1512 assert (checkerboard (1, 5, 5), out)
1513 assert (checkerboard (1, [5 5]), out)
1514 ***** test
1515 out = zeros (20);
1516 out([1:4:20 2:4:20], [3:4:20 4:4:20]) = 1;
1517 out([3:4:20 4:4:20], [1:4:20 2:4:20]) = 1;
1518 out([1:4:20 2:4:20], [11:4:20 12:4:20]) = 0.7;
1519 out([3:4:20 4:4:20], [13:4:20 14:4:20]) = 0.7;
1520 assert (checkerboard (2, 5), out)
1521 assert (checkerboard (2, 5, 5), out)
1522 assert (checkerboard (2, [5 5]), out)
1523 ***** test
1524 out = zeros (4, 4, 4);
1525 out([1 3], 1, [1 3]) = 1;
1526 out([2 4], 2, [1 3]) = 1;
1527 out([1 3], 2, [2 4]) = 1;
1528 out([2 4], 1, [2 4]) = 1;
1529 out([1 3], 3, [1 3]) = 0.7;
1530 out([2 4], 4, [1 3]) = 0.7;
1531 out([1 3], 4, [2 4]) = 0.7;
1532 out([2 4], 3, [2 4]) = 0.7;
1533 assert (checkerboard (1, [2 2 2]), out)
1534 assert (checkerboard (1, 2, 2, 2), out)
1535 ***** test
1536 out = zeros (8, 8, 8);
1537 out([1 2 5 6], [1 2], [1 2 5 6]) = 1;
1538 out([3 4 7 8], [3 4], [1 2 5 6]) = 1;
1539 out([1 2 5 6], [3 4], [3 4 7 8]) = 1;
1540 out([3 4 7 8], [1 2], [3 4 7 8]) = 1;
1541 out([1 2 5 6], [5 6], [1 2 5 6]) = 0.7;
1542 out([3 4 7 8], [7 8], [1 2 5 6]) = 0.7;
1543 out([1 2 5 6], [7 8], [3 4 7 8]) = 0.7;
1544 out([3 4 7 8], [5 6], [3 4 7 8]) = 0.7;
1545 assert (checkerboard (2, [2 2 2]), out)
1546 assert (checkerboard (2, 2, 2, 2), out)
1547 14 tests, 14 passed, 0 known failure, 0 skipped
1548 [ordfiltn]
1549 >>>>> /usr/share/octave/packages/image-2.6.1/ordfiltn.m
1550 ***** shared b, f, s
1551 b = [ 0 1 2 3
1552 1 8 12 12
1553 4 20 24 21
1554 7 22 25 18];
1555
1556 f = [ 8 12 12 12
1557 20 24 24 24
1558 22 25 25 25
1559 22 25 25 25];
1560 ***** assert (ordfiltn (b, 9, true (3)), f);
1561
1562 f = [ 1 8 12 12
1563 8 20 21 21
1564 20 24 24 24
1565 20 24 24 24];
1566 ***** assert (ordfiltn (b, 8, true (3)), f);
1567
1568 f = [ 1 2 8 12
1569 4 12 20 21
1570 8 22 22 21
1571 20 24 24 24];
1572 ***** assert (ordfiltn (b, 7, true (3), "symmetric"), f);
1573
1574 f = [ 1 8 12 12
1575 4 20 24 21
1576 7 22 25 21
1577 7 22 25 21];
1578 ***** assert (ordfiltn (b, 3, true (3, 1)), f);
1579
1580 f = [ 1 8 12 12
1581 4 20 24 18
1582 4 20 24 18
1583 4 20 24 18];
1584 ***** assert (ordfiltn (b, 3, true (4, 1)), f);
1585
1586 f = [ 4 20 24 21
1587 7 22 25 21
1588 7 22 25 21
1589 7 22 25 21];
1590 ***** assert (ordfiltn (b, 4, true (4, 1)), f);
1591
1592 s = [0 0 1
1593 0 0 1
1594 0 0 1];
1595 f = [ 2 8 12 12
1596 9 20 22 21
1597 21 25 24 24
1598 21 25 24 24];
1599 ***** assert (ordfiltn (b, 8, true (3), s), f);
1600
1601 b(:,:,2) = b(:,:,1) - 1;
1602 b(:,:,3) = b(:,:,2) - 1;
1603 f(:,:,1) = [ 1 8 11 11
1604 8 20 21 21
1605 20 24 24 24
1606 20 24 24 24];
1607 f(:,:,2) = [ 6 10 11 11
1608 18 22 22 22
1609 20 24 24 24
1610 20 24 24 24];
1611 f(:,:,3) = [ 0 7 10 10
1612 7 19 20 20
1613 19 23 23 23
1614 19 23 23 23];
1615 ***** assert (ordfiltn (b, 25, true (3, 3, 3)), f);
1616 8 tests, 8 passed, 0 known failure, 0 skipped
1617 [imregionalmax]
1618 >>>>> /usr/share/octave/packages/image-2.6.1/imregionalmax.m
1619 ***** test
1620 a = [
1621 7 3 9 3 10 3
1622 4 2 3 10 1 3
1623 1 4 6 9 4 10
1624 8 7 9 3 4 8
1625 5 9 3 3 8 9
1626 3 6 9 4 1 10];
1627
1628 a4 = [
1629 1 0 1 0 1 0
1630 0 0 0 1 0 0
1631 0 0 0 0 0 1
1632 1 0 1 0 0 0
1633 0 1 0 0 0 0
1634 0 0 1 0 0 1];
1635 assert (imregionalmax (a, 4), logical (a4))
1636 a8 = [
1637 1 0 0 0 1 0
1638 0 0 0 1 0 0
1639 0 0 0 0 0 1
1640 0 0 0 0 0 0
1641 0 0 0 0 0 0
1642 0 0 0 0 0 1];
1643 assert (imregionalmax (a, 8), logical (a8))
1644 assert (imregionalmax (a), logical (a8))
1645 1 test, 1 passed, 0 known failure, 0 skipped
1646 [imhist]
1647 >>>>> /usr/share/octave/packages/image-2.6.1/imhist.m
1648 ***** shared nn, bb, enn, ebb
1649 [nn, bb] = imhist(logical([0 1 0 0 1]));
1650 ***** assert({nn, bb}, {[3 2]', [0 1]'})
1651 [nn, bb] = imhist([0 0.2 0.4 0.9 1], 5);
1652 ***** assert({nn, bb}, {[1 1 1 0 2]', [0 0.25 0.5 0.75 1]'})
1653 [nn, bb] = imhist([-2 0 0.2 0.4 0.9 1 5], 5);
1654 ***** assert({nn, bb}, {[2 1 1 0 3]', [0 0.25 0.5 0.75 1]'})
1655 [nn, bb] = imhist(uint8([0 32 255]), 256);
1656 enn = zeros(256, 1); enn([1, 33, 256]) = 1;
1657 ebb = 0:255;
1658 ***** assert({nn, bb}, {enn, ebb'})
1659 [nn, bb] = imhist(int8([-50 0 100]), 31);
1660 enn = zeros(31, 1); enn([10, 16, 28]) = 1;
1661 ebb = -128:8.5:127;
1662 ***** assert({nn, bb}, {enn, ebb'})
1663 5 tests, 5 passed, 0 known failure, 0 skipped
1664 [applylut]
1665 >>>>> /usr/share/octave/packages/image-2.6.1/applylut.m
1666 ***** demo
1667 lut = makelut (inline ('sum (x (:)) >= 3', 'x'), 3);
1668 S = applylut (eye (5), lut);
1669 disp (S)
1670 ## Everything should be 0 despite a diagonal which doesn't reach borders.
1671 ***** assert (prod (applylut (eye (3), makelut (@(x) x(1) == 1, 2)) == eye (3)), [1 1 1]);
1672 ***** assert (prod (applylut (eye (3), makelut (@(x) x(2,2) == 1, 3)) == eye (3)), [1 1 1]);
1673 ***** assert (prod (applylut (eye (3), makelut (@(x) x(3,3) == 1, 3)) ==
1674 applylut (eye (3), makelut (@(x) x(2,2) == 1, 2))),
1675 [1 1 1]);
1676 3 tests, 3 passed, 0 known failure, 0 skipped
1677 [lab2xyz]
1678 >>>>> /usr/share/octave/packages/image-2.6.1/lab2xyz.m
1679 ***** assert (lab2xyz ([0, 0, 0]), [0 0 0], 1e-3)
1680 ***** assert (lab2xyz ([53.24, 80.09, 67.20]), [0.4125, 0.2127, 0.0193], 1e-3)
1681 ***** assert (lab2xyz ([97.14, -21.55, 94.48]), [0.7700, 0.9278, 0.1385], 1e-3)
1682 ***** assert (lab2xyz ([87.74, -86.18, 83.18]), [0.3576, 0.7152, 0.1192], 1e-3)
1683 ***** assert (lab2xyz ([91.11, -48.09, -14.13]), [0.5380, 0.7873, 1.0694], 1e-3)
1684 ***** assert (lab2xyz ([32.30, 79.19, -107.86]), [0.1804, 0.07217, 0.9502], 1e-3)
1685 ***** assert (lab2xyz ([60.32, 98.24, -60.83]), [0.5929, 0.28484, 0.9696], 1e-3)
1686 ***** assert (lab2xyz ([100, 0.00, 0.00]), [0.9505, 1.0000, 1.0888], 1e-3)
1687 ***** assert (lab2xyz ([53.39, 0.00, 0.00]), [0.2034, 0.2140, 0.2330], 1e-3)
1688 ***** assert (lab2xyz ([39.77, 64.51, 54.13]), [0.2155, 0.1111, 0.0101], 1e-3)
1689 ***** assert (lab2xyz ([25.42, 47.91, 37.91]), [0.0883, 0.0455, 0.0041], 1e-3)
1690 ***** assert (lab2xyz ([9.66, 29.68, 15.24]), [0.02094, 0.0108, 0.00098], 1e-3)
1691 ***** assert (lab2xyz ([68.11, 48.39, 22.83]), [0.5276, 0.3812, 0.2482], 1e-3)
1692 ***** assert (lab2xyz ([150 130 130]), [4.596, 2.931, 0.519], 1e-3)
1693 ***** test
1694 lab_map = rand (64, 3);
1695 lab_map(:,1) = lab_map(:,1) .* 100;
1696 lab_map(:,2) = lab_map(:,2) .* 254 - 127;
1697 lab_map(:,3) = lab_map(:,3) .* 254 - 127;
1698 assert (xyz2lab (lab2xyz (lab_map)), lab_map, 1e-5);
1699 ***** test
1700 lab_img = rand (64, 64, 3);
1701 lab_img(:,:,1) = lab_img(:,:,1) .* 100;
1702 lab_img(:,:,2) = lab_img(:,:,2) .* 254 - 127;
1703 lab_img(:,:,3) = lab_img(:,:,3) .* 254 - 127;
1704 assert (xyz2lab (lab2xyz (lab_img)), lab_img, 1e-5);
1705 ***** assert (lab2xyz (sparse ([0 0 0])), [0 0 0], 1e-3)
1706 ***** assert (lab2xyz (sparse ([100, 0.00, 0.00])), [0.9505, 1.0000, 1.0888], 1e-3)
1707 ***** assert (class (lab2xyz (single([50 50 50]))), 'single')
1708 ***** error lab2xyz ()
1709 ***** error lab2xyz (1,2)
1710 ***** error <invalid data type 'cell'> lab2xyz ({1})
1711 ***** error <Lab must be a colormap or Lab image> lab2xyz (ones (2,2))
1712 ***** test
1713 lab = rand (16, 16, 3, 5);
1714 lab(:,:,1,:) = lab(:,:,1,:) .* 100;
1715 lab(:,:,2,:) = lab(:,:,2,:) .* 254 - 127;
1716 lab(:,:,3,:) = lab(:,:,3,:) .* 254 - 127;
1717 xyz = zeros (size (lab));
1718 for i = 1:5
1719 xyz(:,:,:,i) = lab2xyz (lab(:,:,:,i));
1720 endfor
1721 assert (lab2xyz (lab), xyz)
1722 24 tests, 24 passed, 0 known failure, 0 skipped
1723 [lab2double]
1724 >>>>> /usr/share/octave/packages/image-2.6.1/lab2double.m
1725 ***** test
1726 l_max_f = 100 + (25500 / 65280);
1727 ab_max_f = 127 + (255 / 256);
1728 cm = [
1729 -Inf
1730 Inf
1731 NaN
1732 l_max_f
1733 ab_max_f
1734 -200
1735 -129
1736 -128
1737 -128+(255/65280)*(0.499999)
1738 -128+(255/65280)*(0.500001)
1739 -128+(255/65280)*(0.500002)
1740 -127
1741 -1
1742 0
1743 (100/65280)*(0.499999)
1744 (100/65280)*(0.51)
1745 (100/65280)*(0.500001)
1746 1
1747 99
1748 100
1749 101
1750 126
1751 127
1752 128
1753 254
1754 255
1755 256
1756 257];
1757 cm = repmat (cm, [1 3]);
1758 im2d = reshape (cm, [7 4 3]);
1759 imnd = permute (im2d, [1 4 3 2]);
1760
1761 cm_uint8 = uint8 ([
1762 0 0 0
1763 255 255 255
1764 255 255 255
1765 255 228 228
1766 255 255 255
1767 0 0 0
1768 0 0 0
1769 0 0 0
1770 0 0 0
1771 0 0 0
1772 0 0 0
1773 0 1 1
1774 0 127 127
1775 0 128 128
1776 0 128 128
1777 0 128 128
1778 0 128 128
1779 3 129 129
1780 252 227 227
1781 255 228 228
1782 255 229 229
1783 255 254 254
1784 255 255 255
1785 255 255 255
1786 255 255 255
1787 255 255 255
1788 255 255 255
1789 255 255 255]);
1790
1791 assert (lab2uint8 (cm), cm_uint8)
1792 im2d_uint8 = reshape (cm_uint8, [7 4 3]);
1793 assert (lab2uint8 (im2d), im2d_uint8)
1794 assert (lab2uint8 (imnd), permute (im2d_uint8, [1 4 3 2]))
1795
1796 cm_uint16 = uint16 ([
1797 0 0 0
1798 65535 65535 65535
1799 65535 65535 65535
1800 65535 58468 58468
1801 65535 65535 65535
1802 0 0 0
1803 0 0 0
1804 0 0 0
1805 0 0 0
1806 0 1 1
1807 0 1 1
1808 0 256 256
1809 0 32512 32512
1810 0 32768 32768
1811 0 32768 32768
1812 1 32768 32768
1813 1 32768 32768
1814 653 33024 33024
1815 64627 58112 58112
1816 65280 58368 58368
1817 65535 58624 58624
1818 65535 65024 65024
1819 65535 65280 65280
1820 65535 65535 65535
1821 65535 65535 65535
1822 65535 65535 65535
1823 65535 65535 65535
1824 65535 65535 65535]);
1825
1826 assert (lab2uint16 (cm), cm_uint16)
1827 im2d_uint16 = reshape (cm_uint16, [7 4 3]);
1828 assert (lab2uint16 (im2d), im2d_uint16)
1829 assert (lab2uint16 (imnd), permute (im2d_uint16, [1 4 3 2]))
1830
1831 assert (lab2single (cm), single (cm))
1832 assert (lab2single (im2d), single (im2d))
1833 assert (lab2single (imnd), single (imnd))
1834 1 test, 1 passed, 0 known failure, 0 skipped
1835 [rgb2ycbcr]
1836 >>>>> /usr/share/octave/packages/image-2.6.1/rgb2ycbcr.m
1837 ***** test
1838 in(:,:,1) = magic (5);
1839 in(:,:,2) = magic (5);
1840 in(:,:,3) = magic (5);
1841 out(:,:,1) = [31 37 17 23 29
1842 36 20 22 28 30
1843 19 21 27 33 35
1844 25 26 32 34 19
1845 25 31 37 18 24];
1846 out(:,:,2) = 128;
1847 out(:,:,3) = 128;
1848 assert (rgb2ycbcr (uint8 (in)), uint8 (out));
1849 ***** shared cbcr
1850 cbcr = 0.5019607843137255;
1851 out(1:10, 1) = linspace (16/255, 235/255, 10);
1852 out(:, [2 3]) = cbcr;
1853 assert (rgb2ycbcr (gray (10)), out, 0.00001);
1854 ***** assert (rgb2ycbcr ([1 1 1]), [0.92157 cbcr cbcr], 0.0001);
1855 2 tests, 2 passed, 0 known failure, 0 skipped
1856 [stretchlim]
1857 >>>>> /usr/share/octave/packages/image-2.6.1/stretchlim.m
1858 ***** error (stretchlim ());
1859 ***** error (stretchlim ("bad parameter"));
1860 ***** error (stretchlim (zeros (10, 10), "bad parameter"));
1861 ***** error (stretchlim (zeros (10, 10), 0.01, 2));
1862 ***** assert (stretchlim (0.01:.01:1), [0.02; 0.99])
1863 ***** assert (stretchlim (0.01:.01:1), stretchlim (0.01:.01:1, [0.01 0.99]))
1864 ***** assert (stretchlim (0.01:.01:1, 0.15), stretchlim (0.01:.01:1, [0.15 0.85]))
1865 ***** assert (stretchlim (0.01:.01:1, [0.01,0.95]), [0.02; 0.95], eps)
1866 ***** assert (stretchlim (0.01:.01:1, 0), [0.01; 1])
1867 ***** test
1868 im = rand (5);
1869 assert (stretchlim (im, 0), [min(im(:)); max(im(:))])
1870 ***** test
1871 im = rand (5, 5, 3);
1872 assert (stretchlim (im, 0),
1873 [min(im(:,:,1)(:)) min(im(:,:,2)(:)) min(im(:,:,3)(:));
1874 max(im(:,:,1)(:)) max(im(:,:,2)(:)) max(im(:,:,3)(:))])
1875 ***** test
1876 im = rand (5);
1877 assert (stretchlim (im, 0.03), [min(im(:)); max(im(:))])
1878 assert (stretchlim (im, 0.0399), [min(im(:)); max(im(:))])
1879 ***** assert (stretchlim (uint8 (1:100)), im2double (uint8 ([2; 99])))
1880 ***** assert (stretchlim (uint8 (1:100), .25), im2double (uint8 ([26; 75])))
1881 ***** assert (stretchlim (uint16 (1:1000)), im2double (uint16 ([11; 990])))
1882 ***** assert (stretchlim (int16 (-100:100)), im2double (int16 ([-98; 98])))
1883 ***** assert (stretchlim (single (0.01:.01:1)),
1884 double (single (0.01:.01:1)([2; 99])).')
1885 ***** assert (stretchlim (uint8 ([1 repmat(2, [1, 90]) 92:100]), 0.05),
1886 im2double (uint8 ([2; 95])))
1887 ***** assert (stretchlim (uint8 ([1 repmat(2, [1 4]) 6:100]), 0.05),
1888 im2double (uint8 ([6; 95])))
1889 ***** assert (stretchlim (uint8 ([1 repmat(2, [1 5]) 7:100]), 0.05),
1890 im2double (uint8 ([2; 95])))
1891 ***** assert (stretchlim (uint8 ([1 repmat(2, [1 6]) 8:100]), 0.05),
1892 im2double (uint8 ([2; 95])))
1893 ***** assert (stretchlim (uint8 ([1 repmat(2, [1 7]) 9:100]), 0.05),
1894 im2double (uint8 ([2; 95])))
1895 ***** assert (stretchlim (uint8 ([1 repmat(2, [1 8]) 10:100]), 0.05),
1896 im2double (uint8 ([2; 95])))
1897 ***** assert (stretchlim (uint8 ([1 repmat(2, [1 5]) repmat(3, [1 5]) 9:100]), 0.04),
1898 im2double (uint8 ([2; 96])))
1899 ***** assert (stretchlim (uint8 ([1 repmat(2, [1 5]) repmat(3, [1 5]) 9:100]), 0.05),
1900 im2double (uint8 ([2; 95])))
1901 ***** assert (stretchlim (uint8 ([1 repmat(2, [1 5]) repmat(3, [1 5]) 9:100]), 0.06),
1902 im2double (uint8 ([3; 94])))
1903 ***** assert (stretchlim (uint8 ([1 repmat(2, [1 5]) repmat(3, [1 5]) 9:100]), 0.07),
1904 im2double (uint8 ([3; 93])))
1905 ***** assert (stretchlim (uint8 ([1 repmat(2, [1 5]) repmat(3, [1 5]) 9:100]), 0.08),
1906 im2double (uint8 ([3; 92])))
1907 ***** test
1908 RGB = zeros (100, 1, 3, "uint16");
1909 RGB(:,:,1) = [1:1:100];
1910 RGB(:,:,2) = [2:2:200];
1911 RGB(:,:,3) = [4:4:400];
1912 assert (stretchlim (RGB) , im2double (uint16 ([2 4 8; 99 198 396])))
1913 ***** test
1914 im6c = zeros (100, 1, 6, "uint16");
1915 im6c(:,:,1) = [1:1:100];
1916 im6c(:,:,2) = [2:2:200];
1917 im6c(:,:,3) = [4:4:400];
1918 im6c(:,:,4) = [8:8:800];
1919 im6c(:,:,5) = [16:16:1600];
1920 im6c(:,:,6) = [32:32:3200];
1921 assert (stretchlim (im6c) ,
1922 im2double (uint16 ([2 4 8 16 32 64; 99 198 396 792 1584 3168])))
1923 ***** test
1924 im = [0 0 .1 .1 .1 .1 .2 .2 .2 .4 .4 .6 .6 .7 .7 .9 .9 .9 1 1];
1925
1926 assert (stretchlim (im), [0; 1])
1927
1928 ## Consider the returned lower limit in this test. A lower limit
1929 ## of 0.1 will saturate two elements (10%), while 0.2 will saturate
1930 ## 6 elements (30%). Both have the same distance to 20% but returning
1931 ## 0.1 is Matlab compatible.
1932 ## Now looking at the higher limit. A limit of .9 will saturate
1933 ## 2 elements (10%), while a limit of 0.7 will saturate 5 elements (25%).
1934 ## However, for Matlab compatibility we must return .9 even though
1935 ## 25% would be closer to 20%.
1936 ## Basically, it's not just rounded.
1937 assert (stretchlim (im, .2), [0.1; 0.9])
1938
1939 assert (stretchlim (im, .15), [0.1; 0.9])
1940 assert (stretchlim (im, .1), [0.1; 0.9])
1941 assert (stretchlim (im, .25), [0.1; 0.7])
1942
1943 ## Reorder the vector of values (real images don't have the values
1944 ## already sorted), just to be sure it all works.
1945 im([6 3 16 11 7 17 14 8 5 19 15 1 2 4 18 13 9 20 10 12]) = im;
1946 assert (stretchlim (im, .2), [0.1; 0.9])
1947 assert (stretchlim (im, .15), [0.1; 0.9])
1948 assert (stretchlim (im, .1), [0.1; 0.9])
1949 assert (stretchlim (im, .25), [0.1; 0.7])
1950 ***** assert (stretchlim (0.01:.001:1), [0.019; 0.991], eps)
1951 ***** assert (stretchlim (0.01:.001:1, [0.01,0.95]), [0.019; 0.951], eps)
1952 ***** assert (stretchlim (0.01:.001:1, 0), [0.01; 1])
1953 ***** assert (stretchlim (single (0.01:.001:1)),
1954 double (single (0.01:.001:1)([10; 982])).')
1955 ***** test
1956 assert (stretchlim ([(.05:.05:1) (2:4)], 0.2), [0.25; 0.95], eps)
1957 assert (stretchlim ([(.05:.05:1) (2:5)], 0.2), [0.25; 1])
1958 assert (stretchlim ([(.05:.05:1) (2:6)], 0.2), [0.3; 1])
1959 assert (stretchlim ([(.05:.05:1) (2:7)], 0.2), [0.3; 1])
1960 ***** test
1961 assert (stretchlim ([(-6:0) (.05:.05:1)], 0.2), [0; 0.75], eps)
1962 assert (stretchlim ([(-5:0) (.05:.05:1)], 0.2), [0; 0.75], eps)
1963 ***** test
1964 im = rand (4, 4, 2, 3, 2);
1965 rv = zeros (2, 2, 3, 2);
1966 for p = 1:2
1967 for q = 1:3
1968 for r = 1:2
1969 rv(:,p,q,r) = stretchlim (im(:,:,p,q,r), 0.25);
1970 endfor
1971 endfor