[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Octave-bug-tracker] [bug #55059] [octave forge] (image) Failing unit te
From: |
Hartmut |
Subject: |
[Octave-bug-tracker] [bug #55059] [octave forge] (image) Failing unit test for grayslice |
Date: |
Mon, 10 Dec 2018 16:23:07 -0500 (EST) |
User-agent: |
Mozilla/5.0 (X11; Ubuntu; Linux x86_64; rv:63.0) Gecko/20100101 Firefox/63.0 |
Follow-up Comment #15, bug #55059 (project octave):
I have changed my test scripts (from comment #9 and comment #13) to properly
use input images of all possible classes.
The result in short:
* All outputs are now Matlab COMPATIBLE (using the current grayslice from the
repository), EXCEPT for input images of class INT16 (signed integer):
im = int16([intmin('int16'):intmax('int16')]);
out = grayslice(im, [5 6]);
first1_octave = im(find(out)(1)) % currently = 5
first1_matlab = intmin('int16') + 5 % = -32763
Conclusion: It seems to me that our Octave version is currently referencing
signed integer values (like int16) to the zero value, but Matlab seems to
reference them to the intmin value (of -32768). @Carne: Do you have an idea
how to change our Octave version to fix this (i.e. the above test case)?
In the following I will (only) copy the full test scripts and their Matlab
results for completeness and future reference:
1. test script with a scalar "n" parameter:
klassen = {'uint8', 'uint16', 'int16', 'single', 'double'};
for num = 1:length(klassen)
disp('----------');
klasse = klassen{num}
if any(strcmp(klasse, {'uint8', 'int8', 'uint16', 'int16'}))
vec = [intmin(klasse): intmax(klasse)];
vec = cast(vec, klasse);
else
vec = [0:0.001:1];
vec = cast(vec, klasse);
end
min_max = [min(vec), max(vec)]
erg05 = grayslice(vec, [0.5]);
first1_ind = find(erg05);
first1_erg05 = vec(first1_ind(1))
erg5 = grayslice(vec, [5]);
first1_ind = find(erg5);
first1_erg5 = vec(first1_ind(1))
int5 = uint8(5);
ergint5 = grayslice(vec, [int5]);
first1_ind = find(ergint5);
first1_ergint5 = vec(first1_ind(1))
end
disp('-------');
disp('Bonus: (uint8 0..100)');
vec = uint8([0:100]);
erg5 = grayslice(vec, 5);
first1_ind = find(erg5);
first1_erg5 = vec(first1_ind(1))
disp('Bonus: (double 0..100)');
vec = double(vec);
erg5 = grayslice(vec, 5);
first1_ind = find(erg5);
first1_erg5 = vec(first1_ind(1))
gives the following Matlab output:
----------
klasse =
'uint8'
min_max =
1x2 uint8 row vector
0 255
first1_erg05 =
uint8
1
first1_erg5 =
uint8
51
first1_ergint5 =
uint8
51
----------
klasse =
'uint16'
min_max =
1x2 uint16 row vector
0 65535
first1_erg05 =
uint16
1
first1_erg5 =
uint16
13107
first1_ergint5 =
uint16
13107
----------
klasse =
'int16'
min_max =
1x2 int16 row vector
-32768 32767
first1_erg05 =
int16
-32767
first1_erg5 =
int16
-19661
first1_ergint5 =
int16
-19661
----------
klasse =
'single'
min_max =
1x2 single row vector
0 1
first1_erg05 =
single
0.5000
first1_erg5 =
single
0.2000
first1_ergint5 =
single
0.2000
----------
klasse =
'double'
min_max =
0 1
first1_erg05 =
0.5000
first1_erg5 =
0.2000
first1_ergint5 =
0.2000
-------
Bonus: (uint8 0..100)
first1_erg5 =
uint8
51
Bonus: (double 0..100)
first1_erg5 =
1
2. test script with a vector "v" parameter:
klassen = {'uint8', 'uint16', 'int16', 'single', 'double'};
for num = 1:length(klassen)
disp('----------');
klasse = klassen{num}
if any(strcmp(klasse, {'uint8', 'int8', 'uint16', 'int16'}))
vec = [intmin(klasse): intmax(klasse)];
vec = cast(vec, klasse);
else
vec = [0:0.001:1];
vec = cast(vec, klasse);
end
min_max = [min(vec), max(vec)]
erg0506 = grayslice(vec, [0.5 0.6]);
first1_ind = find(erg0506);
first1_erg0506 = vec(first1_ind(1))
erg56 = grayslice(vec, [5 6]);
first1_ind = find(erg56);
first1_erg56 = vec(first1_ind(1))
int56 = uint8([5 6]);
ergint56 = grayslice(vec, int56);
first1_ind = find(ergint56);
first1_ergint56 = vec(first1_ind(1))
end
disp('-------');
disp('Bonus: (uint8 0..100)');
vec = uint8([0:100]);
erg5 = grayslice(vec, [5 6]);
first1_ind = find(erg5);
first1_erg5 = vec(first1_ind(1))
disp('Bonus: (double 0..100)');
vec = double(vec);
erg5 = grayslice(vec, [5 6]);
first1_ind = find(erg5);
first1_erg5 = vec(first1_ind(1))
gives the following Matlab result:
----------
klasse =
'uint8'
min_max =
1x2 uint8 row vector
0 255
first1_erg0506 =
uint8
1
first1_erg56 =
uint8
5
first1_ergint56 =
uint8
5
----------
klasse =
'uint16'
min_max =
1x2 uint16 row vector
0 65535
first1_erg0506 =
uint16
1
first1_erg56 =
uint16
5
first1_ergint56 =
uint16
5
----------
klasse =
'int16'
min_max =
1x2 int16 row vector
-32768 32767
first1_erg0506 =
int16
-32767
first1_erg56 =
int16
-32763
first1_ergint56 =
int16
-32763
----------
klasse =
'single'
min_max =
1x2 single row vector
0 1
first1_erg0506 =
single
0.5000
first1_erg56 =
single
1
first1_ergint56 =
single
1
----------
klasse =
'double'
min_max =
0 1
first1_erg0506 =
0.5000
first1_erg56 =
1
first1_ergint56 =
1
-------
Bonus: (uint8 0..100)
first1_erg5 =
uint8
5
Bonus: (double 0..100)
first1_erg5 =
5
_______________________________________________________
Reply to this item at:
<https://savannah.gnu.org/bugs/?55059>
_______________________________________________
Message sent via Savannah
https://savannah.gnu.org/