Make an image layer grayscale

3719
6
Jump to solution
09-29-2017 01:32 PM
NicholasLiccini
New Contributor II

Hi!

I would like to know if there is any way to take a basemap (e.g. Imagery) and make it gray scaled? Perhaps there is a workaround using a raster function or editing the contents of the image layer.

I've tried changing the brightness, contrast, and gamma for an ArcGISTiledLayer object but none of those settings seem to make the layer grayscale.

Any help is appreciated! Thanks!

Nick

0 Kudos
1 Solution

Accepted Solutions
LucasDanzinger
Esri Frequent Contributor

I think you have 3 main options to manipulate the look of the layer in ArcGIS Runtime:

- If the layer inherits ImageAdjustmentLayer, then use gamma, contrast, brightness. But it sounds like that is not what you need

- Author your data differently. In ArcGIS Pro or ArcMap, when you are creating your data, you could change the appearance of your data here, using a method like what Dan showed above

- Use shaders or play around with some other sort of client side rendering manipulation that Qt offers. For example, I have played around with the QML ShaderEffect type and our MapView, and have been able to see some cool effects applied to it - ShaderEffect QML Type | Qt Quick 5.9 

View solution in original post

0 Kudos
6 Replies
DanPatterson_Retired
MVP Emeritus

Essentially nothing in your environment makes an image gray scale unless the tools are built-in but you can make it so within your programming environment from rgb as

Essentially gray = 0.2989 * r + 0.5870 * g + 0.1140 * b

see

http://stackoverflow.com/questions/12201577/how-can-i-convert-an-rgb-image-into-grayscale-in-python 

https://en.m.wikipedia.org/wiki/Grayscale#Converting_color_to_grayscale

https://en.m.wikipedia.org/wiki/HSL_and_HSV

0 Kudos
NicholasLiccini
New Contributor II

Dan,

Thank you! I will look into those references. Is there a way to access RGB values of an ArcGISTiledLayer? If so, how could I got about changing those values?

0 Kudos
DanPatterson_Retired
MVP Emeritus

That you would have to wait for others.  I just provided some background on making rgb a single-band gray scale... not just look grayish

0 Kudos
LucasDanzinger
Esri Frequent Contributor

I think you have 3 main options to manipulate the look of the layer in ArcGIS Runtime:

- If the layer inherits ImageAdjustmentLayer, then use gamma, contrast, brightness. But it sounds like that is not what you need

- Author your data differently. In ArcGIS Pro or ArcMap, when you are creating your data, you could change the appearance of your data here, using a method like what Dan showed above

- Use shaders or play around with some other sort of client side rendering manipulation that Qt offers. For example, I have played around with the QML ShaderEffect type and our MapView, and have been able to see some cool effects applied to it - ShaderEffect QML Type | Qt Quick 5.9 

0 Kudos
NicholasLiccini
New Contributor II

Thank you for providing those options! For the moment I will work with the 3rd option (the QML types), but when I use the shaders (particularly the Desaturate item) it turns all of my drawn graphics to grayscale as well since I assume they are associated with the MapView item. Is there any way to separate the graphics and the map so that I could use the shader on just the basemap and not on the graphics?

Desaturate {
    anchors.fill: parent
    source: map
    desaturation: 1.0
}
0 Kudos
LucasDanzinger
Esri Frequent Contributor

No, not that I am aware of. This will alter the entire map view, including all layers and graphics inside of it.