bugGNU Octave - Bugs: bug #56950, NaN/Inf values in ind2rgb

 
 

bug #56950: NaN/Inf values in ind2rgb

Submitter:  Guillaume <gyom>
Submitted:  Wed 25 Sep 2019 11:32:43 AM UTC
   
 
Category:  Octave Function Severity:  3 - Normal
Priority:  5 - Normal Item Group:  Matlab Compatibility
Status:  None Assigned to:  None
Originator Name:  Guillaume Open/Closed:  * Open
Release:  * dev Operating System:  * Any
Fixed Release:  None Planned Release:  None
* Mandatory Fields

Add a New Comment Rich Markup
   

Mon 30 Sep 2019 09:52:19 AM UTC, comment #2: 

In my view, ind2rgb is a 'core' enough functionality that full compatibility could be obtained. I found an older bug report where I was suggesting a short fix:
https://savannah.gnu.org/bugs/?func=detailitem&item_id=41851#comment7
It fits with TMW description that "image values are clipped to the range [1, c]" and solves all the cases I came across without error or warning.

Guillaume <gyom>
Fri 27 Sep 2019 05:04:38 PM UTC, comment #1: 

Octave is generally stricter about checking its inputs than Matlab.  In this case, why would an indexed image have a NaN value?

Even if there is a use case for have a NaN value in an indexed image, it is a rare occurrence.  For most users, a NaN is an error, and for the few users for which it is not, I believe it is better for them to actively choose how they want these values to be interpreted.  This is an easy one-line piece of code as you demonstrated.  I am tempted to mark this as "Won't Fix" and have programmers choose how they want such images to be interpreted.

Rik <rik5>
Group administrator
Wed 25 Sep 2019 11:32:43 AM UTC, original submission:  

ind2rgb does not allow NaN/Inf values in the indexed image while Matlab behaves as if they were equal to the maximal index according to the size of the colormap.


>> rgb = ind2rgb ([NaN Inf 1], jet)
rgb(:,:,1) =
   0.500000000000000   0.500000000000000                   0
rgb(:,:,2) =
     0     0     0
rgb(:,:,3) =
                   0                   0   0.562500000000000


One possible fix would be to add the following before the input check:

if isfloat (x)
  x (isnan (x) | isinf (x)) = size (map, 1);
endif


Guillaume <gyom>

 

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

Attach Files:
   
   
Comment:
   

No files currently attached

 

Depends on the following items: None found

Items that depend on this one: None found

 

Carbon-Copy List
  • -email is unavailable- added by rik5 (Posted a comment)
  • -email is unavailable- added by gyom (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.

     

    Follows 1 latest change.

    Date Changed by Updated Field Previous Value => Replaced by
    2019-09-27 rik5 Item GroupUnexpected Error or Warning Matlab Compatibility

    Back to the top

    Powered by Savane 3.14-f13d.
    Corresponding source code