Tool to convert PNG images to HDF5

2,602 views
Skip to first unread message

Craig Warren

unread,
Apr 4, 2017, 9:31:31 AM4/4/17
to gprMax-users
Hi folks,

Based on some discussion on this forum I have created a module (part of the tools sub-package in gprMax) called convert_png2h5.py which is available if you pull the latest code from the master branch of GitHub.

The 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. 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.

Full info on how to use it is in the User Guide at: http://docs.gprmax.com/en/latest/utils.html#convert-png2h5-py

This is a new tool so it might be a bit rough around the edges. Feedback (and proposed changes) welcome!

I hope it is useful.

Kind regards,

Craig

Mohamed Elsaid

unread,
Aug 17, 2017, 6:13:45 PM8/17/17
to gprMax-users
Hi Craig,

Great efforts to introduce this module to us. when I try to use this module to convert PNG image to HDF5 file, there are problem appear in the implementing this conversion representing in the attached syntax error.
I don't know what's the problem. can you help me in understanding this error? and how I can solve this problem?


Regards,
Mohamed
SyntaxError.png

Craig Warren

unread,
Aug 18, 2017, 4:41:00 AM8/18/17
to gprMax-users
Looks like a problem with your PNG file name and/or path.

Craig

Mohamed Elsaid

unread,
Aug 19, 2017, 10:39:33 AM8/19/17
to gprMax-users
I checked o the file name and path, I'm sure that there's no mistake in it. may be in the last command I did't write the extension (PNG)of the file,
and I modify it and use the following command in the current directory of the gprmax
python -m tools.convert_png2h5 my_PMA.png 0.002 0.002 0.002 -zcells 150


and obtain the same syntax error. Now I'm sure that the name and the path are correct and still don't know the problem.
Can you help me? 

Thanks
Mohamed 

Craig Warren

unread,
Aug 20, 2017, 5:07:27 PM8/20/17
to gprMax-users
Hi Mohamed,

In which case can you report it (and attach the PNG file you are testing with) on our GitHub issue tracker please - https://github.com/gprmax/gprMax/issues This allows us to better track and respond to potential issue with the code.

Thanks,

Craig
Message has been deleted

Dongyang Liu

unread,
Mar 29, 2019, 4:05:03 AM3/29/19
to gprMax-users
Hi Craig:
          
        I have some question about the convert_png2h5.py , is there any more specific requirements about the png inputfile ? like dimensional proportion ? does the zoom of png file influence the output HDF5 file?

     
Kind regards,
           Dongyang

Craig Warren

unread,
Mar 29, 2019, 4:43:33 AM3/29/19
to gprMax-users
Hi Dongyang,

The size, i.e. pixel dimensions, of the image when multiplied by the spatial resolution you specify will determine the physical dimensions that the geometry will occupy in the model.

Kind regards,

Craig
Reply all
Reply to author
Forward
0 new messages