for p in ptc:\r
ptc_src.append(Image.open(p))\r
mstr_msg("layergen", "Layer sources selected")\r
-\r
- """\r
- # OK! Load the mask\r
- if self._is_completion == False:\r
- mask = Image.open( mstr_datafolder + "_cache/" + str(self._latitude) + "-" + str(self._lat_number) + "_" + str(self._longitude) + "-" + str(self._lng_number) + "_" + self._tag + "-" + self._value + ".png" )\r
- if self._is_completion == True:\r
- mask = Image.open( mstr_datafolder + "_cache/" + str(self._latitude) + "-" + str(self._lat_number) + "_" + str(self._longitude) + "-" + str(self._lng_number) + "_tile-completion.png" )\r
- """\r
\r
# Generate an edge mask from the original\r
osm_edge = mask.filter(ImageFilter.FIND_EDGES)\r
mstr_msg("layergen", "Generating adjacent fades")\r
adjfade = self.generate_adjacent_fades(mask)\r
\r
- # Determine if there are any fades, and if so, fade those in first before we save the layer\r
- """\r
- fade_fn = mstr_datafolder + "_cache/" + str(self._latitude) + "-" + str(self._lat_number) + "_" + str(self._longitude) + "-" + str(self._lng_number) + "_" + self._tag + "-" + self._value\r
- if os.path.isfile(fade_fn + "_fade_top.png") == True:\r
- fade = Image.open(fade_fn + "_fade_top.png")\r
- layer_comp.alpha_composite(fade)\r
- if os.path.isfile(fade_fn + "_fade_right.png") == True:\r
- fade = Image.open(fade_fn + "_fade_right.png")\r
- layer_comp.alpha_composite(fade)\r
- if os.path.isfile(fade_fn + "_fade_bottom.png") == True:\r
- fade = Image.open(fade_fn + "_fade_bottom.png")\r
- layer_comp.alpha_composite(fade)\r
- if os.path.isfile(fade_fn + "_fade_left.png") == True:\r
- fade = Image.open(fade_fn + "_fade_left.png")\r
- layer_comp.alpha_composite(fade)\r
- """\r
-\r
layer_comp.alpha_composite(adjfade)\r
mstr_msg("layergen", "Adjacent fading completed")\r
\r
tree_shadow = tree_shadow.filter(ImageFilter.GaussianBlur(radius=2))\r
tree_shadow.alpha_composite(trees)\r
\r
- # Save this separately, so that we can blur buildings, but not the trees\r
- #fn = mstr_datafolder + "_cache/" + str(self._latitude) + "-" + str(self._lat_number) + "_" + str(self._longitude) + "-" + str(self._lng_number) + "_" + self._tag + "-" + self._value + "_layer_building_trees.png"\r
-\r
- #if os.path.isfile(fn) == True:\r
- # extrees = Image.open(fn)\r
- # extrees.alpha_composite(tree_shadow)\r
- # extrees.save(fn)\r
- #else:\r
- # tree_shadow.save(fn)\r
-\r
# Let's try this one on for size\r
bld_comp = Image.new("RGBA", (self._imgsize, self._imgsize))\r
details = details.filter(ImageFilter.GaussianBlur(radius=1))\r
# First, we walk through all layers and blend them on top of each other, in order\r
mstr_msg("photogen", "Merging layers")\r
\r
- """\r
- # Note if we added building shadows\r
- bldg_shadow_added = False\r
-\r
- # Shadow merging\r
- bldg_shadow = Image.new("RGBA", (self._imgsize, self._imgsize))\r
- if mstr_shadow_enabled == True:\r
- for l in mstr_ortho_layers:\r
- if l[0] == "building":\r
- if os.path.isfile(root_filename + l[0] + "-" + l[1] + "_layer_shadow.png"):\r
- shd = Image.open(root_filename + l[0] + "-" + l[1] + "_layer_shadow.png")\r
- shd = shd.filter(ImageFilter.GaussianBlur(radius=2))\r
- bldg_shadow.alpha_composite(shd)\r
- # Details merging\r
- bldg_details = Image.new("RGBA", (self._imgsize, self._imgsize))\r
- for l in mstr_ortho_layers:\r
- if l[0] == "building":\r
- if os.path.isfile(root_filename + l[0] + "-" + l[1] + "_layer_details.png"):\r
- dtl = Image.open(root_filename + l[0] + "-" + l[1] + "_layer_details.png")\r
- dtl = dtl.filter(ImageFilter.GaussianBlur(radius=1))\r
- bldg_details.alpha_composite(dtl)\r
- # Building merging\r
- bldg_main = Image.new("RGBA", (self._imgsize, self._imgsize))\r
- for l in mstr_ortho_layers:\r
- if l[0] == "building":\r
- if os.path.isfile(root_filename + l[0] + "-" + l[1] + "_layer.png"):\r
- bld = Image.open(root_filename + l[0] + "-" + l[1] + "_layer.png")\r
- bld = bld.filter(ImageFilter.GaussianBlur(radius=0.7))\r
- bldg_main.alpha_composite(bld)\r
- # Trees merging\r
- tree_main = Image.new("RGBA", (self._imgsize, self._imgsize))\r
- for l in mstr_ortho_layers:\r
- if l[0] == "building":\r
- if os.path.isfile(root_filename + l[0] + "-" + l[1] + "_layer_building_trees.png"):\r
- trs= Image.open(root_filename + l[0] + "-" + l[1] + "_layer_building_trees.png")\r
- tree_main.alpha_composite(trs)\r
- # Merge the building layers\r
- bldg_final = Image.new("RGBA", (self._imgsize, self._imgsize))\r
- bldg_final.alpha_composite(bldg_details)\r
- #bldg_final.alpha_composite(bldg_shadow)\r
- bldg_final.alpha_composite(tree_main)\r
- bldg_final.alpha_composite(bldg_main)\r
- """\r
-\r
for l in layers:\r
self._tile.alpha_composite(l)\r
- """\r
- if os.path.isfile(root_filename + l[0] + "-" + l[1] + "_layer.png"):\r
- # Need to divert in case we have shadows\r
- if mstr_shadow_enabled == True:\r
-\r
- # Make sure building shadows appear below forests\r
- shdc = False\r
- for s in mstr_shadow_casters:\r
- if s[0] == l[0] and s[1] == l[1]:\r
- shdc = True\r
- break\r
- if shdc == True:\r
- if bldg_shadow_added == False:\r
- self._tile.alpha_composite(bldg_shadow)\r
- bldg_shadow_added = True\r
-\r
- if os.path.isfile(root_filename + l[0] + "-" + l[1] + "_layer_shadow.png"):\r
- if l[0] != "building":\r
- sn = root_filename + l[0] + "-" + l[1] + "_layer_shadow.png"\r
- s_layer = Image.open(sn)\r
- self._tile.alpha_composite(s_layer)\r
- if l[0] != "building":\r
- # Complete the file name based on the template\r
- fn = root_filename + l[0] + "-" + l[1] + "_layer.png"\r
- # Open the layer\r
- layer = Image.open(fn)\r
- if l[0] == "leisure" and l[1] == "pitch":\r
- layer = layer.filter(ImageFilter.GaussianBlur(radius=0.2))\r
- # Converge the layer with this image\r
- self._tile.alpha_composite(layer)\r
- """\r
-\r
- # Drop the buildings on top\r
- #self._tile.alpha_composite(bldg_final)\r
\r
\r
# When we have run through this loop, we will end up with a sandwiched\r
corrpix[x,y] = (0,0,0,0)\r
\r
# We are now in posession of the final image.\r
-\r
- # Scale to correct size.\r
- #self._tile = self._tile.resize((mstr_photores, mstr_photores), Image.Resampling.BILINEAR)\r
\r
# Contrast\r
self._tile = ImageEnhance.Contrast(self._tile).enhance(1)\r
Very simple.\r
\r
First step: \r
-[codebox]python og.py LATITUDE LONGITUDE true[/codebox]\r
+python og.py LATITUDE LONGITUDE true\r
\r
So for example\r
\r
-[codebox]python main.py 51 7 true[codebox]\r
+python og.py 51 7 true\r
\r
This will generate a complete dataset containing which sources to use in which quadrant of the image grid.\r
\r
Then:\r
\r
-[codebox]python og.py LATITUDE LONGITUDE NUMBER_OF_SIMULTANEOUS_IMAGES_TO_PRODUCE[/codebox]\r
+python og.py LATITUDE LONGITUDE NUMBER_OF_SIMULTANEOUS_IMAGES_TO_PRODUCE\r
\r
So for example\r
\r
-[codebox]python main.py 51 7 32[codebox]\r
+python og.py 51 7 32\r
\r
This will generate 32 "orthos" at once. Which number you can use highly depends on the performance of your hardware.\r
\r
\r
For X-Plane scenery, you will need to do this once step 2 is done:\r
\r
-[codebox]python main.py 51 7 xpscenery[codebox]\r
+python og.py 51 7 xpscenery\r
\r
This will generate the terrain mesh and associate the textures with the mesh.\r
\r