Win a copy of Rust Web Development this week in the Other Languages forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Tim Cooke
  • Campbell Ritchie
  • Ron McLeod
  • Liutauras Vilda
  • Jeanne Boyarsky
Sheriffs:
  • Junilu Lacar
  • Rob Spoor
  • Paul Clapham
Saloon Keepers:
  • Tim Holloway
  • Tim Moores
  • Jesse Silverman
  • Stephan van Hulst
  • Carey Brown
Bartenders:
  • Al Hobbs
  • Piet Souris
  • Frits Walraven

RescaleOp Class

 
Ranch Hand
Posts: 57
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
the constructor of RescaleOp is: RescaleOp(float scaleFactor float offset, null) It performs function, pixel = pixel * scaleFactor + offset, for every pixel of a image. I have two sliders to change the values of scaleFactor and offset on the GUI and the program does change the effects of the image. But I cannot change the image back to the original one. The reason is shown below:
Assume pixel = 5, scaleFactor = 2, offset = 0 as origin.
if I adjust a slider to change the value of offset to be 1.
pixel = 11 now according to the function pixel = pixel * scaleFactor + offset.
Now I want to change back to the initial image. So I adjust the slider again and set offset to be 0 again: pixel = 11 * 5 + 0 = 55, which is not the same as the initail value 5.
What sort of change can I make to my program? Is there any fuction I can perform when changing the value of scalefactor and offset?
 
Ranch Hand
Posts: 175
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
The equation you have derived itself is wrong..
It should be..
newPixelValue = originalPixelValue * scaleFactor + offset
 
Consider Paul's rocket mass heater.
reply
    Bookmark Topic Watch Topic
  • New Topic