bugGNU Octave - Bugs: bug #63610, patch() creates incorrect color...

 
 

bug #63610: patch() creates incorrect color interpolation. Finite Element applications rely on that graphics.

Submitter:  None
Submitted:  Tue 03 Jan 2023 08:47:01 AM UTC
 
Category:  Plotting with OpenGL Severity:  3 - Normal
Priority:  5 - Normal Item Group:  Incorrect Result
Status:  Confirmed Assigned to:  None
Originator Name:  Christoph Richter Originator Email:  -email is unavailable-
Open/Closed:  * Open Release:  * dev
Operating System:  * Any Fixed Release:  None
Planned Release:  None
* Mandatory Fields

Add a New Comment (Rich Markup)
   

Comment Type & Canned Response:
       

 

Wed 04 Jan 2023 09:08:56 PM UTC, comment #1: 

Thanks for your detailed report.

I can confirm the issue. Octave currently uses glShadeModel which automatically interpolates vertex colors independent of the current colormap. In order to have better control on pixel colors we would need to switch to modern OpenGL and implement our own vertex shader ... far from a simple task.

Pantxo Diribarne <pantxo>
Project Member
Tue 03 Jan 2023 08:47:01 AM UTC, original submission:  

The command patch() does not yield the correct graphics when using interp option to interpolate the shading color of the polygon.
https://octave.sourceforge.io/octave/function/patch.html
Applications like Finite Elements vitally rely on correct color interpolation.

Expected behavior of patch(): Color interpolation following the colorbar that attends the graphics (command colorbar). The color
sequence itself is defined with colormap().

Current behavior (Octave 7.3): E. g., color interpolation appears to interpolate linearly between the colors at the vertices of the polygon.
So with vertex 1 having red color (RGB 1 0 0) and vertex 2 having blue color (RGB 0 0 1) the interpolation takes place between the two RGB
triples. This behavior disregards that an intermediate value may require green, depending on the colorbar/colormap.

The above example describes interpolation along an edge of the polygon as a vehicle. Interpolation inside the polygon yiels the same
described deviations from the expected result.

I attach an example m-file. This can be run in Octave and Matlab to see the difference. Matlab yields the expected result.
I also attach the resulting graphics as obtained with each, Octave and Matlab.

Comparing the attached images, the issue is NOT about the discrete interpolation of Matlab and the continuous interpolation of Octave.
The issue is: E. g. left, vertical edge: Matlab goes from blue via green to orange. Octave goes from blue to orange but along the path it
blends the vertex colors.

Anonymous

 

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

Attach Files:
   
   
Comment:
   

Attached Files
file #54177:  testpatch.m added by None (325B - application/vnd.wolfram.mathematica.package - The jpgs can be reproduced with the m-file.)
file #54178:  GNUOctaveBug_OctaveFigure.jpg added by None (14KiB - image/jpeg - The jpgs can be reproduced with the m-file.)
file #54179:  GNUOctaveBug_MatlabFigure.jpg added by None (17KiB - image/jpeg - The jpgs can be reproduced with the m-file.)

 

Depends on the following items: None found

Items that depend on this one: None found

 

Carbon-Copy List
  • -email is unavailable- added by pantxo (Posted a comment)
  • -email is unavailable- added by None (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 project members can vote.

     

     

     

     

    Follow 7 latest changes.

    Date Changed by Updated Field Previous Value => Replaced by
    2023-01-04 pantxo CategoryPlotting Plotting with OpenGL
        StatusNone Confirmed
        Release7.3.0 dev
        Operating SystemMicrosoft Windows Any
    2023-01-03 None Attached File- Added testpatch.m, #54177
        Attached File- Added GNUOctaveBug_OctaveFigure.jpg, #54178
        Attached File- Added GNUOctaveBug_MatlabFigure.jpg, #54179

    Back to the top

    Powered by Savane 3.10