Python PIL.ImageFilter.MaxFilter() Examples
The following are 5
code examples of PIL.ImageFilter.MaxFilter().
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example.
You may also want to check out all available functions/classes of the module
PIL.ImageFilter
, or try the search function
.
Example #1
Source File: test_image_filter.py From python3_ios with BSD 3-Clause "New" or "Revised" License | 6 votes |
def test_sanity(self): def filter(filter): for mode in ["L", "RGB", "CMYK"]: im = hopper(mode) out = im.filter(filter) self.assertEqual(out.mode, im.mode) self.assertEqual(out.size, im.size) filter(ImageFilter.BLUR) filter(ImageFilter.CONTOUR) filter(ImageFilter.DETAIL) filter(ImageFilter.EDGE_ENHANCE) filter(ImageFilter.EDGE_ENHANCE_MORE) filter(ImageFilter.EMBOSS) filter(ImageFilter.FIND_EDGES) filter(ImageFilter.SMOOTH) filter(ImageFilter.SMOOTH_MORE) filter(ImageFilter.SHARPEN) filter(ImageFilter.MaxFilter) filter(ImageFilter.MedianFilter) filter(ImageFilter.MinFilter) filter(ImageFilter.ModeFilter) filter(ImageFilter.GaussianBlur) filter(ImageFilter.GaussianBlur(5)) filter(ImageFilter.BoxBlur(5)) filter(ImageFilter.UnsharpMask) filter(ImageFilter.UnsharpMask(10)) self.assertRaises(TypeError, filter, "hello")
Example #2
Source File: test_image_filter.py From python3_ios with BSD 3-Clause "New" or "Revised" License | 6 votes |
def test_rankfilter(self): def rankfilter(mode): im = Image.new(mode, (3, 3), None) im.putdata(list(range(9))) # image is: # 0 1 2 # 3 4 5 # 6 7 8 minimum = im.filter(ImageFilter.MinFilter).getpixel((1, 1)) med = im.filter(ImageFilter.MedianFilter).getpixel((1, 1)) maximum = im.filter(ImageFilter.MaxFilter).getpixel((1, 1)) return minimum, med, maximum self.assertEqual(rankfilter("1"), (0, 4, 8)) self.assertEqual(rankfilter("L"), (0, 4, 8)) self.assertRaises(ValueError, rankfilter, "P") self.assertEqual(rankfilter("RGB"), ((0, 0, 0), (4, 0, 0), (8, 0, 0))) self.assertEqual(rankfilter("I"), (0, 4, 8)) self.assertEqual(rankfilter("F"), (0.0, 4.0, 8.0))
Example #3
Source File: fuck12306.py From fuck12306 with MIT License | 6 votes |
def pre_ocr_processing(im): im = im.convert("RGB") width, height = im.size white = im.filter(ImageFilter.BLUR).filter(ImageFilter.MaxFilter(23)) grey = im.convert('L') impix = im.load() whitepix = white.load() greypix = grey.load() for y in range(height): for x in range(width): greypix[x,y] = min(255, max(255 + impix[x,y][0] - whitepix[x,y][0], 255 + impix[x,y][1] - whitepix[x,y][1], 255 + impix[x,y][2] - whitepix[x,y][2])) new_im = grey.copy() binarize(new_im, 150) return new_im
Example #4
Source File: test_image_filters.py From pliers with BSD 3-Clause "New" or "Revised" License | 6 votes |
def test_pillow_image_filter_filter(): stim = ImageStim(join(IMAGE_DIR, 'thai_people.jpg')) with pytest.raises(ValueError): filt = PillowImageFilter() filt = PillowImageFilter('BLUR') blurred = filt.transform(stim) assert blurred is not None from PIL import ImageFilter filt2 = PillowImageFilter(ImageFilter.FIND_EDGES) edges = filt2.transform(stim) assert np.array_equal(edges.data[0, 0], [134, 85, 45]) filt3 = PillowImageFilter(ImageFilter.MinFilter(3)) min_img = filt3.transform(stim) assert np.array_equal(min_img.data[0, 0], [122, 74, 36]) filt4 = PillowImageFilter('MinFilter') min_img = filt4.transform(stim) assert np.array_equal(min_img.data[0, 0], [122, 74, 36]) filt5 = PillowImageFilter(ImageFilter.MaxFilter, size=3) med_img = filt5.transform(stim) assert np.array_equal(med_img.data[0, 0], [136, 86, 49])
Example #5
Source File: transforms.py From revolver with BSD 2-Clause "Simplified" License | 5 votes |
def __call__(self, arr): for i in range(arr.shape[0]): arr[i, ...] = np.array(Image.fromarray(arr[i, ...]).filter(ImageFilter.MaxFilter(self.fs)), dtype=arr.dtype) return arr