-
Notifications
You must be signed in to change notification settings - Fork 51
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add argparse, deterministic precipitation, image input support for simulation.py #23
base: master
Are you sure you want to change the base?
Conversation
Add an image_to_array function so we can run simulation.py from an input image instead of generating a new FBM every time we run simulation.py I have not tested this for robustness and it will probably break if the image isn't an 8-bit grayscale (1 channel) image.
- Simulation takes an input image as terrain source instead of generating a new FBM every time it runs. (This is probably fragile as I haven't tested with anything other than an 8-bit 1-channel grayscale png) Usage: `python simulation.py <input_image.png>` - Precipitation randomness has been replaced with seeded randomness in the two parts of the code that were using random precipitation. This makes the output of the simulation deterministic for the same given input image. For now we're just using the current iteration as the base for the seed and changing it on every iteration to keep things close to the way the previous randomness used to be. - If enable_snapshotting is True, also save out the terrain source before running any iterations on it.
Fix a typo
- Allow user to control the seed used to generate fbm.
- Added argparse options (required moving a few things around) - Argparse controls snapshotting now - Also has an argument for saving out png files automatically so the user doesn't need to run make_grayscaleimage.py or make_hillshaded_image.py
- Added argparse options
- Add argparse options and ability to automatically save out png files.
- Add argparse options - User control over fbm input seed - Option to automatically save out png files
- Add argparse options - Fixed a typo - Result is saved into an output subfolder
- Add argparse options - Fixed a typo - Result is saved into an output subfolder
- Add argparse options and ability to save out png files automatically
Argparse and simulation updates
- Update help text for --file argument
- Added conversion support for 16-bit grayscale images and RGB and RGBA images. Tested with png, jpg, tga, and tiff images of various bit depths and with/without alpha channels and didn't run into issues but there are still a lot of untested combinations. Still room for improvement but these should be the most common.
This is a lot of good work, and I like the effort you put into it. My personal preference for many of these scripts was that they be demos rather than utilities, since I wanted people to go in and change things to see what happened. However, since I am no longer actively contributing to this project, and you have put in a lot of good effort, I would be willing to add a comment to the top of README.md pointing readers to your fork. Does that sound fine by you? |
Hmm, an interesting idea although I'm not sure how to "brand" a link to my fork. I.E. I'm not really capable of doing major revisions or features related to the simulations as a responsible maintainer or anything like that. I'm still new to programming in general and these demos are using math that's above my head. (I don't remember a thing about imaginary numbers and I never made it as far as Fourier transforms in my schooling. [present-me wishes that past-me had taken calc and trig]) For an example of how I'm already kind of at my knowledge limits, I tried to get I also don't grok, for example, how you plotted the river network images when there doesn't appear to be code for that explicit purpose in the repo.
I know the data is there in their own arrays of course ( So yeah in summation I'm not sure what the best way to frame a link to this fork would be. |
output
subfolder to keep things tidy.simulation.py
's precipitation randomness has been replaced with seeded randomness in the two parts of the code that were using random precipitation. This makes the output of the simulation deterministic for the same given input seed or image. For now we're just using the current iteration # as the base for the seed and changing it on every iteration to keep things close to the way the previous randomness used to be.fbm
function also accepts a specific seed for user control of results.<script_name.py> -h
for help on a particular .py file.make_grayscale_image.py
andmake_hillshaded_image.py
):-h: Help
-f:
simulation.py
can now take an input image as terrain source instead of generating a new fBm every time it runs. If a file is given as input thensimulation.py
will get its dimensions from the file. Requires a square image.-s: A positive integer. This is a seed for the randomness used in
plain_old_fbm.py
andsimulation.py
so we can have predictable, repeatable results.-o: User-defined name for the output file (without file extension, except in
make_grayscale_image.py
andmake_hillshaded_image.py
where user must type .png extension)--snapshot: Controls whether simulation.py will use snapshotting.
--png: Automatically save out a grayscale and hillshaded png of the result to save some work.