bugGNU Octave - Bugs: bug #56175, "cdata" property should...

 
 

bug #56175: "cdata" property should be documented

Submitter:  None
Submitted:  Sat 20 Apr 2019 04:39:19 AM UTC
   
 
Category:  Documentation Severity:  2 - Minor
Priority:  3 - Low Item Group:  Documentation
Status:  Fixed Assigned to:  None
Originator Name:  Originator Email:  -email is unavailable-
Open/Closed:  * Closed Release:  * dev
Operating System:  * Any Fixed Release:  9.1.0
Planned Release:  9.1.0
* Mandatory Fields

Add a New Comment Rich Markup
   

Jump to the original submission

Sat 02 Mar 2024 10:45:43 PM UTC, comment #8: 

This seems resolved.  Closing bug as Fixed.

Rik <rik5>
Group administrator
Thu 29 Feb 2024 01:20:19 PM UTC, comment #7: 

Sorry, not just hard to understand but a mistake.  that should have been:

 "that map to minimum and maximum color value"

Just pushed that fix to https://hg.savannah.gnu.org/hgweb/octave/rev/030686799759

but is it sufficient? That makes it correct but maybe still not clear enough?

How about:

Color data for the image object.  Data is either stored as a 2-D matrix where each element's value determines that pixel's color
according to the current colormap, or as a 3-D array where the third dimension contains separate red, blue, and green components for each pixel.  For RGB arrays, the "cdata" values that correspond to minimum and maximum color values depend on the number type.  Floating point and logical types have minimum and maximum values of 0 and 1 while integer types have minimum and maximum values of intmin and intmax for that integer class.

Nicholas Jankowski <nrjank>
Group Member
Thu 29 Feb 2024 07:19:03 AM UTC, comment #6: 

I'm not sure I understand what is meant with the following sentence:

