Changeset 4072 for cows/trunk
- Timestamp:
- 29/07/08 13:55:09 (12 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
cows/trunk/cows/bbox_util.py
r4008 r4072 6 6 7 7 """ 8 9 import math 8 10 9 11 def intersection(bbox1, bbox2): … … 31 33 return (sx, sy) 32 34 33 def geoToPixel(x_g, y_g, bbox, width, height ):35 def geoToPixel(x_g, y_g, bbox, width, height, roundUpX=False, roundUpY=False): 34 36 """ 35 37 Calculate the pixel coordinate of a point within a bbox given the … … 44 46 @param width: The width of the image in pixels 45 47 @param height: The height of the image in pixels. 48 @param roundUpX: Round the X pixel value upwards. 49 @param roundUpY: Round the y pixel value upwards. 50 46 51 @return: (x,y) in pixel coordinates 47 52 … … 50 55 x = (x_g - bbox[0])*width / (bbox[2]-bbox[0]) 51 56 y = (bbox[3] - y_g)*height / (bbox[3]-bbox[1]) 57 58 if roundUpX: 59 x = math.ceil(x) 60 if roundUpY: 61 y = math.ceil(y) 52 62 53 63 return int(x), int(y)
Note: See TracChangeset
for help on using the changeset viewer.