bugGNU Octave - Bugs: bug #31745, flipping images with hold on

 
 

bug #31745: flipping images with hold on

Submitter:  Ben Abbott <bpabbott>
Submitted:  Thu 02 Dec 2010 01:14:42 PM UTC
   
 
Category:  Plotting Severity:  3 - Normal
Priority:  5 - Normal Item Group:  Incorrect Result
Status:  Fixed Assigned to:  bpabbott
Originator Name:  Ben Abbott Open/Closed:  * Closed
Release:  * dev Operating System:  * Mac OS
Fixed Release:  None Planned Release:  None
* Mandatory Fields

Add a New Comment Rich Markup
   

Jump to the original submission

Wed 08 Dec 2010 01:05:28 PM UTC, comment #13: 

I've pushed the change. John has fixed the set/get problem as well.

Ben Abbott <bpabbott>
Group Member
Wed 08 Dec 2010 04:28:12 AM UTC, comment #12: 

Your newest patch appears sound.  Go ahead and commit it.  I think you can close this bug report as well.

Rik <rik5>
Group administrator
Wed 08 Dec 2010 02:43:36 AM UTC, comment #11: 

I can confirm there is a second bug involved.

Notice the set/get sequence flips the order of the children.


octave:1> x = 0:0.1:10;
octave:2> h = plot (x,sin(x),x,cos(x))
h =
  -38.362
  -39.023
octave:3> get (gca, "children")
ans =
  -39.023
  -38.362
octave:4> set (gca, "children", get (gca, "children"));
octave:5> get (gca, "children")
ans =
  -38.362
  -39.023


I'll enter a new bug report.

Ben Abbott <bpabbott>
Group Member
Wed 08 Dec 2010 02:00:48 AM UTC, comment #10: 

I looks to me like Rik's image used the gnuplot backend.

Since the changeset I proposed is consistent with the "old" behavior, I'm inclined to push the change. Any objections?

Ben Abbott <bpabbott>
Group Member
Tue 07 Dec 2010 08:09:46 PM UTC, comment #9: 

What happened to the plot on top of the images? Was this with the gnuplot backend or with FLTK?

Søren

Søren Hauberg <hauberg>
Tue 07 Dec 2010 08:06:15 PM UTC, comment #8: 

Looks like imshow should force ydir to be reversed.

I've prepared a trivial changeset (needs testing since I'm unfamiliar with the image functions). It is attached.

I've also attached "arrow_up.jpg" as well as the results I get with gnuplot 4.4.0 and fltk 1.1.10 (aqua).

With this change in place, It looks to me like a different bug/feature is responsible for the differences between Octave's and Matlab's plots.



(file #22149,

Ben Abbott <bpabbott>
Group Member
Tue 07 Dec 2010 07:56:33 PM UTC, comment #7: 

I ran your test script in Octave to produce a comparison image against Matlab.  Octave is clearly different for the last two cases (3 and 4) in which it does not reverse the y-axis.  I also went back to a revision just prior to the new code (11307:6ab93f01df07).  It correctly has all the arrows pointing up and the y-axis numbering is reversed as it is in Matlab.  See the two attached png files.



Rik <rik5>
Group administrator
Tue 07 Dec 2010 06:57:31 PM UTC, comment #6: 

I don't do as much image processing as I used to. When doing image processing the basic visualisation work-flow is essentially:

  imshow (im);
  hold on
  plot (col, row, '*');
  hold off

where (row, col) denotes the coordinates of some points of interest in the image.

Now with respect to the bug in question I am a bit unsure how things should work. I tried generating a few plots in matlab hoping that this might shed some light on the situation. I'm attaching a script and the resulting figure.

Søren



(file #22144,

Søren Hauberg <hauberg>
Fri 03 Dec 2010 08:01:37 PM UTC, comment #5: 

I would take a look at 30509.  It began with exactly the same issue, that 'imshow; hold on; plot' produced different behavior than 'plot; hold on; imshow'. 

I implemented the following in changeset 10817:d9147775da54

A) set 'ydir' to 'reverse' when using imshow
B) ignore 'hold on' when using imshow and always reverse axes
C) add some documentation on what imshow is doing since it isn't intuitive.

