bugGNU Octave - Bugs: bug #56169, [octave forge] (image) images of...

 
 

bug #56169: [octave forge] (image) images of class double or single fail to convert to class uint8

Submitter:  None
Submitted:  Fri 19 Apr 2019 08:02:06 AM UTC
   
 
Category:  Octave Package Severity:  3 - Normal
Priority:  5 - Normal Item Group:  None
Status:  Invalid / Not an Octave Bug Assigned to:  None
Originator Name:  Originator Email:  -email is unavailable-
Open/Closed:  * Closed Release:  * 5.1.0
Operating System:  * Microsoft Windows Fixed Release:  None
Planned Release:  None
* Mandatory Fields

Add a New Comment Rich Markup
   

Thu 08 Aug 2019 06:06:45 PM UTC, comment #4: 

On comment #3 Hartmut wrote:

> (By the way, it should proabably read "uint8 class" here, and not "uint16". Maybe we could fix this typo on this occasion.)


Good catch. Fixed on the stable branch.

---

The original report here remains invalid. I just fixed that typo on the im2uint8 documentation.

Carnë Draug <carandraug>
Group Member
Sat 03 Aug 2019 09:06:28 PM UTC, comment #3: 

Theoretically, it would also be possible to use im2uint8 on a Lab input image, but those Lab values should then also be scaled to be in the range 0..1 if using the double data type.

The help text of im2double mentiones this (and it is Matlab compatible):


'double or single'
          Values are truncated to the interval [0 1] and then rescaled
          to the range of values of the int16 class [0 255].


(By the way, it should proabably read "uint8 class" here, and not "uint16". Maybe we could fix this typo on this occasion.)

So if you really want to tranform a Lab image (of signed values between roughly -100 and 100, as output by rgb2lab) into a uint8 datatype (with integers between 0 and 127), then you should first figure out a (meaningful) definition of what you mean by this, without loosing too much information on the way. And afterwards just do this transformation "by hand", it shouldn't be more than one addition and one multiplication. Sorry, there is no predifined function for this in Octave (nor in Matlab, I think).

Hartmut <hardy>
Sat 03 Aug 2019 06:38:14 PM UTC, comment #2: 

im2uint8 should get an RGB image, and not Lab.

Closing as invalid.

Avinoam Kalma <avinoam>
Group Member
Sat 20 Apr 2019 01:53:11 AM UTC, comment #1: 

Where was the `im` data sourced from? It's hard to reproduce this without a full example. Can you attach an example input file to this issue?

Maybe you're not supposed to call im2uint8 on LAB-space image data? I don't know that the data structures used by the image toolbox have enough metadata for the functions to know whether they're RGB or LAB-space images. So maybe it's seeing that the input is a double, assuming it's RGB, in which case the values should have been in the interval [0.0 1.0], so these LAB values which are >1 are just saturating it and pegging all the values to 1.0, which gets normalized to 255 in uint8 space.

Andrew Janke <apjanke>
Fri 19 Apr 2019 08:02:06 AM UTC, original submission:  


>> lab = rgb2lab(im);
>> im(1:10,1:10,1)

ans =

  21  21  21  21  22  23  22  18  20  23
  24  23  21  21  21  20  20  19  21  22
  23  23  22  21  21  20  20  20  21  20
  25  23  21  21  21  22  22  22  23  24
  21  21  21  21  21  22  20  22  23  24
  25  22  21  21  21  21  21  21  22  23
  23  21  21  22  22  22  23  20  20  23
  25  24  24  22  22  22  23  23  24  24
  24  24  22  22  21  21  22  20  22  24
  26  23  21  21  22  22  20  19  20  23

>> lab(1:10,1:10,1)

ans =

   34.908   32.971   32.649   31.366   32.296   32.911   31.653   30.946   31.108   31.565
   34.340   32.965   32.762   31.892   31.570   31.603   31.925   31.697   31.745   31.451
   34.525   33.343   32.674   32.483   31.513   32.514   32.784   32.784   32.428   31.811
   34.362   33.343   32.064   32.271   31.513   32.296   31.749   31.749   33.128   32.725
   34.157   33.941   32.647   32.807   31.835   31.216   32.191   31.216   32.210   33.102
   34.629   33.428   31.686   31.628   32.103   31.399   31.686   30.410   31.711   32.965
   34.954   33.460   29.527   31.314   31.595   31.274   31.016   31.208   31.589   32.533
   36.233   33.960   33.314   32.399   31.805   32.019   32.478   31.887   32.614   33.102
   36.209   34.604   33.051   31.694   32.374   31.456   31.481   31.165   31.102   31.271
   35.565   35.274   33.140   32.807   31.917   30.694   32.135   31.511   32.079   32.424

>> a = im2uint8(lab);
>> size(a)

ans =

   308   168     3

>> class(a)

ans = uint8

>> a(1:10,1:10,1)

ans =

  255  255  255  255  255  255  255  255  255  255
  255  255  255  255  255  255  255  255  255  255
  255  255  255  255  255  255  255  255  255  255
  255  255  255  255  255  255  255  255  255  255
  255  255  255  255  255  255  255  255  255  255
  255  255  255  255  255  255  255  255  255  255
  255  255  255  255  255  255  255  255  255  255
  255  255  255  255  255  255  255  255  255  255
  255  255  255  255  255  255  255  255  255  255
  255  255  255  255  255  255  255  255  255  255

>>

บบบบบบบบบบบบบบบบบบบ 翀 øᏊ貀 퀰 '￿)￿p￿é￿w￿v￿u￿t￿,￿(￿&￿￿Ž

Anonymous

 

(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 hardy (Posted a comment)
  • -email is unavailable- added by avinoam (Posted a comment)
  • -email is unavailable- added by avinoam
  • -email is unavailable- added by avinoam
  • -email is unavailable- added by apjanke (Posted a comment)
  •  

    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 6 latest changes.

    Date Changed by Updated Field Previous Value => Replaced by
    2019-08-03 avinoam StatusNone Invalid / Not an Octave Bug
        Open/ClosedOpen Closed
        Carbon-Copy- Added carandraug
        Carbon-Copy- Added hardy
    2019-04-19 mtmiller CategoryOctave Function Octave Package
        Summaryimages of class double or single fail to convert to class uint8 [octave forge] (image) images of class double or single fail to convert to class uint8

    Back to the top

    Powered by Savane 3.13-4448.
    Corresponding source code