Is there a feature to extract color statistics from an image layer and an area ?

jeroenDKjeroenDK Global Mapper UserPosts: 18Trusted User
edited May 2015 in Raster Data
Hi.

I'm trying to figure out roof colors on houses.
So I have an image layer, and and a shapefile containing the houses, as areas.
Is there a feature similar to 'Calculate Elevation/Slope stats for Selected Feature(s)', but for color information instead ?

Kind regards
Jeroen

Comments

  • Jasmine_BMGJasmine_BMG BMG Staff Posts: 174
    edited June 2014
    Hello Jeroen,

    There are some options for procuring information from the raster values in Global Mapper using imagery. What data are you using?

    Regards,

    Jasmine
  • jeroenDKjeroenDK Global Mapper User Posts: 18Trusted User
    edited June 2014
    Hi Jasmine.

    Im using and esri shapefile containing the outlines of the houses.
    and the imagery is aerial photos, either from a wms server, or geotiffs.

    I can see that global mapper is already outputting the rgb value in the lower left corner, can i somehow get my hands on this value, from script or via the menues ?


    BR
    jeroen
  • global_mapperglobal_mapper Administrator Posts: 17,238
    edited June 2014
    Jereon,

    I've created a todo item (#13872) to find color statistics just like the elevation statistics for an area. What type of color information would be most useful? Perhaps the average color of all pixels in the area, or color of center pixel, or some other metric?

    Thanks,

    Mike
    Global Mapper Guru
    geohelp@bluemarblegeo.com
    Blue Marble Geographics for Coordinate Conversion, Image Reprojection and Vector Translation
  • RobertRRobertR GlobalMapper Fan! Posts: 284Trusted User
    edited June 2014
    Hello all,
    I will step into this discussion and add a few notes on this (great) suggestion.
    I am using another software to generate statistics on colors (aka: to know which color <RGB works fine for me> is most present in a certain area);

    So at least for me, it would be great if Global Mapper could:

    1. calculate which is the most present color (RGB) on the raster for/inside a selected area (for eg: an overlapped area shapefile);

    2. calculate which is the most present color (RGB) on the raster for a set of points that have the same id (for eg: an overlapped shapefile of points); I often use a matrix of points.

    This helps because often the colors on the raster map/pdf do not match the ones in the legend. If they would, based on color, it would be easy to add the description from the legend directly into the shapefiles dbf. Because they don't, somehow we have to figure out what is the correspondent of a label in the legend, on the map.
  • jeroenDKjeroenDK Global Mapper User Posts: 18Trusted User
    edited June 2014
    Hi again.

    From my experience with the elevation statistics, it seems that the median and quartiles are the most stable values, but average would probably also be useful.

    Regards
    jeroen
  • Jasmine_BMGJasmine_BMG BMG Staff Posts: 174
    edited June 2014
    Hi RobertR,

    Thank you for your input, I have appended the todo item (#13872) to include your suggestions as well. Additionally, I have added Jeroen's request for median and quartile values, in addition to average.

    Regards,

    Jasmine
  • bmg_bobbmg_bob Global Mapper Programmer Posts: 1,681
    edited January 2015
    Hello,

    I am looking at implementing the functionality requested in this thread. The calculation of most present color is pretty straightforward -- count the number of occurrences of each RGB value and report back the largest value. The average, median, and quartiles are a little less clear. It is easy enough to perform those calculations from a set of RGB values, but it is not clear to what extent the results will be meaningful. Those types of statistics are usually used on data that represents a range of values, such as age, home values, income, etc., where one is trying to learn something about the population as a whole, but it doesn't seem that RGB color values work in this same way.

    Could one of the users who requested this provide some clarification? Thank you very much.

    Cheers,

    Bob
  • jeroenDKjeroenDK Global Mapper User Posts: 18Trusted User
    edited March 2015
    Hi bob.

    Sorry, I haven't been on the forum for some time.
    Like I wrote, I wanted to determine the colors of roofs, from satelite imagery.
    In my imagery there is a big difference in the color, on the different faces of the roof, depending on the position of the sun, when the image was taken, so I think some kind of average color would suit my needs best.

    Would simply averaging the R,G and B components of the roof pixels give a meaningful result ?

    Best Regards
    Jeroen
  • jeroenDKjeroenDK Global Mapper User Posts: 18Trusted User
    edited May 2015
    I did a quick test in paint.net, and it seems to me, that the average value would be good enough for my needs.
    I'm going to use the calculated average for selecting a suitable roof texture for the 3d model in the simulation software.

    BR.
    jeroen
    jeroenDK wrote: »
    Hi bob.

    Sorry, I haven't been on the forum for some time.
    Like I wrote, I wanted to determine the colors of roofs, from satelite imagery.
    In my imagery there is a big difference in the color, on the different faces of the roof, depending on the position of the sun, when the image was taken, so I think some kind of average color would suit my needs best.

    Would simply averaging the R,G and B components of the roof pixels give a meaningful result ?

    Best Regards
    Jeroen
  • bmg_bobbmg_bob Global Mapper Programmer Posts: 1,681
    edited May 2015
    Hello Jeroen,

    Thank you for the update. I have added this information to the feature request. We will post a message to this thread when the status of the request changes.

    Cheers,

    Bob
  • mattpwalkermattpwalker Global Mapper User Posts: 4
    Was this feature ever implemented?
    I have a use case similar to the OP which I'm keen to proceed with 
  • bmg_bobbmg_bob Global Mapper Programmer Posts: 1,681
    Was this feature ever implemented?
    I have a use case similar to the OP which I'm keen to proceed with 
    Hello,

    This has not been implemented yet.

    Cheers,

    Bob
  • mattpwalkermattpwalker Global Mapper User Posts: 4
    Ok, in the spirit of information share, QGIS have a plugin called zonal statistics which achieves the desired result. https://docs.qgis.org/2.2/en/docs/user_manual/plugins/plugins_zonal_statistics.html
  • bmg_bobbmg_bob Global Mapper Programmer Posts: 1,681
    Hello,

    We have implemented functionality for calculating color statistics within an area feature.  This enhancement will be in Global Mapper 18 daily builds dated October 25, 2016, or later (tomorrow, as of this posting).  Simply download the appropriate installer and run it to install the latest build.  If you have any problems or feedback, please post a message here.

    New Digitizer context menu item is available is:

      Analysis/Measurement | Calculate Color Statistics in Selected Area(s)
      Attribute/Style Functions | Calculate Color Statistics in Selected Area(s)

    New Dialog: Color Statistics Options

    Use a slider to select how close colors must be to be declared a "match".  If the you choose "Exact" (0), then the stored color values must match exactly.  Any other value allows for slightly different colors to be considered the same.  The usefulness of this depends on the type of data being analyzed.  For example, if your are attempting to determine the roof color for building footprints, then you would most likely want a non-zero similarity number, since many colors that look the same vary slightly in their internal representation.

    Output:

    Global Mapper will add the following attributes to each area feature:
      MOST_PRESENT_COLOR - this is the RGB value that occurs the largest number of times within the area feature.
    In the following attributes, the values are calculated separately for the Red, Green, and Blue components of the colors.  
      AVG_RGB          - The average Red, Green, and Blue color values.
      MODE_RGB         - The mode.
      1ST_QUARTILE_RGB - The first quartile value.
      MEDIAN_RGB       - The median
      3RD_QUARTILE_RGB - The 3rd quartile
    

    Cheers,
    Bob
  • RobertRRobertR GlobalMapper Fan! Posts: 284Trusted User
    Awesome!
  • Helio. Why this function is no more no digitizer menu?
  • Anybody please
  • JeffH@BMGJeffH@BMG Global Mapper Developer Posts: 266Trusted User
    Hello Diggopaiva,

    You need to have imagery loaded, and an area feature selected before the function appears in the digitizer menu. Hope that this helps.

    best regards,

    ~Jeff
Sign In or Register to comment.