Bug in the IJ.run("Multiply...", "value=x") function

I want to make you aware of a bug I ran into in a python script that I wrote to re-scale all my images. In the following code the multiplication commanded by the IJ.run command does not occur.

    Max = imp.getStatistics().max
    IJ.run(imp, "Divide...", "value="+str(Max))

    IJ.run(imp, "Multiply...", "value = 65535")

User Iarganda suggested to me the following code as an alternative solution, this works:

    # read processor (only works for 2D)
    ip = imp.getProcessor();
    # divide by maximum value
    ip.multiply( 1.0/Max )
    # multiply by new maximum
    ip.multiply( 65535 )

Thanks to Iarganda for the help!


Does not seem to be a bug. Just a white space issue in your "value · = · 65535" argument. Either of the following seems to work fine:

#@ImagePlus imp
from ij import IJ
IJ.run(imp, "Multiply...", "value=65535")
imp_max = imp.getStatistics().max
IJ.run(imp, "Multiply...", "value=%s" % imp_max)

Yes you are right tferr, just a stupid mistake on my part. I remember having the same problem with spacing in the dividing, don’t know why I didn’t fix it in the multiplication…