bugGNU Octave - Bugs: bug #55373, [octave forge] (image) random...

 
 

bug #55373: [octave forge] (image) random failure of unit test in imadjust.m

Submitted by:  Hartmut <hardy>
Submitted on:  Thu 03 Jan 2019 07:19:28 PM UTC  
 
Category:  Octave Forge Package Severity:  3 - Normal
Priority:  5 - Normal Item Group:  Unexpected Error or Warning
Status:  Fixed Assigned to:  None
Originator Name:  Open/Closed:  Closed
Release:  4.4.1 Operating System:  Any

Add a New Comment (Rich Markup)
   

You are not logged in

Please log in, so followups can be emailed to you.

 

Tue 29 Dec 2020 07:21:25 PM UTC, comment #5: 

Closing as fixed

Avinoam Kalma <avinoam>
Project Member
Tue 29 Dec 2020 12:26:35 PM UTC, comment #4: 

Thanks for the review, Avinoam. I have now pushed the patch from commment #2 to the image repo: http://hg.code.sf.net/p/octave/image/rev/cb67c774bd13

This issue can now be closed as FIXED.

Hartmut <hardy>
Mon 28 Dec 2020 09:09:42 PM UTC, comment #3: 

@Hartmut: Thanks for the fix. Checking imadjust with this patch, does not fail randomly as it was before.

Avinoam Kalma <avinoam>
Project Member
Sat 26 Dec 2020 09:28:41 PM UTC, comment #2: 

Attached is a PATCH file (V1) to fix this issue as explained in comment #1. Please review.

(file #50574)

Hartmut <hardy>
Wed 23 Dec 2020 09:46:24 PM UTC, comment #1: 

I have found why this BIST is randomly failing: It works with random numbers. And it compares the result of imadjust on an integer type image with the result of imadjust on the same image that has been cast do double before. But this comparison happens in the integer domain, so the result from the double image needs to be cast back into the integer domain (see code below). And during this last step it can happen that the double result is something like 120.5000000000. Depending on a "rounding error" of the size eps this can give 120 or 121. And voila: a failing test for a value difference of one.

I plan to change all the assert lines in the last BIST (this is the only BIST making trouble) in the following way. The idea is to do the comparison in the floating point domain and to allow for a rounding error of the size of "a bit more than a 0.5 integer step".

In code, my proposal to change those assert lines in the last BIST looks like follows:

in_u8 = randi ([0 255], 5, 5, 2, 3, "uint8");
in_u8_d = im2double (in_u8);
lim_u8 =  eps + 0.5/double (intmax ("uint8")); # NEW

# old assert line in last BIST:
assert (imadjust (in_u8), im2uint8 (imadjust (in_u8_d)))

# my proposal for NEW assert line in last BIST:
assert (im2double (imadjust (in_u8)), imadjust (in_u8_d), lim_u8)

Has anyone comments on this? If I do not "hear" any objections, I will prepare a patch to change all (12) assert lines in the last BIST of imadjust in this way.

Hartmut <hardy>
Thu 03 Jan 2019 07:19:28 PM UTC, original submission:  

There is a unit test in imadjust.m of the image package, that randomly fails. Observed with the current image package 2.10.0 release.

The following loop code normally produces this test failure for me (tested on Ubunt 18.04 and Windows 10 with Octave 4.4.1):

pkg load image
for num = 1:10
    disp (num)
    test imadjust
end

Here is a typical output of the failing test:

***** test
in_u8 = randi ([0 255], 5, 5, 2, 3, "uint8");
in_u16 = randi ([0 65535], 5, 5, 2, 3, "uint16");
in_i16 = randi ([-32768 32767], 5, 5, 2, 3, "int16");
in_u8_d = im2double (in_u8);
in_u16_d = im2double (in_u16);
in_i16_d = im2double (in_i16);

## default values
assert (imadjust (in_u8), im2uint8 (imadjust (in_u8_d)))
assert (imadjust (in_u16), im2uint16 (imadjust (in_u16_d)))
assert (imadjust (in_i16), im2int16 (imadjust (in_i16_d)))

## single adjustment for all planes
args = {[.3; .7], [.1; .9], [1.5]};
assert (imadjust (in_u8, args{:}), im2uint8 (imadjust (in_u8_d, args{:})))
assert (imadjust (in_u16, args{:}), im2uint16 (imadjust (in_u16_d, args{:})))
assert (imadjust (in_i16, args{:}), im2int16 (imadjust (in_i16_d, args{:})))

## single adjustment for all planes (mixed with some complement)
args = {reshape([.2 .3 .25 .1 0 .1; .9 .7 .85 .9 1 .8], [2 2 3]),
         reshape([.1 .2 .05 .9 1 .3; .9 .85 .7 .1 0 .9], [2 2 3]),
         reshape([1 .75 1 1.2 1.5 2], [1 2 3])};
assert (imadjust (in_u8, args{:}), im2uint8 (imadjust (in_u8_d, args{:})))
assert (imadjust (in_u16, args{:}), im2uint16 (imadjust (in_u16_d, args{:})))
assert (imadjust (in_i16, args{:}), im2int16 (imadjust (in_i16_d, args{:})))

## test use of [] as limit and negative
args = {[], [.95; 0], 1.25};
assert (imadjust (in_u8, args{:}), im2uint8 (imadjust (in_u8_d, args{:})))
assert (imadjust (in_u16, args{:}), im2uint16 (imadjust (in_u16_d, args{:})))
assert (imadjust (in_i16, args{:}), im2int16 (imadjust (in_i16_d, args{:})))
!!!!! test failed
ASSERT errors for:  assert (imadjust (in_u8),im2uint8 (imadjust (in_u8_d)))

  Location  |  Observed  |  Expected  |  Reason
(1,3,2,3)       102          103        Abs err 1 exceeds tol 0 by 1
shared variables   scalar structure containing the fields:

    oRGB =

    ans(:,:,1) =

       0.00000
       0.00000
       0.20000
       0.40000
       0.60000
       0.80000
       1.00000
       1.00000
       1.00000
       1.00000

    ans(:,:,2) =

       0.00000
       0.00000
       0.00000
       0.20000
       0.40000
       0.60000
       0.80000
       1.00000
       1.00000
       1.00000

    ans(:,:,3) =

       0.00000
       0.00000
       0.00000
       0.00000
       0.20000
       0.40000
       0.60000
       0.80000
       1.00000
       1.00000

Hartmut <hardy>

 

(Note: upload size limit is set to 16384 kB, after insertion of the required escape characters.)

Attach Files:
   
   
Comment:
   

Attached Files
file #50574:  imadjust_fix_tests_V1.patch added by hardy (3KiB - text/x-patch)

 

Depends on the following items: None found

Items that depend on this one: None found

 

Carbon-Copy List
  • -email is unavailable- added by avinoam (Updated the item)
  • -email is unavailable- added by hardy (Submitted the item)
  • -email is unavailable- added by hardy
  • -email is unavailable- added by hardy
  •  

    Do you think this task is very important?
    If so, you can add your encouragement to it.
    This task has 0 encouragements so far.

    Only project members can vote.

     

     

     

    Follow 6 latest changes.

    Date Changed by Updated Field Previous Value => Replaced by
    2020-12-29 avinoam StatusConfirmed => Fixed
        Open/ClosedOpen => Closed
    2020-12-26 hardy Attached File- => Added imadjust_fix_tests_V1.patch, #50574
    2019-01-03 avinoam StatusNone => Confirmed
    2019-01-03 hardy Carbon-Copy- => Added carandraug
        Carbon-Copy- => Added avinoam

    Back to the top


    Powered by Savane 3.5