Loading...
Logo
Processing Forum

reset button.

in Programming Questions  •  1 year ago  
hi all,
i have a project for my study, i make a program using processing, to make histogram of image, then equalize the histogram. when i press the button equalize, then i want to make a button that the function to reset the image, so the image have the original color value, how can i do that?
i'm try create function to save pixel value in an array. but, it still didn't work, when i press the reset button there is no chage with my image. because value that be read with reset function is value after equalize.
can you give me some solution??
thanks,

Replies(4)

Re: reset button.

1 year ago
Show your code. Then we will tell you how to fix it.

Re: reset button.

1 year ago
i have been create grayscale and reset button in setup procedure,
then i have procedure RGB2Grayscale, that working good.
then the problem is with my reset procedure,
public void Reset() { 
  for (int j = 0; j < img.height; j++) {
    for (int i = 0; i < img.width; i++) {
      color c = img.get(i, j);
      float r = red(c);
      float g = green(c);
      float b = blue(c);
      color grayscale2 = color(r, g, b);
      img.set(i, j, grayscale2);
    }
  }
}
after i click RGB2Grayscale button and the image be grayscale. then i click Reset button, then no chage with my image, maybe because Reset procedure read pixel value of image, after grayscale.
if i want to save pixel value automatically after image loaded, so when image pixel have chaged, i have the backup the original pixel value.
can i do that??

Re: reset button.

1 year ago
You should do exactly what you said at the end. Have a backup original, so you can revert to it at a later time.

You don't need to use the pixel array for this, if it concerns the whole image. Pseudocode...

Copy code
  1. PImage original, working;
  2.  
  3. void setup() {
  4.   working = loadImage(...);
  5.   original = working.get(); // backup the original, never change it!
  6. }
  7.  
  8. void reset() {
  9.   working = original.get(); // reset the working image to the original
  10. }

Re: reset button.

1 year ago
thank you very much sir.