octave-bug-tracker
[Top][All Lists]
Advanced

[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, 28 Dec 2020 15:42:34 -0500 (EST)
User-agent: Mozilla/5.0 (X11; Ubuntu; Linux x86_64; rv:84.0) Gecko/20100101 Firefox/84.0

Follow-up Comment #16, bug #55059 (project octave):

When I understand my own (2 years old) comment #15 right, then the only
missing bit to close this issue is the output of our grayslice function when
feeding it with (signed) int16 signed integer inputs.

Regarding this missing bit, I just found the following information in the
Matlab help:

Note:
Before thresholding an image of data type int16, the grayslice function
converts the image to uint16 by adding 32,768 to each pixel. Consider this
additive offset when specifying thresholds for input images of data type
int16.

(source: https://de.mathworks.com/help/images/ref/grayslice.html)

So I suggest that we do the same in our Octave vesion of grayslice, to finally
fix this issue.

An easy way to do this would be to add the following line somewhere before the
"final" call to the "lookup" function (line 84 in our current repo version).

It turns out, we need to add this also before the creation of the v vector
from a scalar n (line 56 in current repo version), because this uses the class
if the image. So a good position would be just before this line 56:


  if isa (I, "int16")
  ## Convert int16 images to uint16, because that is what Matlab does.
    I = im2uint16 (I);
  endif

  if (isscalar (n) && n >= 1)  # currently existing code


As drawback I can only see the enlarged (double) memory consumption, but we
would improve Matlab compatibility (and then also have their memory
consumption).

When I apply the above mention code change, then
* all tests still pass (except for the one xtest)
* The very first test code in comment #15 (the one with int16 checks) finally
gives the same result as Matlab. 
* The "1. test script" from comment #15 (the one using a scalar parameter)
gives only Matlab compatible results.
* The "2. test script" from comment #15 (the one with a vector parameter) also
gives always compatible outputs.

So all looks fine to me. 

Please let me know if you see any drawbacks with the suggested code change.
Otherwise I will prepare a patch with this code change and some useful new
tests.

    _______________________________________________________

Reply to this item at:

  <https://savannah.gnu.org/bugs/?55059>

_______________________________________________
  Message sent via Savannah
  https://savannah.gnu.org/




reply via email to

[Prev in Thread] Current Thread [Next in Thread]