ascent icon indicating copy to clipboard operation
ascent copied to clipboard

PNG Metadata

Open WillTrojak opened this issue 2 years ago • 9 comments

Would it be possible to add something to the scene API that allows metadata to be written to PNGs? Additionally, would it be possible for a flag that causes a map from value to colourmap colour to be written to the metadata?

The idea of this is twofold, it would allow for PNG files to be more accurately post-processed, with the colour map being handy for training ML/dataset curation. The second thing would be to improve reproducibility, for example in PyFR we would like to write parts of the config/inifile and stats to the png.

WillTrojak avatar Jun 07 '23 10:06 WillTrojak

A similar feature is now supported in Paraview: https://www.kitware.com/paraview-state-embedded-in-png-screenshots/

WillTrojak avatar Jun 07 '23 11:06 WillTrojak

This is a great idea! I had previously looked into adding more info to PNGs, but it was not as straightforward as I had hoped, so I tabled it.

I will look into this again!

nicolemarsaglia avatar Jun 08 '23 18:06 nicolemarsaglia

Looking into this, in the meantime, one thing Ascent does have in an info() call in the API that populates a conduit node with metadata rather than the PNG, and can be used in a similar way: https://ascent.readthedocs.io/en/latest/AscentAPI.html?highlight=info#info

nicolemarsaglia avatar Jun 08 '23 20:06 nicolemarsaglia

I added the ability to add meta data to PNGs with the following PR.

https://github.com/Alpine-DAV/ascent/pull/746

If you add specific conduit nodes under the state, it will add those strings to the PNG meta data. Specifically:

state/software state/source state/title state/info state/comment

brugger1 avatar Jun 08 '23 20:06 brugger1

Thanks @brugger1

edit: Definitely needs to be documented.

nicolemarsaglia avatar Jun 08 '23 21:06 nicolemarsaglia

Yes, the PR didn't have any documentation associated with it. :(

brugger1 avatar Jun 08 '23 21:06 brugger1

This is great, thanks @brugger1. I'll give it a go!

WillTrojak avatar Jun 09 '23 07:06 WillTrojak

@WillTrojak if you are creating images for ML datasets, you might be interested in scalar rendering -- which you can use to save an image out to a HDF5 file and preserve the floating point data.

https://ascent.readthedocs.io/en/latest/Actions/Examples.html?highlight=scalar#an-example-of-scalar-rendering

cyrush avatar Jun 14 '23 19:06 cyrush

I have been looking into this for a partitioned mesh, and it seems that the current metadata implementation in #746 doesn't work on meshes with multiple domains. ie it works on

state:
    stuff: ...
coordinates:
    x: ...

but it doesn't work on:

domain_0:
    state:
        domain_id: 0
        stuff: ...
    coordinates:
        x: ...
domain_1:
    state:
        domain_id: 1
        stuff: ...
    coordinates:
        x: ...

I'd be happy to implement this, but I need a bit of direction from the ascent team. The most straightforward choice to me is to only output the metadata from the first domain child which is sort of the root rank (ie. m_source.child(0)) and this could be done in the PopulateMetadata function. What are your thoughts?

WillTrojak avatar Sep 08 '23 12:09 WillTrojak