Login  Register

calculation on 32bit pictures

Posted by RuhlAlex on Jun 26, 2009; 9:10am
URL: http://imagej.273.s1.nabble.com/calculation-on-32bit-pictures-tp3691981.html

Hi,

I have 32 Bit-images with negative values. I want to add a value to these
pixels to get them positive.

I tried to modify the MyInverter plugin (below) but didnt succeed.
What do I have to modify to calculate with floating point values?
I dont get the right values by using getpixel and putpixel.
Is this only for int-values?

------------------------------------------------------------------------
import ij.ImagePlus;
import ij.plugin.filter.PlugInFilter;
import ij.process.ImageProcessor;

/* W. Burger, M. J. Burge: "Digitale Bildverarbeitung"
* © Springer-Verlag, 2005
* www.imagingbook.com
*/

public class MyInverter_ implements PlugInFilter {

   public int setup(String arg, ImagePlus img) {
       return DOES_32;    // this plugin accepts 8-bit grayscale images
   }

   public void run(ImageProcessor ip) {
       int w = ip.getWidth();
       int h = ip.getHeight();

       for (int u = 0; u < w; u++) {
           for (int v = 0; v < h; v++) {
               int p = ip.getPixel(u,v);
              if (p<0) {ip.putPixel(u,v,(p+180));}
           }
       }
   }
          }


-----------------------------

Thanks for help,

Alex