def scaleandfilter(infile,outfile,scalex,scaley): print ("infile is: "+infile) imp = Opener().openImage(infile) print imp print "scalex = %f; scaley = %f" % (scalex,scaley) # Rescale ip = imp.getProcessor() ip.setInterpolate(True) sp = StackProcessor(imp.getStack(),ip); sp2=sp.resize(int(round(ip.width * scalex)), int(round(ip.height *scaley))); imp.setStack(imp.getTitle(),sp2); cal = imp.getCalibration() cal.pixelWidth /= scalex cal.pixelHeight /= scaley IJ.run(imp, "8-bit","") intif=infile+".tif" outtif=infile+"-filtered.tif" print("saving input file as "+intif) f=FileSaver(imp) f.saveAsTiffStack(intif) imp.close() # anisotropic filtering anisopts="-scanrange:10 -tau:2 -nsteps:2 -lambda:0.1 -ipflag:0 -anicoeff1:1 -anicoeff2:0 -anicoeff3:0" anisopts=anisopts+" -dx:%f -dy:%f -dz:%f" % (cal.pixelWidth,cal.pixelHeight,cal.pixelDepth) if sys.version_info > (2, 4): #for testing # subprocess.check_call(["cp",intif,outtif]) subprocess.check_call(["anisofilter"]+anisopts.split(' ')+[intif,outtif]) else: os.system(" ".join(["anisofilter"]+anisopts.split(' ')+[intif,outtif])) # Hessian (tubeness) print("Opening output tif: "+outtif) imp = Opener().openImage(outtif) imp.setCalibration(cal) print("Running tubeness on tif: "+outtif) IJ.run(imp,"Tubeness", "sigma=1") IJ.run(imp, "8-bit","") # Save to PIC print("Saving as PIC: "+outfile) # IJ.saveAs("tiff","outtif") IJ.run(imp,"Biorad ...", "biorad="+outfile)