43 lines
1.4 KiB
Python
Executable File
43 lines
1.4 KiB
Python
Executable File
###################################################################################################
|
|
# Demonstrate creation of an image filters and new source based on filter.
|
|
# Also demonstrate creation of image histogram and use of overlays.
|
|
###################################################################################################
|
|
|
|
|
|
import ch.psi.pshell.imaging.Filter as Filter
|
|
from ch.psi.pshell.imaging.Utils import *
|
|
from ch.psi.pshell.imaging.Overlays import *
|
|
import ch.psi.pshell.imaging.Pen as Pen
|
|
|
|
last = None
|
|
class MyFilter(Filter):
|
|
def process(self, image, data):
|
|
global last
|
|
image = grayscale(image)
|
|
i=None
|
|
if last is not None:
|
|
i = sub(image,last, False)
|
|
i = rescale(i,100.0, 0, True)
|
|
i = add(i, last, True)
|
|
i = rescale(i,10.0, 0, True)
|
|
last = image
|
|
return i
|
|
|
|
def translate2(image, minV, maxV,inPlace):
|
|
range = float(maxV - minV)
|
|
scale = (255.0 / range) if (range > 0) else 1.0
|
|
offset = -minV
|
|
return rescale(image, scale,offset, inPlace)
|
|
|
|
|
|
class MyFilter2(Filter):
|
|
def process(self, image, data):
|
|
image = grayscale(image)
|
|
image = translate(image, 100, 200, True)
|
|
#image = rescale(image, 1.0, 200.0, False)
|
|
return image
|
|
|
|
|
|
#Setting the filter to a source
|
|
img.setFilter(MyFilter2())
|