File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -2703,16 +2703,16 @@ from PIL import Image
27032703```
27042704
27052705``` python
2706- < tuple / int > = < Image> .getpixel((x, y)) # Returns a pixel.
2707- < Image> .putpixel((x, y), < tuple / int > ) # Writes a pixel to the image.
2706+ < int / tuple > = < Image> .getpixel((x, y)) # Returns a pixel.
2707+ < Image> .putpixel((x, y), < int / tuple > ) # Writes a pixel to the image.
27082708< ImagingCore> = < Image> .getdata() # Returns a sequence of pixels.
27092709< Image> .putdata(< list / ImagingCore> ) # Writes a sequence of pixels.
27102710< Image> .paste(< Image> , (x, y)) # Writes an image to the image.
27112711```
27122712
27132713``` bash
2714- < 2d_array> = np.array(< Image > ) # Creates NumPy array from greyscale image.
2715- < 3d_array> = np.array(< Image > ) # Creates NumPy array from color image.
2714+ < 2d_array> = np.array(< Image_L > ) # Creates NumPy array from greyscale image.
2715+ < 3d_array> = np.array(< Image_RGB > ) # Creates NumPy array from color image.
27162716< Image> = Image.fromarray(< array> ) # Creates image from NumPy array of floats.
27172717```
27182718
Original file line number Diff line number Diff line change 23202320<Image>.save(< span class ="hljs-string "> '<path>'</ span > )
23212321<Image>.show()
23222322</ code > </ pre >
2323- < pre > < code class ="python language-python hljs "> <tuple/ int> = <Image>.getpixel((x, y)) < span class ="hljs-comment "> # Returns a pixel.</ span >
2324- <Image>.putpixel((x, y), <tuple/ int>) < span class ="hljs-comment "> # Writes a pixel to the image.</ span >
2323+ < pre > < code class ="python language-python hljs "> <int/tuple > = <Image>.getpixel((x, y)) < span class ="hljs-comment "> # Returns a pixel.</ span >
2324+ <Image>.putpixel((x, y), <int/tuple >) < span class ="hljs-comment "> # Writes a pixel to the image.</ span >
23252325<ImagingCore> = <Image>.getdata() < span class ="hljs-comment "> # Returns a sequence of pixels.</ span >
23262326<Image>.putdata(<list/ImagingCore>) < span class ="hljs-comment "> # Writes a sequence of pixels.</ span >
23272327<Image>.paste(<Image>, (x, y)) < span class ="hljs-comment "> # Writes an image to the image.</ span >
23282328</ code > </ pre >
2329- < pre > < code class ="bash language-bash hljs "> <2d_array> = np.array(<Image >) < span class ="hljs-comment "> # Creates NumPy array from greyscale image.</ span >
2330- <3d_array> = np.array(<Image >) < span class ="hljs-comment "> # Creates NumPy array from color image.</ span >
2329+ < pre > < code class ="bash language-bash hljs "> <2d_array> = np.array(<Image_L >) < span class ="hljs-comment "> # Creates NumPy array from greyscale image.</ span >
2330+ <3d_array> = np.array(<Image_RGB >) < span class ="hljs-comment "> # Creates NumPy array from color image.</ span >
23312331<Image> = Image.fromarray(<array>) < span class ="hljs-comment "> # Creates image from NumPy array of floats.</ span >
23322332</ code > </ pre >
23332333< div > < h3 id ="modes-1 "> Modes</ h3 > < ul >
You can’t perform that action at this time.
0 commit comments