Part B is exactly the opposite of "prevents image() from reversing the y-axis for plots on hold."  Soren did some testing that seemed to show that Matlab doesn't even allow the 'plot; hold on; imshow' sequence.  Instead the last imshow command resets the figure.

Rik <rik5>
Group administrator
Fri 03 Dec 2010 07:18:15 PM UTC, comment #4: 

I haven't looked that the details of 30509/30033, but I think the current problem is due to ydir being changed when the axis is in a hold on state.

I tried the imshow demo. It looks correct to me.

Ben Abbott <bpabbott>
Group Member
Fri 03 Dec 2010 06:54:46 PM UTC, comment #3: 

You should ask Soren about this change (I'll add him to the CC list).  He seems to do a lot of work with images and exactly the opposite behavior was implemented for imshow.  See https://savannah.gnu.org/bugs/?30509.  Bug 30509 was, itself, a response to bug 30033.  https://savannah.gnu.org/bugs/?30033.

If there is no clarity on this issue, then I think we should just copy exactly, weird behavior for weird behavior, what Matlab does.

Rik <rik5>
Group administrator
Fri 03 Dec 2010 12:29:11 AM UTC, comment #2: 
Ben Abbott <bpabbott>
Group Member
Thu 02 Dec 2010 02:02:29 PM UTC, comment #1: 

I've attached a proposed changeset which prevents image() form reversing the y-axis for plots on hold.

(file #22090)

Ben Abbott <bpabbott>
Group Member
Thu 02 Dec 2010 01:14:42 PM UTC, original submission:  

Matlab and Octave produce the same results for


clf
imagesc (1./hilb(4))
hold on
plot (1:4, 's-')


But if the order if switched ...


clf
plot (1:4, 's-')
hold on
imagesc (1./hilb(4))
set (gca, 'children', flipud (get (gca, 'children')))


... Matlab correctly respects the existing axis limits and y-axis orientation, while Octave does not. For reference, see the hold_2_1.png plots at the link below.

http://octave.sourceforge.net/compare_plots/

Ben Abbott <bpabbott>
Group Member

 

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

Attach Files:
   
   
Comment:
   

Attached Files
file #22149:  changeset.patch added by bpabbott (866B - trivial fix for imshow.m)
file #22150:  imshow_fltk.png added by bpabbott (37KiB - image/png - trivial fix for imshow.m)
file #22151:  arrow_up.jpg added by bpabbott (2KiB - image/jpeg - trivial fix for imshow.m)
file #22152:  imshow_gnuplot.png added by bpabbott (36KiB - image/png - trivial fix for imshow.m)
file #22144:  imshow_testing.m added by hauberg (792B - text/x-objcsrc)
file #22145:  imshow_testing.png added by hauberg (22KiB - image/png)
file #22090:  changeset.patch added by bpabbott (1KiB - don't reverse y-axis if plot is on hold)

 

Depends on the following items: None found

Items that depend on this one: None found

 

Carbon-Copy List
  • -email is unavailable- added by hauberg (Updated the item)
  • -email is unavailable- added by rik5 (Posted a comment)
  • -email is unavailable- added by rik5 (changeset concerning reversing axes with images)
  • -email is unavailable- added by bpabbott (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.

     

    Follow 14 latest changes.

    Date Changed by Updated Field Previous Value => Replaced by
    2010-12-08 bpabbott StatusReady For Test Fixed
        Open/ClosedOpen Closed
    2010-12-07 bpabbott Attached File- Added changeset.patch, #22149
        Attached File- Added imshow_fltk.png, #22150
        Attached File- Added arrow_up.jpg, #22151
        Attached File- Added imshow_gnuplot.png, #22152
    2010-12-07 rik5 Attached File- Added imshow_test_octave_results.png, #22147
        Attached File- Added imshow_test_results_older.png, #22148
    2010-12-07 hauberg Attached File- Added imshow_testing.m, #22144
        Attached File- Added imshow_testing.png, #22145
    2010-12-03 rik5 Carbon-Copy- Added hauberg
    2010-12-02 bpabbott StatusNone Ready For Test
    2010-12-02 bpabbott Attached File- Added changeset.patch, #22090
        Assigned toNone bpabbott

    Back to the top

    Powered by Savane 3.13-02a9.
    Corresponding source code