Image.plane#
- Image.plane(planes) Image[source][source]#
Extract plane(s) from color image
- Parameters:
planes (int, list, str) – planes to extract
- Raises:
ValueError – if image is not color
- Return out:
image containing only the selected planes
- Return type:
Create a new image from the selected planes of the image.
Example:
>>> from machinevisiontoolbox import Image >>> img = Image.Read("flowers4.png") # in BGR order >>> img.colororder_str 'R:G:B' >>> img.nplanes 3 >>> red = img.plane(0) # red plane >>> red Image(size=(640, 426), dtype=uint8) >>> red.iscolor False >>> red.nplanes 1 >>> green_blue = img.plane('G:B') # green and blue planes >>> green_blue Image(size=(640, 426), dtype=uint8, nplanes=2, colororder=G:B) >>> green_blue.iscolor True >>> green_blue.nplanes 2 >>> red_blue = img.plane([0, 2]) # blue and red planes >>> red_blue Image(size=(640, 426), dtype=uint8, nplanes=2, colororder=R:B)
Note
This can also be performed using the overloaded
__getitem__operator.To select more than one plane, use either a sequence of integers or a string of colon separated plane names.
For a single-plane image the index must be zero.