Reputation: 9833
If I have the following 4 sets of coordinates, each being a corner of a square, what would be the best way to create a coordinate mapping of all of the inner pixels?
(566, 282) - top left
(566, 304) - top right
(594, 282) - bottom left
(594, 304) - bottom right
Is there any python libraries to help create this box of pixels using the corner coordinates?
i.e expected result
[(566, 282), (566, 283), (566, 284)...(594, 302), (594, 303), (594, 304)]
Upvotes: 0
Views: 92
Reputation: 142641
You need only for
, range()
and list comprehension
left = 282
right = 304
top = 566
bottom = 594
result = [(y, x) for y in range(top, bottom+1) for x in range(left, right+1)]
print(result)
Upvotes: 1