'How to retrieve the ImagePlus Object from ImageJ ImageCalculator
i dont understand how can i use the run method of the ij.plugin ImageCalculator Class to return a ImagePlus object instead of void. I tested the script from here: https://imagej.nih.gov/ij/developer/api/ij/ij/plugin/ImageCalculator.html in my python script and got: AttributeError: 'NoneType' object has no attribute 'show'.
My script:
import os
from ij import WindowManager, IJ
from ij.plugin import ImageCalculator as ic
dir = "path to my files"
imp1 = WindowManager.getImage(dir + "bgn0.tif")
for file in os.listdir(dir):
filename = file
if filename.endswith(".tif"):
imp2 = WindowManager.getImage(filename)
imp3 = ic().run("subtract create", imp1, imp2);
imp3.show();
IJ.saveAsTiff(imp3, dir + "\subtracted\\" + filename)
I aim for using this script with ImageJ to use background subtraction on all files in a target folder. Finally i want to save the images in the "subtracted" sub folder.
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|
