Fix : Height of building and better area taken by building
This commit is contained in:
@@ -384,14 +384,16 @@ def rectangle_2D_to_3D(rectangle: list[tuple[tuple[int, int], tuple[int, int]]],
|
||||
new_rectangle = []
|
||||
for rect in rectangle:
|
||||
start, end = rect
|
||||
avg_height = 0
|
||||
height = {}
|
||||
for x in range(start[0], end[0]):
|
||||
for y in range(start[1], end[1]):
|
||||
avg_height += image.getpixel((x, y))
|
||||
avg_height = int(
|
||||
avg_height / ((end[0] - start[0]) * (end[1] - start[1]))) + 1
|
||||
if image.getpixel((x, y)) not in height:
|
||||
height[image.getpixel((x, y))] = 1
|
||||
else:
|
||||
height[image.getpixel((x, y))] += 1
|
||||
max_height = max(height, key=height.get)
|
||||
new_rectangle.append(
|
||||
((start[0], avg_height, start[1]), (end[0], avg_height + randint(height_min, height_max), end[1])))
|
||||
((start[0], max_height, start[1]), (end[0], max_height + randint(height_min, height_max), end[1])))
|
||||
return new_rectangle
|
||||
|
||||
|
||||
|
||||
Reference in New Issue
Block a user