red-blue heightmap convert to greyscale?

Started by Dune, August 25, 2015, 12:11:00 PM

Previous topic - Next topic

Dune

I have a red (heights) to bluish (lows) heightmap which I would like to convert to greyscale heightfield. What would be the best approach, any advice?

AP

If your red is more dark then your blue then invert the image after your convert it to black and white. If it where already grey scale the red looks like a darker grey while the blue looks lighter. Inverting it makes the red the lighter grey

mhaze

I think black and white in PS gives you the option to play with colour and greyscale.  Image>Adjustments>Black and White

AP

Correct, there is brightness-contrast, levels, curves, gamma, exposure, channel mixer, selective color, shadows and highlights.

AP

I took a small chunk of your image, converted it to back and white and then inverted it.

Kadri


There is a high indicator in the image. Chris not sure but i think some parts are different in your image. 
The best would be first to convert the image to a real 16 or even 32 bit HDR image.
Ulco could be done with a standard 8 bit image maybe but a higher bit one would be better maybe.
There might be users around who use these kind of things i think.
Curious too what the best approach would be.


AP

I should have asked this sooner but what format is the height field in for one thing?

I inverted the colors if that is what you mean.


Kadri


If the red parts on the right above side are high ground and the river the lower part then the river should be black for example.

Matt

Judging by the height legend, anything between red and dark green could probably be extracted from the Hue channel, if you can convert the image to HSL or HSV. Below dark green, where it stays greenish but becomes lighter, I would try using the luminance channel, but it'll take some experimentation.

Matt
Just because milk is white doesn't mean that clouds are made of milk.

AP

HSL or HSV and luminance seems like an good idea as well. There seems to be a few interesting ways to approach this.

Even adding a gradient map to the black and white conversion might be useful. The gradient could be adjusted accordingly so the the rivers are black and the highest elevation can be adjusted to one's liking, medium grey or pure white for example.

Kadri


Played with the RGB channels by copying them one by one to a new image.
Took them together with different blending modes just by look.
So it is not accurate of course and could be made better.

Not sure but the blue channel itself looked very close to what it should like (to me).

[attachimg=1]


Dune

#11
Thanks for all your input, guys. This should work different from a standard conversion, as you see in Chris' version the deepest are lighter than middle ground. I found some algorithms on the web. To have an accurate conversion there should be a constant way; I'll do some experimenting.

This is what I found:

Gray RGB color code has equal red,green and blue values:

R = G = B

For each image pixel with red, green and blue values of (R,G,B):

R' = G' = B' = (R+G+B) / 3 = 0.333R + 0.333G + 0.333B

This formula can be changed with different weights for each R/G/B values.

R' = G' = B' = 0.2126R + 0.7152G + 0.0722B

Or

R' = G' = B'  = 0.299R + 0.587G + 0.114B


Example

Pixel with RGB values of (30,128,255)

The red level R=30.

The green level G=128.

The blue level B=255.

R' = G' = B' = (R+G+B) / 3 = (30+128+255) / 3 = 138

so the pixel will get RGB values of:

(138,138,138)
----------------
Second option:

If each color pixel is described by a triple (R, G, B) of intensities for red, green, and blue, how do you map that to a single number giving a grayscale value? The GIMP image software has three algorithms.

The lightness method averages the most prominent and least prominent colors: (max(R, G, B) + min(R, G, B)) / 2.

The average method simply averages the values: (R + G + B) / 3.

The luminosity method is a more sophisticated version of the average method. It also averages the values, but it forms a weighted average to account for human perception. We're more sensitive to green than other colors, so green is weighted most heavily. The formula for luminosity is 0.21 R + 0.72 G + 0.07 B.

You're method looks pretty good, Kadri. I'll have a go also.

Tangled-Universe

What you basically need to do is remapping the values from that custom gradient to a greyscale gradient.

Interestingly and unfortunately there's plenty info on the web on how to remap a greyscale gradient to a false color gradient, but the opposite way is barely being described and involves tedious processes.

In Photoshop you can do this remapping also by using the Gradient Map tool, but you can't define gradients based on a pixel based image (of the custom gradient in your image).
Unless someone finds a way.

Dune

I followed a strange procedure; copied every channel to a layer, negated the red channel so dark red became light, then set the layers to multiply and the amounts 0.3R/0.6G/0.11B and after some repainting and softening got a decent map. But there should be a definite and easy way.
Still interested if anybody knows, but I think i'm gonna handpaint the map anyway as there's too much modern clutter on the map. I need ice age heights  ;)

Tangled-Universe

I found that the red channel itself resembled something which looks like a terrain the most.

Pity they used this custom gradient and that other sources are not available.