Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 9117673
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 17, 20262026-06-17T04:57:06+00:00 2026-06-17T04:57:06+00:00

I have Gui that show image and few buttons for B&W, mirror etc. I

  • 0

I have Gui that show image and few buttons for B&W, mirror etc.
I need to implement a undo button that call to undo function, which, obiviously, undo the last action that was made on the image.
I need to use a global variable – history=[] (empty list) to save all the actions that made on the image.
I don’t have an idea how do this, I be happy to get a direction.
part of the code:

def mirror():
    '''Flips the image like a mirror does, left to right'''
    global img
    out = Image.new('L',img.size, 'white')
    out=flip(img)
    img = out  
    display() 

def negate():
    '''Negate the image pixels'''
    global img
    out = Image.new('L',img.size, 'white')
    out=negate_pxls(img)
    img = out  
    display()
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-17T04:57:07+00:00Added an answer on June 17, 2026 at 4:57 am

    It depends on the set of functions you are applying, if they are invertible then it gets very simple.

    Start with your mirror function which actually flips along the y axis. If you want to undo that operation, simply flip along the y axis again. Negating an image works the same way. To do the negation, you know the maximum value accepted by your image type (255 for example), so you simply perform 255 – image. To revert that, you again apply 255 – image. So, in these situations, your history could simple be the functions that were applied (so you just simply call them to undo an operation).

    Now consider a rotation by 90 degrees. You cannot undo it by rotating more 90 degrees, instead you need to go for -90. With this new operation, it is clear that your history needs to be modified. You actually want to store the list of operations performed along with the inverse of the transformation (and you would display just the first information to the user).

    Let’s increment the problem a bit more. You can now rotate by an arbitrary degree, which requires the use of interpolation methods. You cannot undo it in general by rotation by simply negating the degree, the resulting image will not be the same before applying the initial rotation. It gets worse after you apply N arbitrary rotations and then try to undo them, the discrete grid doesn’t allow for such perfect undoing. There are also operations that cannot simply be undone, irrelevant of being in the discrete or continuous domain (erosion is a simple example for that). At this point you need to distinguish between invertible and non-invertible operations, which is an easy thing to do actually. The problem is then that when the user perform non-invertible operations, the easiest thing to do is saving the current image before modifying it (either in memory, or to the disk). If you have enough memory/disk available, fully saving an image is a non-issue.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a PyGTK GUI that has a gtk.Table. Pressing one button will generate
I need to implement a list of images and buttons. I have 6 images
I have a GUI application that has a ListView. It is used to show
I have a GUI that is going to do a lot of disparate tasks.
I have a GUI that is issuing commands to a web server based on
I have a GUI app that is getting to be quite slow. I want
I have a GUI tool that manages state sequences. One component is a class
I have created a GUI that will setup the pivot table. For example, I
I have a wxPython GUI application that contains 13 pairs of StaticText controls that
Suppose I have a GUI-only application that runs on Windows and I'd like to

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.