本文整理匯總了Python中PIL.ImageFilter.SMOOTH_MORE屬性的典型用法代碼示例。如果您正苦於以下問題:Python ImageFilter.SMOOTH_MORE屬性的具體用法?Python ImageFilter.SMOOTH_MORE怎麽用?Python ImageFilter.SMOOTH_MORE使用的例子?那麽, 這裏精選的屬性代碼示例或許可以為您提供幫助。您也可以進一步了解該屬性所在類PIL.ImageFilter
的用法示例。
在下文中一共展示了ImageFilter.SMOOTH_MORE屬性的6個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Python代碼示例。
示例1: imfilter
# 需要導入模塊: from PIL import ImageFilter [as 別名]
# 或者: from PIL.ImageFilter import SMOOTH_MORE [as 別名]
def imfilter(arr,ftype):
"""
Simple filtering of an image.
Parameters
----------
arr : ndarray
The array of Image in which the filter is to be applied.
ftype : str
The filter that has to be applied. Legal values are:
'blur', 'contour', 'detail', 'edge_enhance', 'edge_enhance_more',
'emboss', 'find_edges', 'smooth', 'smooth_more', 'sharpen'.
Returns
-------
imfilter : ndarray
The array with filter applied.
Raises
------
ValueError
*Unknown filter type.* If the filter you are trying
to apply is unsupported.
"""
_tdict = {'blur':ImageFilter.BLUR,
'contour':ImageFilter.CONTOUR,
'detail':ImageFilter.DETAIL,
'edge_enhance':ImageFilter.EDGE_ENHANCE,
'edge_enhance_more':ImageFilter.EDGE_ENHANCE_MORE,
'emboss':ImageFilter.EMBOSS,
'find_edges':ImageFilter.FIND_EDGES,
'smooth':ImageFilter.SMOOTH,
'smooth_more':ImageFilter.SMOOTH_MORE,
'sharpen':ImageFilter.SHARPEN
}
im = toimage(arr)
if ftype not in _tdict:
raise ValueError("Unknown filter type.")
return fromimage(im.filter(_tdict[ftype]))
示例2: test_sanity
# 需要導入模塊: from PIL import ImageFilter [as 別名]
# 或者: from PIL.ImageFilter import SMOOTH_MORE [as 別名]
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")
示例3: imfilter
# 需要導入模塊: from PIL import ImageFilter [as 別名]
# 或者: from PIL.ImageFilter import SMOOTH_MORE [as 別名]
def imfilter(arr, ftype):
"""
Simple filtering of an image.
Parameters
----------
arr : ndarray
The array of Image in which the filter is to be applied.
ftype : str
The filter that has to be applied. Legal values are:
'blur', 'contour', 'detail', 'edge_enhance', 'edge_enhance_more',
'emboss', 'find_edges', 'smooth', 'smooth_more', 'sharpen'.
Returns
-------
imfilter : ndarray
The array with filter applied.
Raises
------
ValueError
*Unknown filter type.* If the filter you are trying
to apply is unsupported.
"""
_tdict = {'blur': ImageFilter.BLUR,
'contour': ImageFilter.CONTOUR,
'detail': ImageFilter.DETAIL,
'edge_enhance': ImageFilter.EDGE_ENHANCE,
'edge_enhance_more': ImageFilter.EDGE_ENHANCE_MORE,
'emboss': ImageFilter.EMBOSS,
'find_edges': ImageFilter.FIND_EDGES,
'smooth': ImageFilter.SMOOTH,
'smooth_more': ImageFilter.SMOOTH_MORE,
'sharpen': ImageFilter.SHARPEN
}
im = toimage(arr)
if ftype not in _tdict:
raise ValueError("Unknown filter type.")
return fromimage(im.filter(_tdict[ftype]))
示例4: FilterImage
# 需要導入模塊: from PIL import ImageFilter [as 別名]
# 或者: from PIL.ImageFilter import SMOOTH_MORE [as 別名]
def FilterImage(image, filter_name):
"""Applies an arbitrary filtering to a PIL image. Note that this does not
work for two-byte images.
Input:
image a PIL image as 8-bit RGB or grayscale.
filter_name name of the filter to be applied. Choices are
"NONE", "BLUR", "CONTOUR", "DETAIL" ,"EDGE_ENHANCE",
"EDGE_ENHANCE_MORE", "EMBOSS", "FIND_EDGES",
"SMOOTH", "SMOOTH_MORE", "SHARPEN", "MEDIAN_3",
"MEDIAN_5", "MEDIAN_7", "MINIMUM_3", "MINIMUM_5",
"MINIMUM_7" ,"MAXIMUM_3", "MAXIMUM_5", and
"MAXIMUM_7".
Return: a pointer to the filtered image.
"""
if type(image) == list:
raise ValueError("filtering of 2-byte images is not supported")
# Look up filter method
if filter:
filter_method = FILTER_DICT[filter_name.upper()]
else:
filter_method = None
# Apply filter if necessary
if filter_method: image = image.filter(filter_method)
return image
################################################################################
# Re-size a PIL image
################################################################################
示例5: imfilter
# 需要導入模塊: from PIL import ImageFilter [as 別名]
# 或者: from PIL.ImageFilter import SMOOTH_MORE [as 別名]
def imfilter(arr, ftype):
"""
Simple filtering of an image.
This function is only available if Python Imaging Library (PIL) is installed.
.. warning::
This function uses `bytescale` under the hood to rescale images to use
the full (0, 255) range if ``mode`` is one of ``None, 'L', 'P', 'l'``.
It will also cast data for 2-D images to ``uint32`` for ``mode=None``
(which is the default).
Parameters
----------
arr : ndarray
The array of Image in which the filter is to be applied.
ftype : str
The filter that has to be applied. Legal values are:
'blur', 'contour', 'detail', 'edge_enhance', 'edge_enhance_more',
'emboss', 'find_edges', 'smooth', 'smooth_more', 'sharpen'.
Returns
-------
imfilter : ndarray
The array with filter applied.
Raises
------
ValueError
*Unknown filter type.* If the filter you are trying
to apply is unsupported.
"""
_tdict = {'blur': ImageFilter.BLUR,
'contour': ImageFilter.CONTOUR,
'detail': ImageFilter.DETAIL,
'edge_enhance': ImageFilter.EDGE_ENHANCE,
'edge_enhance_more': ImageFilter.EDGE_ENHANCE_MORE,
'emboss': ImageFilter.EMBOSS,
'find_edges': ImageFilter.FIND_EDGES,
'smooth': ImageFilter.SMOOTH,
'smooth_more': ImageFilter.SMOOTH_MORE,
'sharpen': ImageFilter.SHARPEN
}
im = toimage(arr)
if ftype not in _tdict:
raise ValueError("Unknown filter type.")
return fromimage(im.filter(_tdict[ftype]))
示例6: blurred
# 需要導入模塊: from PIL import ImageFilter [as 別名]
# 或者: from PIL.ImageFilter import SMOOTH_MORE [as 別名]
def blurred(fn):
PADDING = 16
def get_shape_box(*args):
if fn.__name__ == 'polygon':
xlist = [pt.x for pt in args[0]]
ylist = [pt.y for pt in args[0]]
return Box(min(xlist), min(ylist), max(xlist), max(ylist))
else:
return args[0]
def get_abs_coordinate(box, *args):
dx = box.x1 - PADDING
dy = box.y1 - PADDING
if fn.__name__ == 'polygon':
return [pt.shift(-dx, -dy) for pt in args[0]]
else:
return box.shift(-dx, -dy)
def create_shadow(self, size, *args, **kwargs):
drawer = ImageDrawExBase(self.filename, transparency=True)
drawer.set_canvas_size(size)
getattr(drawer, fn.__name__)(*args, **kwargs)
for _ in range(15):
drawer._image = drawer._image.filter(ImageFilter.SMOOTH_MORE)
return drawer._image
@wraps(fn)
def func(self, *args, **kwargs):
args = list(args)
if kwargs.get('filter') not in ('blur', 'transp-blur'):
return fn(self, *args, **kwargs)
else:
box = get_shape_box(*args)
args[0] = get_abs_coordinate(box, *args)
size = Size(box.width + PADDING * 2, box.height + PADDING * 2)
shadow = create_shadow(self, size, *args, **kwargs)
xy = XY(box.x1 - PADDING, box.y1 - PADDING)
self.paste(shadow, xy, shadow)
return func