Image.draw_box#

Image.draw_box(**kwargs: Any) → None[source][source]#

Draw box into image

Parameters:

kwargs – parameters passed to draw_box

There are myriad ways to specify the corners of the box.

Example, draw boxes over the eyes of the Mona Lisa:

from machinevisiontoolbox import Image
img = Image.Read("monalisa.png")
img.draw_box(lb=(245,170), rt=(290, 210), color="yellow", thickness=5)
img.draw_box(lb=(315, 175), rt=(370,205), color="blue", thickness=-1)
img.disp()

(Source code, png, hires.png, pdf)

../_images/machinevisiontoolbox-Image-draw_box-1.png

Note

If image has multiple planes then color should have the same number of elements as the image has planes. If it is a scalar that value is used for each color plane. For a color image color can be a string color name.

Warning

The image is drawn into in place. OpenCV requires that its pixel data is C-contiguous, otherwise a ValueError is raised. Images read from file are, but an image created from a transposed or reversed array might not be: create it with Image(array, copy=True) to get a contiguous copy. See Image.

Seealso:

draw_box