There are equations for greyscale and there isn’t one right way to do it. There is typically 4 common schemes. I have a Grayscale Color component in Pufferfish with them but since I assume you want some code, check out the section of this page called “Luma Coding in Video Systems” for the different common weighted average schemes: https://en.m.wikipedia.org/wiki/Grayscale
Grayscale isn’t what is really needed. One needs to map the different colors to the different height values. Color ramp / multistop gradient can help you interpolate.
Yes, exactly.
The problem is the number of colors. It is not based on luminescence or luminosity do not know the correct term here .
I tried even to reduce the colors by playing around with gimp, but still when I tried to scan it with Python the number of colors is huge.
Can you also attach the original image?
I tried, but it’s 40 mb
Update:
Do you mean original colors or original full-sized image with reduced colors?
Here are all my attempts:
map.7z (16.2 MB)
the file tst2inv.png I got closer to what I want, but all rivers become mountains
Just original colors, not necessary the size. But I’ll get your zip and show something what I mean. You can take it from there (:
Hi Ivelin; As colors could be transformed to point in a cube with {-1,-1,-1,} and {1,1,1} extremities, you could first draw a curve representing the gradiant and then at each parameter of the curve affect a greyscale. If not precise you could use GraphMapper.
See there
Thanks @laurent_delrieu,
I did not think of using gradient component.
I simply used the image sampler.
I’ll try to combine somehow both.
I’m puzzled.
How does a simple mesh component contain colors?
I have no experience of mesh and I don’t know its properties, but having color in it, how?
A mesh can have color at Vertex in Rhinoceros/Grasshopper.
For your image you can use that
Then look at the points. The hard work is here and for this case it is not so simple …
Maybe it would be easier to find another file with the height information directly encoded rather than trying to back calculate it?
while this looks like an interesting problem, why not just use other sources?
your map seems to be simple elevation data… here is a nice 16 bit grayscale tiff source:
http://www.shadedrelief.com/natural3/pages/extra.html
and if you need better data get an account (free) for: https://earthexplorer.usgs.gov/
there you can download all kinds of high res raw satellite data
even if you would manage to convert your color map, the loss of precision will be so great, not sure it is worth it
Hi @atair,
The reason I want to do this is because all already grayscaled images about elevations I found contain only data for the land, not the underwater topography.
The sea is always the same level. And if you try to create a 3d model it doesn’t look ok.
Hi Graham,
How would this file look like? Is there specific format that contains this kind of data?
here is a full map with ocean floor:
http://naciscdn.org/data/cleantopo/Full.zip
be sure to run some image filters like auto-level on it before using it - image samplers in grasshopper / rhino only work on 8bit precision
here is how it looks like (edited crop):
That image is viewed from an angle.
I am saying this because some satelite images contain shadows. That is impacting the result
its not. it is Plate Carree aka Geographic or LatLong
with a bit of math (wikipedia!) you can make it any projection you want
regarding the shadows - also no.
Ivelin, I encouter the same ptoblem as you. I ended using a, image similar to the one from Atair.
For projecting on an earth with unit in kilometer I do that. In order to have good longitude, a rotation of 180° is necessary. The 0 of longitude is on the middle.
For the elevation I managed to do that. Not super precise, but the mesh was heavy
You all have similar problem to mine.
No idea how to transform into Grayscale
original colour scale I guess is that: and wanted scale looks like this:
but not this:
Hello here a solution.
The trick is to transform the color to coordinate. 0 to 255 becomes automatically -1 to 1 in Grasshopper.
So I draw a line on each Gradient, divide each line in N points.
This look like to this.
Then I deconstruct your image. Find the closest color in first gradient. The closest points gives also an index that I use to get the color in second gradient.
“Et voilà”.
The only problem is that the automatic color to point gives [-1 to 1] and the Color from RGB uses [0 to 1] value. It is not very consistant.
Your initial image colors
Strictly related: