Change filters
12
main.py
@@ -26,13 +26,13 @@ def main():
|
|||||||
abs(buildArea.begin.z - buildArea.end.z) / 2)
|
abs(buildArea.begin.z - buildArea.end.z) / 2)
|
||||||
length_world = sqrt((center[0]*2) ** 2 + (center[1]*2) ** 2)
|
length_world = sqrt((center[0]*2) ** 2 + (center[1]*2) ** 2)
|
||||||
|
|
||||||
# remove_trees('./world_maker/data/heightmap.png', './world_maker/data/treemap.png',
|
remove_trees('./world_maker/data/heightmap.png', './world_maker/data/treemap.png',
|
||||||
# './world_maker/data/smooth_sobel_watermap.png')
|
'./world_maker/data/smooth_sobel_watermap.png')
|
||||||
# smooth_terrain('./world_maker/data/heightmap.png',
|
smooth_terrain('./world_maker/data/heightmap.png',
|
||||||
# './world_maker/data/heightmap_smooth.png', './world_maker/data/smooth_sobel_watermap.png')
|
'./world_maker/data/heightmap_smooth.png', './world_maker/data/smooth_sobel_watermap.png')
|
||||||
|
|
||||||
# set_roads(skeleton_highway, origin)
|
set_roads(skeleton_highway, origin)
|
||||||
# set_roads(skeleton_mountain, origin)
|
set_roads(skeleton_mountain, origin)
|
||||||
# set_roads_grids(road_grid, origin)
|
# set_roads_grids(road_grid, origin)
|
||||||
# roads.setRoads(skeleton_mountain)
|
# roads.setRoads(skeleton_mountain)
|
||||||
# roads.setRoads(skeleton_highway)
|
# roads.setRoads(skeleton_highway)
|
||||||
|
|||||||
|
Before Width: | Height: | Size: 717 B After Width: | Height: | Size: 963 B |
|
Before Width: | Height: | Size: 1.0 KiB After Width: | Height: | Size: 1.0 KiB |
|
Before Width: | Height: | Size: 6.0 KiB After Width: | Height: | Size: 5.8 KiB |
|
Before Width: | Height: | Size: 10 KiB After Width: | Height: | Size: 9.7 KiB |
|
Before Width: | Height: | Size: 24 KiB After Width: | Height: | Size: 24 KiB |
|
Before Width: | Height: | Size: 29 KiB After Width: | Height: | Size: 28 KiB |
|
Before Width: | Height: | Size: 1.8 KiB After Width: | Height: | Size: 2.3 KiB |
|
Before Width: | Height: | Size: 2.3 KiB After Width: | Height: | Size: 2.6 KiB |
|
Before Width: | Height: | Size: 2.7 KiB After Width: | Height: | Size: 2.5 KiB |
|
Before Width: | Height: | Size: 45 KiB After Width: | Height: | Size: 49 KiB |
|
Before Width: | Height: | Size: 2.2 KiB After Width: | Height: | Size: 3.0 KiB |
|
Before Width: | Height: | Size: 44 KiB After Width: | Height: | Size: 45 KiB |
|
Before Width: | Height: | Size: 1.4 KiB After Width: | Height: | Size: 1.6 KiB |
@@ -229,19 +229,50 @@ def highway_map() -> Image.Image:
|
|||||||
negative_smooth_sobel_water = subtract_map(
|
negative_smooth_sobel_water = subtract_map(
|
||||||
negative_smooth_sobel, './world_maker/data/watermap.png')
|
negative_smooth_sobel, './world_maker/data/watermap.png')
|
||||||
array_sobel_water = np.array(negative_smooth_sobel_water)
|
array_sobel_water = np.array(negative_smooth_sobel_water)
|
||||||
|
|
||||||
|
# Remove details
|
||||||
array_sobel_water = ndimage.binary_erosion(
|
array_sobel_water = ndimage.binary_erosion(
|
||||||
array_sobel_water, iterations=12)
|
array_sobel_water, iterations=5)
|
||||||
|
|
||||||
|
# Smooth non buildable area
|
||||||
|
array_sobel_water = filter_negative(
|
||||||
|
filter_smooth_array(np.array(filter_negative(array_sobel_water)), 2))
|
||||||
|
array_sobel_water = np.array(array_sobel_water)
|
||||||
|
|
||||||
|
# Propagate buildable area
|
||||||
array_sobel_water = ndimage.binary_dilation(
|
array_sobel_water = ndimage.binary_dilation(
|
||||||
array_sobel_water, iterations=5)
|
array_sobel_water, iterations=5)
|
||||||
array_sobel_water = filter_smooth_array(array_sobel_water, 5)
|
|
||||||
|
# Smooth buildable area
|
||||||
|
array_sobel_water = filter_smooth_array(array_sobel_water, 2)
|
||||||
|
array_sobel_water = np.array(array_sobel_water)
|
||||||
|
|
||||||
|
# Smooth non buildable area
|
||||||
|
array_sobel_water = filter_negative(
|
||||||
|
filter_smooth_array(np.array(filter_negative(array_sobel_water)), 1))
|
||||||
|
array_sobel_water = np.array(array_sobel_water)
|
||||||
|
|
||||||
|
# Erode buildable area
|
||||||
array_sobel_water = ndimage.binary_erosion(
|
array_sobel_water = ndimage.binary_erosion(
|
||||||
array_sobel_water, iterations=20)
|
array_sobel_water, iterations=12)
|
||||||
array_sobel_water = filter_smooth_array(array_sobel_water, 6)
|
|
||||||
|
# Dilate buildable area
|
||||||
|
array_sobel_water = ndimage.binary_dilation(
|
||||||
|
array_sobel_water, iterations=7)
|
||||||
|
|
||||||
|
# Smooth buildable area
|
||||||
|
array_sobel_water = filter_smooth_array(array_sobel_water, 20)
|
||||||
|
array_sobel_water = np.array(array_sobel_water)
|
||||||
|
|
||||||
image = Image.fromarray(array_sobel_water)
|
image = Image.fromarray(array_sobel_water)
|
||||||
image_no_details = filter_remove_details(image, 15)
|
image.save('./world_maker/data/smooth_for_highway.png')
|
||||||
image_no_details.save('./world_maker/data/highwaymap.png')
|
|
||||||
|
# Remove details
|
||||||
|
# image_no_details = filter_remove_details(image, 10)
|
||||||
|
# image_no_details.save('./world_maker/data/highwaymap.png')
|
||||||
|
|
||||||
print("[Data Analysis] Highway map generated.")
|
print("[Data Analysis] Highway map generated.")
|
||||||
return image_no_details
|
return image
|
||||||
|
|
||||||
|
|
||||||
def create_volume(surface: np.ndarray, heightmap: np.ndarray, make_it_flat: bool = False) -> np.ndarray:
|
def create_volume(surface: np.ndarray, heightmap: np.ndarray, make_it_flat: bool = False) -> np.ndarray:
|
||||||
|
|||||||
@@ -9,10 +9,10 @@ from world_maker.pack_rectangle import generate_building
|
|||||||
|
|
||||||
|
|
||||||
def world_maker():
|
def world_maker():
|
||||||
# world = World()
|
world = World()
|
||||||
# heightmap, watermap, treemap = get_data(world)
|
heightmap, watermap, treemap = get_data(world)
|
||||||
|
|
||||||
heightmap, watermap, treemap = get_data_no_update()
|
# heightmap, watermap, treemap = get_data_no_update()
|
||||||
|
|
||||||
filter_sobel(
|
filter_sobel(
|
||||||
"./world_maker/data/heightmap.png").save('./world_maker/data/sobelmap.png')
|
"./world_maker/data/heightmap.png").save('./world_maker/data/sobelmap.png')
|
||||||
|
|||||||