[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Octave-bug-tracker] [bug #59242] ind2rgb/ind2gray errors with uint inpu
From: |
Niklas Wahl |
Subject: |
[Octave-bug-tracker] [bug #59242] ind2rgb/ind2gray errors with uint input containing the maximum integer value outside of colormap range |
Date: |
Fri, 9 Oct 2020 08:59:13 -0400 (EDT) |
User-agent: |
Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/85.0.4183.121 Safari/537.36 |
URL:
<https://savannah.gnu.org/bugs/?59242>
Summary: ind2rgb/ind2gray errors with uint input containing
the maximum integer value outside of colormap range
Project: GNU Octave
Submitted by: wahln
Submitted on: Fri 09 Oct 2020 12:59:11 PM UTC
Category: Octave Function
Severity: 3 - Normal
Priority: 5 - Normal
Item Group: Unexpected Error or Warning
Status: None
Assigned to: None
Originator Name:
Originator Email:
Open/Closed: Open
Release: dev
Discussion Lock: Any
Operating System: Any
_______________________________________________________
Details:
I stumbled upon some unexpected behavior / error in ind2rgb (also reproducible
with ind2gray). When you pass your indexed image as an unsigned integer array
containing the maximum value of said unsigned integer and this value is
outside of the given colormap, ind2rgb will fail when calling the map function
internally.
Code Example:
For example, calling
ind2rgb(uint8([255]),jet(64))
throws the following error:
error: map(256,_): out of bound 255 (dimensions are 255x3)
error: called from
ind2rgb at line 56 column 5
What does work, however, is the following:
ind2rgb(uint8([254]),jet(64)) %Prints the expected warning regarding colormap
range
ind2rgb(uint8([255]),jet(256)) %Works normally
Tried this with uint8 and uint16 on ubuntu 20.04 with a dev build and the 5.2
release and with the latter on Windows, too. In Matlab it seems to work
normally in all cases.
Possible source of the bug & solution:
I think this comes from the index shift performed in ind2x.m, where maxidx
doesn't increase (because its datatype is not changed and therefore it just
keeps the maximum integer value). I attached a patch for ind2x.m that fixed
the problem for me by changing the type of maxidx to double.
_______________________________________________________
File Attachments:
-------------------------------------------------------
Date: Fri 09 Oct 2020 12:59:11 PM UTC Name: patch_ind2x.txt Size: 265B By:
wahln
Patch for ind2x.m
<http://savannah.gnu.org/bugs/download.php?file_id=49949>
_______________________________________________________
Reply to this item at:
<https://savannah.gnu.org/bugs/?59242>
_______________________________________________
Message sent via Savannah
https://savannah.gnu.org/
- [Octave-bug-tracker] [bug #59242] ind2rgb/ind2gray errors with uint input containing the maximum integer value outside of colormap range,
Niklas Wahl <=
- [Octave-bug-tracker] [bug #59242] ind2rgb/ind2gray errors with uint input containing the maximum integer value outside of colormap range, Markus Mützel, 2020/10/09
- [Octave-bug-tracker] [bug #59242] ind2rgb/ind2gray errors with uint input containing the maximum integer value outside of colormap range, Niklas Wahl, 2020/10/09
- [Octave-bug-tracker] [bug #59242] ind2rgb/ind2gray errors with uint input containing the maximum integer value outside of colormap range, Markus Mützel, 2020/10/09
- [Octave-bug-tracker] [bug #59242] ind2rgb/ind2gray errors with uint input containing the maximum integer value outside of colormap range, Guillaume, 2020/10/09
- [Octave-bug-tracker] [bug #59242] ind2rgb/ind2gray errors with uint input containing the maximum integer value outside of colormap range, Markus Mützel, 2020/10/09
- [Octave-bug-tracker] [bug #59242] ind2rgb/ind2gray errors with uint input containing the maximum integer value outside of colormap range, Rik, 2020/10/09
- [Octave-bug-tracker] [bug #59242] ind2rgb/ind2gray errors with uint input containing the maximum integer value outside of colormap range, Markus Mützel, 2020/10/09
- [Octave-bug-tracker] [bug #59242] ind2rgb/ind2gray errors with uint input containing the maximum integer value outside of colormap range, Rik, 2020/10/12