def filter(self, job): img = job.img mode = img.mode if mode != '1': return len = self.averageSize * job.resolution / 25.4 len = int(len) | 1 thrsh = int(len*len * self.threshold / 100) job.img = MeanFilter.fixedThresholdFilter(img, len, thrsh)
def filter(self, job): img = job.img mode = img.mode if mode == '1': return elif mode == 'RGB': img = img.convert('L') elif mode != 'L': raise SaneError('unexpected image mode: %s' % mode) len = self.averageSize * job.resolution / 25.4 # we need an odd number of pixels as the square length len = int(len) | 1 offs = self.averageOffset * 255.0 / 100.0 offs = int(round(offs)) img = MeanFilter.adaptiveThresholdFilter(img, len, -offs) job.img = img.convert('1')