How to apply LoG on 2D+T stack with op in jython

Dear all,

I would like to know how to apply a log kernel to a 2d+T Stack that means that the kernel is 2D and I want to convolve this kernel to all the image of the stack. Here is where I am for the moment with imge a ImagePlus :

converted = ops.convert().float32(imge)
log = ops.create().img(converted)

create a log kernel

logKernel=ops.create().kernelLog(2, sigma1);
log_op = ops.op(“filter.convolve”, converted, logKernel)
ops.slice(log, converted, log_op)

thank you by advance

Hi @philgi

Maybe, this relatively old plugin will be helpful, because it already implements the convolution of an image with a LoG kernel:

Thank you @ssklykov, it is a good solution but I want to do it with op and I found the solution in the post : “Perform connected components along specific dimensions”. It is not possible to do it with the log kernel so I managed to do it by applying the convolution on each slice separately and to recombine the stack afterward… Here is the code:

    stack = imp.getStack()
    stackOut = ImageStack(imp.getWidth(), imp.getHeight())
	# create a log kernel
	logKernel=ops.create().kernelLog(2, 2)
	for i in range(stack.getSize()):
		aframe = ImagePlus(stack.getSliceLabel(i+1), stack.getProcessor(i+1))
		imge = IJF.wrap(aframe)

		# Convert data to float 32
		converted = ops.convert().float32(imge)
		# convolve with log kernel
		log=ops.filter().convolve(converted, logKernel)

		clipped = ops.create().img(log, imge.firstElement())
		clip_op = ops.op("convert.clip", imge.firstElement(), log.firstElement())
		ops.convert().imageType(clipped, log, clip_op)

		imtp = IJF.wrap(clipped, stack.getSliceLabel(i+1)) 

1 Like