From fee7cf56fe8cfba71d03089abbc1fc1b5e61890f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jure=20=C5=A0orn?= Date: Wed, 1 Feb 2023 13:04:12 +0100 Subject: [PATCH] Image --- README.md | 10 ++++------ index.html | 16 +++++++++------- 2 files changed, 13 insertions(+), 13 deletions(-) diff --git a/README.md b/README.md index 0133c0d..25c6e26 100644 --- a/README.md +++ b/README.md @@ -2740,7 +2740,7 @@ Image ----- ```python # $ pip3 install pillow -from PIL import Image +from PIL import Image, ImageDraw ``` ```python @@ -2764,6 +2764,8 @@ from PIL import Image <3d_array> = np.array() # Creates NumPy array from color image. = Image.fromarray(np.uint8()) # Use .clip(0, 255) to clip the values. ``` +* **To edit an image use `'ImageEnhance'`, `'ImageFilter'` and `'ImageOps'` submodules.** +* **Custom filters can be applied to arrays using `'scipy.ndimage.convolve()'` function.** ### Modes * **`'1'` - 1-bit pixels, black and white, stored with one pixel per byte.** @@ -2794,11 +2796,7 @@ img.show() ### Image Draw ```python -from PIL import ImageDraw - = ImageDraw.Draw() -``` - -```python + = ImageDraw.Draw() # Object for adding 2D graphics to the image. .point((x, y)) # Truncates floats into ints. .line((x1, y1, x2, y2 [, ...])) # To get anti-aliasing use Image's resize(). .arc((x1, y1, x2, y2), deg1, deg2) # Always draws in clockwise direction. diff --git a/index.html b/index.html index a8cdc56..1045942 100644 --- a/index.html +++ b/index.html @@ -2240,7 +2240,7 @@ right = [[0.1, 0.6

#Image

# $ pip3 install pillow
-from PIL import Image
+from PIL import Image, ImageDraw
 
<Image> = Image.new('<mode>', (width, height))   # Also: `color=<int/tuple/str>`.
@@ -2259,6 +2259,10 @@ right = [[0.1,  0.6# Creates NumPy array from color image.
 <Image>    = Image.fromarray(np.uint8(<array>))  # Use <array>.clip(0, 255) to clip the values.
 
+
    +
  • To edit an image use 'ImageEnhance', 'ImageFilter' and 'ImageOps' submodules.
  • +
  • Custom filters can be applied to arrays using 'scipy.ndimage.convolve()' function.
  • +

Modes

  • '1' - 1-bit pixels, black and white, stored with one pixel per byte.
  • 'L' - 8-bit pixels, greyscale.
  • @@ -2283,17 +2287,15 @@ img.putdata([(add_noise(h), s, v) for h, s, v img.show()
-

Image Draw

from PIL import ImageDraw
-<ImageDraw> = ImageDraw.Draw(<Image>)
-
- -
<ImageDraw>.point((x, y))                        # Truncates floats into ints.
+

Image Draw

<ImageDraw> = ImageDraw.Draw(<Image>)            # Object for adding 2D graphics to the image.
+<ImageDraw>.point((x, y))                        # Truncates floats into ints.
 <ImageDraw>.line((x1, y1, x2, y2 [, ...]))       # To get anti-aliasing use Image's resize().
 <ImageDraw>.arc((x1, y1, x2, y2), deg1, deg2)    # Always draws in clockwise direction.
 <ImageDraw>.rectangle((x1, y1, x2, y2))          # To rotate use Image's rotate() and paste().
 <ImageDraw>.polygon((x1, y1, x2, y2, ...))       # Last point gets connected to the first.
 <ImageDraw>.ellipse((x1, y1, x2, y2))            # To rotate use Image's rotate() and paste().
-
+
+
  • Use 'fill=<color>' to set the primary color.
  • Use 'width=<int>' to set the width of lines or contours.