def apply_filter3d(imp, radiusx=5, radiusy=5, radiusz=5, filtertype='MEDIAN'): # initialize filter f3d = Filters3D() # create filter dictionary for 3d filters filterdict = {} filterdict['MEAN'] = f3d.MEAN filterdict['MIN'] = f3d.MIN filterdict['MAX'] = f3d.MAX # filterdict['MAXLOCAL'] = f3d.MAXLOCAL # did not work filterdict['MEDIAN'] = f3d.MEDIAN filterdict['VAR'] = f3d.VAR stack = imp.getStack() # get the stack within the ImagePlus newstack = f3d.filter(stack, filterdict[filtertype], radiusx, radiusy, radiusz) imp = ImagePlus('Filtered 3D', newstack) return imp
def meanIJ(cs, xysigma): # type: (CellStack, float) -> None """ Perform ImageJ mean filter 3D with same sigma along x and y axes on a CellStack (locally) """ stack = cs.getImageStack() new_stack = Filters3D.filter(stack, Filters3D.MEAN, xysigma, xysigma, xysigma * cs.scaleZ) cs.setStack(new_stack)
# 6. Further examples #################################################### # This snippet performs a filtering operation on the active image and # exemplifies how to create a generic, reusable script based on the # IJ1 API[1]. Input parameters are retrieved using @Parameters[2] # # [1] http://javadoc.imagej.net # [2] https://imagej.net/Script_Parameters from ij.plugin import Filters3D from ij import ImagePlus # Get the image stack within the ImagePlus of img stack = img.getStack() # Instantiate ij.plugin.Filters3D f3d = Filters3D() # Retrieve filtered stack newStack = f3d.filter(stack, f3d.MEDIAN, xradius, yradius, zradius) # Construct a new ImagePlus from the stack fImg = ImagePlus("Filtered_" + img.getTitle(), newStack) # Other processing could go here (...) #IJ.run(fImg, "Shen-Castan Edge Detector", "coefficient=0.50"); # Display result fImg.show()
def filter_stack_max_3d(imp, dx ,dy, dz): stack_filtered = Filters3D.filter(imp.getStack(), Filters3D.MAX, dx, dy, dz) return ImagePlus("max filtered", stack_filtered)