The Image.split () method is used to split an image into separate stripes. This method returns a set of individual image stripes from an image.
Splitting an RGB image creates three new images, each containing a copy of one of the original stripes (red, green, blue).
Syntax:
var = Image.Image.split (image_object)
OR
var = Image.Image.split (path_of_image)
Return Value: It returns a tuple containing bands.
Code # 1:
# class import images from the PIL package from PIL import Image # opening a multiband image (specifically RGB) im = Image. ope n (r "C: UsersAdminPictures etwork.png" ) # split () method # this will split the image into separate stripes # and return a tuple im1 = Image.Image.split (im) # shows each group im1 [ 0 ]. show () im1 [ 1 ]. show () im1 [ 2 ]. show () |
Output:
Code # 2:
# import image class from PIL package from PIL import Image # open a single page image im = Image. open (r "C: UsersAdminPicturessingleband .png " ) < code class = "comments"> # split () method # this will split the image into separate stripes # and return a tuple (of 1 element for one range) im1 = Image.Image.split (im) # show the image im1 [ 0 ]. show () |
Exit:
Images used:
Shop
Best laptop for Excel
$
Best laptop for Solidworks
$399+
Best laptop for Roblox
$399+
Best laptop for development
$499+
Best laptop for Cricut Maker
$299+
Best laptop for hacking
$890
Best laptop for Machine Learning
$699+
Raspberry Pi robot kit
$150
Latest questions
PythonStackOverflow
Common xlabel/ylabel for matplotlib subplots
1947 answers
PythonStackOverflow
Check if one list is a subset of another in Python
1173 answers
PythonStackOverflow
How to specify multiple return types using type-hints
1002 answers
PythonStackOverflow
Printing words vertically in Python
909 answers
PythonStackOverflow
Python Extract words from a given string
798 answers
PythonStackOverflow
Why do I get "Pickle - EOFError: Ran out of input" reading an empty file?
606 answers
PythonStackOverflow
Python os.path.join () method
384 answers
PythonStackOverflow
Flake8: Ignore specific warning for entire file
360 answers
Wiki
Python | How to copy data from one Excel sheet to another
Common xlabel/ylabel for matplotlib subplots
Check if one list is a subset of another in Python
How to specify multiple return types using type-hints
Printing words vertically in Python
Python Extract words from a given string
Cyclic redundancy check in Python
Finding mean, median, mode in Python without libraries
Python add suffix / add prefix to strings in a list
Why do I get "Pickle - EOFError: Ran out of input" reading an empty file?
Python - Move item to the end of the list
Python - Print list vertically