Wand mode() function Python (original) (raw)
Last Updated : 19 May, 2021
The mode() function is an inbuilt function in the Python Wand ImageMagick library which is used to replace each pixel with the mathematical mode of the neighboring colors.
Syntax:
mode(width, height)
Parameters: This function accepts two parameters as mentioned above and defined below:
- width: This parameter is used to store the number of neighboring pixels to include in mode.
- height: This is an optional parameter is used to store height of neighboring pixels. By default it is same as width.
Return Value: This function returns the Wand ImageMagick object.
Original Image:
Example 1:
Python3
from
wand.image
import
Image
with Image(filename
=
'../geeksforgeeks.png'
) as image:
`` with image.clone() as mode:
`` mode.mode(
30
,
10
)
`` mode.save(filename
=
'mode1.jpg'
)
Output:
Example 2:
Python3
from
wand.image
import
Image
from
wand.drawing
import
Drawing
from
wand.color
import
Color
with Drawing() as draw:
`` draw.stroke_color
=
Color(
'black'
)
`` draw.stroke_width
=
1
`` draw.fill_color
=
Color(
'white'
)
`` draw.circle((
200
,
200
),
`` (
100
,
100
))
`` draw.font
=
'../Helvetica.ttf'
`` draw.font_size
=
30
`` with Image(width
=
400
, height
=
400
, background
=
Color(
'# 45ff33'
)) as pic:
`` draw.text(
int
(pic.width
/
3
),
int
(pic.height
/
2
),
'GeeksForGeeks !'
)
`` draw(pic)
`` pic.mode(
200
)
`` pic.save(filename
=
'mode2.jpg'
)
Output:
Similar Reads
- Wand implode() function - Python The implode() function is an inbuilt function in the Python Wand ImageMagick library which is used to create a “imploding†effect by pulling pixels towards the center of the image. Syntax: implode(amount, method) Parameters: This function accepts two parameters as mentioned above and defined below: 2 min read
- Wand implode() function - Python implode() generates a kind of distorted image in which pull effect is noticed into the middle of the image. The amount argument controls the range of pixels to pull towards the center. Syntax : wand.image.implode(amount, method) Parameters : ParameterInput TypeDescriptionamountnumbers.RealNormalized 1 min read
- Wand modulate() function - Python The modulate() function is an inbuilt function in the Python Wand ImageMagick library which is used to changes the brightness, saturation and hue of the image. Syntax: modulate(brightness, saturation, hue) Parameters: This function accepts three parameters as mentioned above and defined below: brigh 2 min read
- Wand noise() function - Python The noise() function is an inbuilt function in the Python Wand ImageMagick library which is used to add noise to the image. Syntax: noise(noise_type, attenuate, channel) Parameters: This function accepts three parameters as mentioned above and defined below: noise_type: This parameter is used to sto 2 min read
- Wand fx() function - Python FX special effects are a powerful “micro†language to work with. Simple functions & operators offer a unique way to access & manipulate image data. The fx() method applies a FX expression, and generates a new Image instance. We can create a custom DIY filter that will turn the image black 1 min read
- Python - Image() function in Wand In this specific article we will learn how to read our image through Python wand module. To read image in Wand we use Image() function. To manipulate an image first of all we need to read image in Python. Parameters : Parameter Input Type Description image Image make exact copy of image blob bytes o 2 min read
- Wand polaroid() function - Python polaroid() is one of function with simplest functionality. It generates image with a white border with a slight shadow to create a special effect of a Polaroid print. Syntax : wand.image.polaroid(angle, caption, font, method) Parameters : Parameter Input Type Description angle numbers.Real applies a 1 min read
- Python - noise() function in Wand Image noise is random variation of brightness or color information in images, and is usually an aspect of electronic noise. We can add noise to the image using noise() function. noise function can be useful when applied before a blur operation to defuse an image. Following are the noise we can add u 1 min read
- modf() function - Python modf() function is an inbuilt function in Python that returns the fractional and integer parts of the number in a two-item tuple. Both parts have the same sign as the number. The integer part is returned as a float. Example:[GFGTABS] Python import math # modf() function used with a positive number p 4 min read
- Wand line() function in Python line() is another drawing function present in wand.drawing module. As the name implies line() function is used to draw a line in the image. line() function only need two arguments that are start and end point of the line that we want to draw. Syntax : wand.drawing.line(start, end) Parameters : Param 2 min read