Added a module to the tools sub-package that enables a PNG image file to be converted into a HDF5 file that can then be used to import geometry.

这个提交包含在:
Craig Warren
2017-04-04 14:03:09 +01:00
父节点 09d675b5fc
当前提交 328e98cb85
共有 2 个文件被更改,包括 154 次插入1 次删除

查看文件

@@ -29,4 +29,31 @@ gprMax produces a separate output file for each trace (A-scan) in a B-scan. This
where:
* ``basefilename`` is the base name file of the output file series, e.g. for ``myoutput1.out``, ``myoutput2.out`` the base file name would be ``myoutput``
* ``basefilename`` is the base name file of the output file series, e.g. for ``myoutput1.out``, ``myoutput2.out`` the base file name would be ``myoutput``
convert_png2h5.py
-----------------
This module enables a Portable Network Graphics (PNG) image file to be converted into a HDF5 file that can then be used to import geometry into gprMax (see the ``#geometry_objects_read`` command for information on how to use the HDF5 file with a materials file to import the geometry). The resulting geometry will be 2D but maybe extended in the z-(invariate) direction if a 3D model was desired. Usage (from the top-level gprMax directory) is:
.. code-block:: none
python -m tools.convert_png2h5 imagefile dxdydz
where:
* ```imagefile`` is the name of the PNG image file including the path
* ``dxdydz`` is the spatial discretisation to be used in the model
There is an optional command line argument:
* ``-zcells`` is the number of cells to extend the geometry in the z-(invariate) direction of the model
For example create a HDF5 geometry objects file from the PNG image ``my_layers.png`` with a spatial discretisation of :math:`\Delta x = \Delta y = \Delta z = 0.002`mm, and extending 150 cells in the z-(invariate) direction of the model:
.. code-block:: none
python -m tools.convert_png2h5 my_layers.png 0.002 0.002 0.002 -zcells 150
The module will display the PNG image and allow the user to select colours that will be used to define discrete materials in the model. When the user has finished selecting colours the window should be closed, whereupon the HDF5 file will be written.