WebPlotDigitizer icon indicating copy to clipboard operation
WebPlotDigitizer copied to clipboard

extracting data from colormaps?

Open sonebu opened this issue 3 years ago • 3 comments

Is it possible to use this tool for extracting data from 2D colormaps? An example of such a colormap, with its reference bar on the side:

bb

I tried doing this on the online tool, but failed to get the color values for the points that I marked on the graph:

tried

sonebu avatar May 14 '21 08:05 sonebu

This is an interesting idea. Right of the tip of my hat I think about maps about roughness of surfaces (recorded by e.g., a profilometer), but equally about response surfaces (as e.g., in statistical design of experiments) as a possible application.

I'm not sure if the digitizer already may perform such a task. However, a map with discrete levels in the third dimension probably is easier to digitize if the reference bar at the side equally reflects these discrete levels. At present, it looks more like this uses a continuous scale; this complicates an assignment in the map.

Based on the scale of the map shown by you (a geosurvey?), perhaps the entry on gis.stackexchange[1] pointing to GRASS GIS[2a, b] could be of immediate help for you now.

[1] https://gis.stackexchange.com/questions/220592/digitizing-in-grass-gis [2] a) https://grass.osgeo.org/ b) https://grasswiki.osgeo.org/wiki/WxPython-based_GUI_for_GRASS#Digitizer

nbehrnd avatar May 14 '21 10:05 nbehrnd

@nbehrnd thanks a lot for the detailed answer. I'll check the alternatives to see if I can twist them for my use.

However -> I haven't been able to find anything that does this automatically up to now, but I started to think the problem is a bit hard anyways. For example, one concern would be the one you mentioned about the colorbar being continuous. Other concerns could be: the colorbar can be anywhere on the image so it needs to be recognized, it can have black/white borders (whether or not they're part of the color scale can be ill-defined), ... so without an interface like the one that webplotdigitizer offers (which, I think, is amazing by the way, kudos to the devs :) ) the tool would need to be really intelligent in order to do anything useful.

I'm mainly interested in doing this for some papers published by some certain IEEE journals though, and people in those communities usually follow a certain format (and either use MATLAB or matplotlib), so I think I'll just write something that parses image-graphs like that for extracting such data, for the time being, if the alternatives you've mentioned don't work.

I don't know if you're an admin, but if you are -> I think you can close this issue for now since, as I understand, there are no plans for integrating something like this into webplotdigitizer in the foreseeable future. If I do end up writing something simple that parses the type of graphs I mentioned above (or if I can use the alternatives you've mentioned for this usecase), I'll re-open this and explain accordingly.

Thanks a lot


about the application: this is actually an antenna transmit pattern (power) measurement, so the scale units are dBm, and yes they are continuous. I think the applications you've thought of are also valid.

sonebu avatar May 14 '21 14:05 sonebu

In terms of the colorbar, related to the map, however continuous instead of (map matching) discrete, I assumed both were prepared simultaneously. I'm not sure if gnuplot allows the two schemes to diverge in this regard; however, matplotlib engaged by Python offers this degree of freedom. Maybe you are able to contact the author(s) to replot the map with an adjusted colorbar (and gently point to a documentation like this one).

Regardless of the outcome, I think it still is possible to extract some of the information from the original map because it uses colours. Especially if there are multiple maps using (on the canvas of the map) recurrent colours. The three ools you need for the following are ImageMagick, an editor capable to read-out the colour information of a pixel you determine in the map (e.g., inkscape), and the digitizer.

  • With inkscape's pipette tool, I determined for one of the patches on the canvas the hexadecimal colour code as #91be72.
  • On stackoverflow I found a contribution by Kurt Pfeifle *) how to address specific pixels in an image by their colour, and to alter their appearance. For example, to change

start

into this

example_grid_01 you issue an instruction in pattern of

convert example_A.png.svg -fuzz 3% -fill red -opaque "#91be72" example_red.png

You may recognize -fuzz 3% is about «colour tolerance» (similar to an option present in the digitizer) about the green the reference scale assigns about 25 a.u. Subsequently,

Option a) In the digitizer, you may then define a box on the canvas (to constrain digitizer's work to this area / to exclude the reference bar) and perform a digitization with a fine grid, intentionally decreasing the increments of about x and y:

example_grid02

Option b) The area of interest is filled with black. Using the pen tool, you manually run around the lobe in question, increase the increments about x and y and digitize around this trace to fence your region of interest:

black_02

This is a bit more laborious than option a) because there are multiple contour lines. It is up to you to add (A), delete (D), or adjust individual points to mark this frontier.

Because Imagemagick may be moderated by a script (possibly the digitizer equally does, too), option a) could allow to process multiple maps of this type. For documentation, I add two .zip archives about both options below.

*) Kurt Pfeifle has profound knowledge about ImageMagick (and ghostscript / .ps, .pdf); it is thought well invested to read his comments / see his tutorials.

As an occasional user of the digitizer, I contributed once to the documentation, without administration about this program.

example_grid.zip example_black.zip

nbehrnd avatar May 14 '21 17:05 nbehrnd