I can't find the true approach in order to invert the result image. I tried to use inverse=True argument inside pygame.transform.threshold method but it results in errors. In other words, I need to take inverse threshold.
def threshold_image(self, image):
"""Applies a threshold to an image and returns the thresholded image
arguments
image -- the image that should be thresholded, a
pygame.surface.Surface instance
returns
thresholded -- the thresholded image, a
pygame.surface.Surface instance
"""
# surface to apply threshold to surface
thimg = pygame.surface.Surface(self.get_size(), 0, image)
# perform thresholding
th = (self.settings['threshold'], self.settings['threshold'],
self.settings['threshold'])
pygame.transform.threshold(thimg, image, self.settings['pupilcol'], th,
self.settings['nonthresholdcol'], 1)
return thimg