コード例 #1
0
def filt_median(f, nx, ny, nz = 1, kernelshape = "BLOCK"):
	"""
	Name
		filt_median - Calculate the median filtered image.
	Input
		input image
		nxk, nyk, nzk
			Size of the kernel on each dimension.
			- They have to be odd so that the center of kernal can be well defined.
			- Note: For CIRCULAR kernel, we currently only allow circle or sphere kernel, i.e., nxk and nyk must be same for 2 dimensional image and nxk, nyk and nzk must be same for 3 dimensional image.
		kernelshape
			Shape of the kernel
			- BLOCK is for block kernel (DEFAULT);
			- CIRCULAR is for circular kernel;
			- CROSS is for cross kernal;
			- Note: For 1-dimensional image, these three kernels degenerate into the same shape.
	Output
		median filtered image
	"""
	from EMAN2 import kernel_shape, filt_median_

	if kernelshape=="BLOCK":         return filt_median_(f,nx,ny,nz,kernel_shape.BLOCK)
	elif kernelshape=="CIRCULAR":    return filt_median_(f,nx,ny,nz,kernel_shape.CIRCULAR)
	elif kernelshape=="CROSS":       return filt_median_(f,nx,ny,nz,kernel_shape.CROSS)
	else: sxprint("Unknown kernel shape.")
コード例 #2
0
ファイル: filter.py プロジェクト: CVL-dev/StructuralBiology
def filt_median(f, nx, ny, nz, kernelshape = "BLOCK"):
	"""
	Name
		filt_median - Calculate the median filtered image.
	Input
		input image
		nxk, nyk, nzk
			Size of the kernel on each dimension.
			- They have to be odd so that the center of kernal can be well defined.
			- Note: For CIRCULAR kernel, we currently only allow circle or sphere kernel, i.e., nxk and nyk must be same for 2 dimensional image and nxk, nyk and nzk must be same for 3 dimensional image.
		kernelshape
			Shape of the kernel
			- BLOCK is for block kernel (DEFAULT);
			- CIRCULAR is for circular kernel;
			- CROSS is for cross kernal;
			- Note: For 1-dimensional image, these three kernels degenerate into the same shape.
	Output
		median filtered image
	"""
	from EMAN2 import kernel_shape, filt_median_

	if kernelshape=="BLOCK":
		return filt_median_(f,nx,ny,nz,kernel_shape.BLOCK)
	elif kernelshape=="CIRCULAR":
		return filt_median_(f,nx,ny,nz,kernel_shape.CIRCULAR)
	elif kernelshape=="CROSS":
		return filt_median_(f,nx,ny,nz,kernel_shape.CROSS)
	else: print "Unknown kernel shape."