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

 
 

bug #45333: [octave forge] (image) graythresh fails if input doesn't have different values

Submitter:  Carnë Draug <carandraug>
Submitted:  Tue 16 Jun 2015 06:10:56 PM UTC
   
 
Category:  Octave Package Severity:  3 - Normal
Priority:  5 - Normal Item Group:  Inaccurate Result
Status:  Fixed Assigned to:  carandraug
Originator Name:  Open/Closed:  * Closed
Release:  * dev Operating System:  * Any
Fixed Release:  None Planned Release:  None
* Mandatory Fields

Add a New Comment Rich Markup
   

Jump to the original submission

Fri 19 Oct 2018 10:58:05 AM UTC, comment #13: 
Avinoam Kalma <avinoam>
Group Member
Tue 16 Oct 2018 07:38:18 PM UTC, comment #12: 

Please review the attached cs which handles comment #9 & comment #10

(file #45212)

Avinoam Kalma <avinoam>
Group Member
Tue 28 Nov 2017 08:20:20 PM UTC, comment #11: 

Reopening this bug, because of comment #9 and comment #10 that should be fixed.

Avinoam Kalma <avinoam>
Group Member
Tue 06 Jun 2017 08:46:26 PM UTC, comment #10: 

There is another problem with graythresh:
running the tests with Otsu in Matlab, the thresh is 114.5, and not 115, so the test should be:


%!assert (graythresh (img, "otsu"),            114.5/255);
%! histo = hist (img(:), 0:255);
%!assert (graythresh (histo, "otsu"),          114.5/255);


To get Matlab results, the "ceil" in line 235 should be removed.



Avinoam Kalma <avinoam>
Group Member
Mon 05 Jun 2017 09:10:33 PM UTC, comment #9: 

There is still a minor problem in a corner case:


>> H(1) = 100;
>> graythresh(H)
warning: division by zero
warning: called from
    graythresh>otsu at line 217 column 13
    graythresh at line 186 column 35
warning: division by zero
warning: called from
    graythresh at line 192 column 12
ans = NaN


In Matlab the answer is zero.
The problem is in the line:

  thresh{1} = double (thresh{1}) / (numel (ihist) - 1);

since numel(ihist) is 1



Avinoam Kalma <avinoam>
Group Member
Sun 23 Apr 2017 08:34:40 PM UTC, comment #8: 
Carnë Draug <carandraug>
Group Member
Sun 23 Apr 2017 06:00:22 PM UTC, comment #7: 

Another typo:

 img_max = 65535 in line 171, but img_max is not used elsewhere.

Avinoam Kalma <avinoam>
Group Member
Wed 12 Apr 2017 04:41:25 PM UTC, comment #6: 


> It seems that few semicolons have disappeared.


Ups.  I put them back now

http://hg.code.sf.net/p/octave/image/rev/382986039e12

Carnë Draug <carandraug>
Group Member
Wed 12 Apr 2017 02:13:55 PM UTC, comment #5: 


@Carnë: Thanks for the fix.
It seems that few semicolons have disappeared.

Avinoam Kalma <avinoam>
Group Member
Wed 12 Apr 2017 01:27:33 PM UTC, comment #4: 

I am not sure why you were using `!isfinite` when the problem is that `max (bcv)` returned NaN.  I used isnan which is clearer.  Also, I put the check earlier and avoided computing threshold and goodness in such case.

http://hg.code.sf.net/p/octave/image/rev/34c55ccd6dad

Carnë Draug <carandraug>
Group Member
Thu 08 Dec 2016 05:36:22 PM UTC, comment #3: 

@Carnë:

Please review the cs in comment #2

Avinoam Kalma <avinoam>
Group Member
Wed 19 Aug 2015 08:20:56 AM UTC, comment #2: 


cs attached. Please review



(file #34676)

Avinoam Kalma <avinoam>
Group Member
Wed 17 Jun 2015 05:57:42 AM UTC, comment #1: 

The correction should be something like


if (~isfinite(max(bcv)))
     thresh{1} = 0;
     thresh{2} = 0;
endif


near the end of function otsu

Avinoam Kalma <avinoam>
Group Member
Tue 16 Jun 2015 06:10:56 PM UTC, original submission:  

Example:


octave> a = repmat (0.5, 100, 100);
octave> graythresh (a)
ans = [](1x0)


For Matlab compatibility, such corner case should return a value of zero.

Carnë Draug <carandraug>
Group Member

 

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

Attach Files:
   
   
Comment:
   

Attached Files
file #45212:  graythresh.cs added by avinoam (3KiB - text/plain)
file #34676:  bug45333.cs added by avinoam (703B - text/plain)

 

Depends on the following items: None found

Items that depend on this one: None found

 

Carbon-Copy List
  • -email is unavailable- added by avinoam
  • -email is unavailable- added by avinoam (Posted a comment)
  • -email is unavailable- added by carandraug (Submitted the item)
  •  

    There are 0 votes so far. Votes easily highlight which items people would like to see resolved in priority, independently of the priority of the item set by tracker managers.

    Only group members can vote.

     

    Follow 14 latest changes.

    Date Changed by Updated Field Previous Value => Replaced by
    2018-10-19 mtmiller Carbon-CopyRemoved 80942 -
    2018-10-19 avinoam Open/ClosedOpen Closed
    2018-10-19 avinoam StatusPatch Submitted Fixed
    2018-10-16 avinoam Attached File- Added graythresh.cs, #45212
        StatusIn Progress Patch Submitted
    2018-03-20 mtmiller Summary[octave forge] (image) grayhresh fails if input doesn't have different values [octave forge] (image) graythresh fails if input doesn't have different values
    2018-03-20 mtmiller Summaryimage package: grayhresh fails if input doesn't have different values [octave forge] (image) grayhresh fails if input doesn't have different values
    2017-11-28 avinoam StatusFixed In Progress
        Open/ClosedClosed Open
    2017-04-12 carandraug StatusPatch Submitted Fixed
        Open/ClosedOpen Closed
    2017-03-06 avinoam StatusNone Patch Submitted
    2016-12-08 avinoam Carbon-Copy- Added -email is unavailable-
    2015-08-19 avinoam Attached File- Added bug45333.cs, #34676

    Back to the top

    Powered by Savane 3.13-4448.
    Corresponding source code