> For RGB arrays, the values that map to minimum to a maximum color value depend on the class of @qcode{\"cdata\"}.


Would it be possible to rephrase that to make it easier to understand for non-native speakers?

Markus Mützel <mmuetzel>
Group administrator
Thu 29 Feb 2024 06:42:36 AM UTC, comment #5: 

added a couple sentences to the image cdata description which will now read:


      case "cdata"
        s.doc = "Color data for the image object.  Data is either stored as \
a 2-D matrix where each element's value determines that pixel's color \
according to the current colormap, or as a 3-D array where the third \
dimension contains separate red, blue, and green components for each pixel.  \
For RGB arrays, the values that map to minimum to a maximum color value \
depend on the class of @qcode{\"cdata\"}.  Floating point and logical values \
range from 0 to 1 while integer value range from @code{intmin} to \
@code{intmax} for that integer class.";


pushed to stable as https://hg.savannah.gnu.org/hgweb/octave/rev/f3c6badd9dd4

closing as fixed.  issues with the color output are being addressed in the other report.

Nicholas Jankowski <nrjank>
Group Member
Wed 28 Feb 2024 10:55:33 PM UTC, comment #4: 

looking through this report, I can confirm on octave 9.0.90 and Matlab 2023b that the two programs behave differently for the second example in comment #3.  I thought maybe CData was being stored differently, but in both cases the class(H, 'CData') returns 'double'.  This is worth a separate report from the documentation request, so i created bug #65384.

We have recently gone through the graphics object property documentation, and Image / CData does now have a full description at (what will be) https://octave.org/doc/interpreter/Image-Properties.html#XREFimagecdata , BUT it doesn't call out the class dependent color behavior. I'll look at appending that in the appropriate places.

Nicholas Jankowski <nrjank>
Group Member
Mon 10 Jan 2022 12:45:46 PM UTC, comment #3: 

Potentially related, the following displays a random array in both cases in Matlab, while only in the first case with Octave - in the second case, 0 values are displayed.


figure
H = imagesc (zeros (16, 16, 3));
set (H, 'CData', rand (16));

figure
H = imagesc (zeros (16, 16, 3, 'uint8'));
set (H, 'CData', rand (16));


Guillaume <gyom>
Mon 22 Apr 2019 04:33:55 PM UTC, comment #2: 

Matlab does the same thing, i.e., it produces a yellow square for the given input.


Rik <rik5>
Group administrator
Sat 20 Apr 2019 09:09:36 AM UTC, comment #1: 

I don't know if it is properly documented somewhere in Octave's manual, but what you observe is expected, at least if your "rgb_img" is of type "double": in this case the range of useful values for rgb channels is [0 1] and thus "RGBdouble = [255 1 0]" is equivalent to "RGBdouble = [1 1 0]".

If the image was of type uint8, then 255 (intmax("uint8")) would be the saturation value and so on. Here is a script that demonstrates how color matrices are handled:


RGBdouble = zeros (4,4,3);
RGBdouble(:,:,1) = 1;
RGBdouble(:,:,2) = 1;

subplot (3,2,1)
imshow (RGBdouble)
title "Double type: R and G saturated"

subplot (3,2,2)
RGBdouble(:,:,1) = 255;
imshow (RGBdouble)

subplot (3,2,3)
RGBdouble(:,:,1) = 255;
imshow (uint8(RGBdouble))
title "Double type: R saturated"

subplot (3,2,4)
RGBdouble(:,:,1) = 1000;
imshow (uint8(RGBdouble))

subplot (3,2,5)
RGBdouble(:,:,1) = intmax ("uint16");
imshow (uint16(RGBdouble))
title "Double type: R saturated"

subplot (3,2,6)
RGBdouble(:,:,1) = 1e5;
imshow (uint16(RGBdouble))


I'll turn this report into a request for documentation, at least image's "cdata" property should be documented:
https://octave.org/doc/interpreter/Image-Properties.html#XREFimagecdata

Changing title and other items accordingly.

Pantxo Diribarne <pantxo>
Group Member
Sat 20 Apr 2019 04:39:19 AM UTC, original submission:  

The following rgb_img matrix appears as a bright yellow image block although the red band has almost 100% of the energy?


>> rgb_img

rgb_img =

ans(:,:,1) =

   255   255
   255   255

ans(:,:,2) =

   1   1
   1   1

ans(:,:,3) =

   0   0
   0   0

imshow(rgb_img)


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 mmuetzel (Posted a comment)
  • -email is unavailable- added by nrjank (Posted a comment)
  • -email is unavailable- added by gyom (Posted a comment)
  • -email is unavailable- added by rik5 (Posted a comment)
  • -email is unavailable- added by pantxo (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 20 latest changes.

    Date Changed by Updated Field Previous Value => Replaced by
    2024-03-03 nrjank Originator Email-email is unavailable-
    2024-03-02 rik5 StatusReady For Test Fixed
        Open/ClosedOpen Closed
    2024-02-29 rik5 Carbon-CopyRemoved -email is unavailable- -
    2024-02-29 nrjank StatusFixed Ready For Test
    2024-02-29 nrjank Open/ClosedClosed Open
    2024-02-29 nrjank StatusConfirmed Fixed
        Open/ClosedOpen Closed
        Fixed ReleaseNone 9.1.0
        Planned ReleaseNone 9.1.0
    2020-01-31 mtmiller CategoryPlotting Documentation
        Priority5 - Normal 3 - Low
        Release5.1.0 dev
    2019-04-22 rik5 SummaryImage &quot;cdata&quot; property should be documented "cdata" property should be documented
    2019-04-20 pantxo CategoryNone Plotting
        Severity3 - Normal 2 - Minor
        Item GroupNone Documentation
        StatusNone Confirmed
        Operating SystemMicrosoft Windows Any
        Summaryimshow doesn't show proper colours Image "cdata" property should be documented

    Back to the top

    Powered by Savane 3.13-758e.
    Corresponding source code