|
| 1 | +function tests = test_morphoGradient |
| 2 | +% Test suite for the file morphoGradient. |
| 3 | +% |
| 4 | +% Test suite for the file morphoGradient |
| 5 | +% |
| 6 | +% Example |
| 7 | +% test_morphoGradient |
| 8 | +% |
| 9 | +% See also |
| 10 | +% morphoGradient |
| 11 | + |
| 12 | +% ------ |
| 13 | +% Author: David Legland |
| 14 | +% e-mail: david.legland@inrae.fr |
| 15 | +% Created: 2021-02-04, using Matlab 9.8.0.1323502 (R2020a) |
| 16 | +% Copyright 2021 INRAE - BIA-BIBS. |
| 17 | + |
| 18 | +tests = functiontests(localfunctions); |
| 19 | + |
| 20 | +function test_Simple(testCase) %#ok<*DEFNU> |
| 21 | +% Test call of function without argument. |
| 22 | + |
| 23 | +data = zeros([16 14], 'uint8'); |
| 24 | +data(2:4, 2:4) = 150; |
| 25 | +data(8:15, 2:4) = 150; |
| 26 | +data(8:15, 8:13) = 150; |
| 27 | +img = Image('Data', data); |
| 28 | + |
| 29 | +% apply opening making two smallest regions disappear |
| 30 | +res = morphoGradient(img, ones(3,3)); |
| 31 | + |
| 32 | +assertEqual(testCase, size(res), size(img)); |
| 33 | +assertTrue(testCase, isa(res, 'Image')); |
| 34 | +assertEqual(testCase, res.Type, img.Type); |
| 35 | + |
| 36 | +assertEqual(testCase, double(res( 3, 3)), 0); |
| 37 | +assertEqual(testCase, double(res(10, 3)), 0); |
| 38 | +assertEqual(testCase, double(res( 3, 10)), 0); |
| 39 | +assertEqual(testCase, double(res(10, 10)), 0); |
| 40 | + |
| 41 | +assertEqual(testCase, double(res( 2, 4)), 150); |
| 42 | +assertEqual(testCase, double(res( 4, 2)), 150); |
| 43 | +assertEqual(testCase, double(res(10, 4)), 150); |
| 44 | + |
0 commit comments