Results 1 to 7 of 7

Thread: Changing the grayscale range within a height map

  1. #1

    Default Changing the grayscale range within a height map

    Hello, I'm new to the forums. It seems there's far more info here than I can quickly process. I did a search, but I didn't find what I was looking for, so maybe someone here can help.

    I'm creating 8 bit grayscale .bmp files for a free game called Armored Brigade. http://www.armoredbrigade.com/

    The game reads a grayscale .bmp file and assigns the height (in Meters) to the value for each pixel. For example, if a pixel has a grayscale value of 155, then the elevation is 155 Meters.

    My problem is that every random terrain generator tends to assign the value 0 (black) to the lowest elevation, and 255 (white) to the highest elevation, thereby making every single map between the elevations of 0-255.

    For example, if I create a random heightmap in Terragen or L3DT setting the vertical range as 50 to 155 Meters, the program still creates a grayscale map with the lowest point a black (0) and the highest as white (255).

    If I want my actual map vertical range between 50 and 155 Meters, how do I convert a greyscale 8 bit .bmp map from 0-255 to 50-155?

    I'm hoping something in Wilbur can do this.

    I'm sorry if this is a double-triple post but I'm having real issues submitting this thread

  2. #2

  3. #3
    Administrator Redrobes's Avatar
    Join Date
    Dec 2007
    Location
    England
    Posts
    7,193
    Blog Entries
    8

    Default

    Thats not a problem. The easiest is with a graph tool but I am familiar with PSP not Gimp or PS but I would imagine they have one too. This graph tool is one where you can draw a curve (set points and it interpolates the line) for the input and it will scale the luminance to the output.

    By setting the curve such that its a two point straight line where 0 goes to 50 and 255 goes to 155 it will directly convert that map to your requirements.

    If you dont have one of those then its easier to get it by first getting the range correct then by setting the brightness. So first of all you would drop the contrast from (255 - 0) = 255 to (155 - 50) = 105. Thats a 105/255 drop which is 41% of original. That in most application terms is a -59% contrast adjust. Then you would have an image which is of that new range but it offsets it by default around the mid grey mark. So it ought to be 128 +/- 52. So you need to drop it by another 26 to get it to 50 to 155.

    Like I said - the graph tool does it all for you tho. No messin'.

    You might want to think about using 16bit heights to prevent the banding that will occur. And b) you can try my totally free 3D visualizer for height map data. Save the image as Height.bmp (or PNG) and then run the app in the same dir as the image.
    Last edited by Redrobes; 10-02-2011 at 05:25 PM.

  4. #4
    Administrator waldronate's Avatar
    Join Date
    Mar 2007
    Location
    The High Desert
    Posts
    3,549

    Default

    Wilbur can do this, but it's a little convoluted to get your mapping. The first step is to set a shader that will map altitude directly to color (done as a code block to make the indentation stay):
    Code:
    Do Texture>>Shader Setup  to bring up the Lighting Settings property page
        Select the General Tab
            Select Display Type as Height Code.
        Select Altitude Tab
            Turn on Absolute Coloring
            Set Altitude Max to 255
            Set Altitude Min to 0
            Click Color List on the Land side to bring up the Edit Color List dialog
                Hold down Shift and click Remove to clear the color list
                Click Add... and select Black (RGB 0,0,0)
                Click Add... and select White (RGB 255,255,255)
                Click OK to accept the Edit Color List changes
            Click OK to accept the Lighting Settings changes. Your surface should appear as grayscale with 0 as black and 255 as white.
    If you need to remap your surface to a particular range of values (let’s say that another image editor has adjusted your data to the range 0 to 255 and you want it to the range 50 to 155), then use Filter>>Mathematical>>Span and enter your desired high and low values (50 and 155 in this case). After clicking OK, your surface will be displayed as you wanted.
    Save the texture using File>>Save As and set File Type as BMP Texture or PNG Texture. It’s the texture that you want here, not the surface.
    Last edited by waldronate; 10-02-2011 at 05:25 PM.

  5. #5
    Community Leader Facebook Connected Ascension's Avatar
    Join Date
    Jun 2008
    Location
    St. Charles, Missouri, United States
    Posts
    8,392

    Default

    In Photoshop go to Image - Adjustments - Curves.
    If the radiance of a thousand suns was to burst at once into the sky, that would be like the splendor of the Mighty One...I am become Death, the Shatterer of worlds.
    -J. Robert Oppenheimer (father of the atom bomb) alluding to The Bhagavad Gita (Chapter 11, Verse 32)


    My Maps ~ My Brushes ~ My Tutorials ~ My Challenge Maps

  6. #6

    Default

    Wow! thanks for the quick replies!

    First of all, using the curves approach works! Never was sure what that was for . . .

    The Wilbur solution works too!

    By the way, I'm using Paint.net and it has an adjustment>curves option. I use GIMP also, but whenever possible I stick to the simpler tool.
    Last edited by Sam101; 10-02-2011 at 10:49 PM.

  7. #7
    Community Leader Facebook Connected Steel General's Avatar
    Join Date
    Jun 2008
    Location
    Ft. Wayne, IN
    Posts
    9,530

    Default

    Welcome Aboard!
    My Finished Maps | My Challenge Maps | Still poking around occasionally...

    Unless otherwise stated by me in the post, all work is licensed under a Creative Commons Attribution-Noncommercial 3.0 United States License.



Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •