Fix heightmap color format

This commit is contained in:
2024-06-16 22:28:32 +02:00
parent 54a4a12cca
commit 7b73aef5fe
19 changed files with 14 additions and 17 deletions

Binary file not shown.

Before

Width:  |  Height:  |  Size: 153 B

After

Width:  |  Height:  |  Size: 114 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 113 B

After

Width:  |  Height:  |  Size: 191 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 428 B

After

Width:  |  Height:  |  Size: 563 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 3.3 KiB

After

Width:  |  Height:  |  Size: 3.0 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 1.7 KiB

After

Width:  |  Height:  |  Size: 1.8 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 2.1 KiB

After

Width:  |  Height:  |  Size: 2.0 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 126 B

After

Width:  |  Height:  |  Size: 77 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 755 B

After

Width:  |  Height:  |  Size: 746 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 873 B

After

Width:  |  Height:  |  Size: 89 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 3.1 KiB

After

Width:  |  Height:  |  Size: 2.9 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 4.5 KiB

After

Width:  |  Height:  |  Size: 4.0 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 595 B

After

Width:  |  Height:  |  Size: 569 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 590 B

After

Width:  |  Height:  |  Size: 637 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 1.1 KiB

After

Width:  |  Height:  |  Size: 857 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 3.8 KiB

After

Width:  |  Height:  |  Size: 3.6 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 6.1 KiB

After

Width:  |  Height:  |  Size: 120 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 214 B

After

Width:  |  Height:  |  Size: 376 B

View File

@@ -23,7 +23,7 @@ def remove_trees(heightmap: Union[str, Image], treesmap: Union[str, Image], mask
treesmap = handle_import_image(treesmap).convert('L')
mask = handle_import_image(mask)
removed_treesmap = Image.new("RGB", distance, 0)
removed_treesmap = Image.new("L", distance, 0)
removed = []
for x in range(0, distance[0]):
@@ -31,16 +31,15 @@ def remove_trees(heightmap: Union[str, Image], treesmap: Union[str, Image], mask
if mask.getpixel((x, z)) != 0 and treesmap.getpixel((x, z)) > 0 and (x, z) not in removed:
treeArea = morphology.flood(treesmap, (z, x), tolerance=1)
blend = Image.blend(Image.fromarray(treeArea).convert(
'RGB'), removed_treesmap.convert('RGB'), 0.5)
tree_area = morphology.flood(treesmap, (z, x), tolerance=1)
blend = Image.blend(Image.fromarray(tree_area).convert(
'L'), removed_treesmap.convert('L'), 0.5)
array = np.array(blend.convert('L'))
bool_array = array > 1
removed_treesmap = Image.fromarray(bool_array)
removed.append((x, z))
print(x, z)
for x in range(0, distance[0]):
for z in range(0, distance[1]):

View File

@@ -46,22 +46,20 @@ def world_maker():
rectangle_mountain = rectangle_2D_to_3D(rectangle_mountain)
# Terraforming
# Smooth initialization
overide_map('./world_maker/data/heightmap.png',
'./world_maker/data/building_moutain.png').save('./world_maker/data/heightmap_with_building.png')
overide_map('./world_maker/data/heightmap_with_building.png',
'./world_maker/data/building.png').save('./world_maker/data/heightmap_with_building.png')
filter_smooth(
'./world_maker/data/heightmap_with_building.png', 2).save('./world_maker/data/heightmap_smooth.png')
overide_map('./world_maker/data/heightmap_with_building.png',
'./world_maker/data/building_moutain.png').save('./world_maker/data/heightmap_with_building.png')
overide_map('./world_maker/data/heightmap_with_building.png',
'./world_maker/data/building.png').save('./world_maker/data/heightmap_with_building.png')
filter_smooth(
'./world_maker/data/heightmap_with_building.png', 2).save('./world_maker/data/heightmap_smooth.png')
overide_map('./world_maker/data/heightmap_with_building.png',
'./world_maker/data/building_moutain.png').save('./world_maker/data/heightmap_with_building.png')
overide_map('./world_maker/data/heightmap_with_building.png',
'./world_maker/data/building.png').save('./world_maker/data/heightmap_with_building.png')
filter_smooth(
'./world_maker/data/heightmap_with_building.png', 2).save('./world_maker/data/heightmap_smooth.png')
for i in range(5):
overide_map('./world_maker/data/heightmap_with_building.png',
'./world_maker/data/building_moutain.png').save('./world_maker/data/heightmap_with_building.png')
overide_map('./world_maker/data/heightmap_with_building.png',
'./world_maker/data/building.png').save('./world_maker/data/heightmap_with_building.png')
filter_smooth(
'./world_maker/data/heightmap_with_building.png', 2).save('./world_maker/data/heightmap_smooth.png')
return rectangle_mountain, rectangle_building, skeleton_highway, skeleton_mountain, road_grid