2.6. Bboxes (bounding boxes)
A bounding box or bbox is a rectangle in the image. It is defined by a 4-tuple, (x
0
, y
0
, x
1
, y
1
) where (x
0
,
y
0
) is the top left (northwest) corner of the rectangle, and (x
1
, y
1
) is the bottom right (southeast) corner.
Generally, the area described by a bounding box will include point (x
0
, y
0
), but it will not include point
(x
1
, y
1
) or the row and column of pixels containing point (x
1
, y
1
).
For example, drawing an ellipse inside the bounding box (0,0,5,10) will produce an ellipse 5 pixels
wide and 10 pixels high. The resulting ellipse will include pixel column 4 but not column 5, and will
also include pixel row 9 but not row 10.
2.7. Colors
You can specify colors in several different ways.
•
For single-band images, the color is the pixel value. For example, in a mode "1" image, the color is
a single integer, 0 for black, 1 for white. For mode "L", it is an integer in the range [0,255], where 0
means black and 255 means white.
•
For multi-band images, supply a tuple with one value per band. In an "RGB" image, the tuple
(255,0,0) is pure red.
•
You can use CSS-style color name strings of the form #rrggbb, where rr specifies the red part as
two hexadecimal digits, gg specifies green, and bb blue. For example, "#ffff00" means yellow
(full red + full green).
•
To specify RGB pixel values in decimal, use a string of the form "rgb(R,G,B)". For example,
"rgb(0,255,0)" is pure green.
•
To specify RGB pixel values as percentages, use a string of the form "rgb(R%,G%,B%)". For example,
you can get a light gray with "rgb(85%,85%,85%)".
• To specify colors in the hue-saturation-lightness (HSV) system, use a string of the form
"hsl(H,S%,L%)".
H is the hue angle in degrees: 0 is red, 60 is yellow, 120 is green, and so on.
S is the saturation: 0% for unsaturated (gray), 100% for fully saturated.
The lightness L is 0% for black, 50% for normal, and 100% for white.
For example, "hsl(180,100%,50%)" is pure cyan.
• On Unix systems, you can use any of the standard color names from the locally installed set given in
file "/usr/lib/X11/rgb.txt", such as "white", "DodgerBlue", or "coral".
2.8. Filters
Some operations that reduce the number of pixels, such as creating a thumbnail, can use different filters
to compute the new pixel values. These include:
NEAREST
Uses the value of the nearest pixel.
BILINEAR
Uses linear interpolation over a 2x2 set of adjacent pixels.
3Python Imaging Library (PIL)New Mexico Tech Computer Center
评论2
最新资源