L3DT users' community
Large 3D terrain generator

Problems exporting heightmap as PNG-16 bit

Got a problem or need advice?

Problems exporting heightmap as PNG-16 bit

Postby ale870 » Tue Sep 15, 2009 10:29 pm

Hello, this is my first post here. I'm using L3DT to make a terrain for my game (made in Shiva 3D engine).
Now the problem is I need an heightmap 16-bit gre scale.
I tried many times, but after the export I always get an 8-bit PNG image.
Can you help me please?

I cannot proceed without this map!

Thank you for your help!
ale870
New member
 
Posts: 7
Joined: Tue Sep 15, 2009 10:26 pm

Postby Aaron » Wed Sep 16, 2009 12:55 am

Hi ale870,

The PNG exporter should default to 16-bit. Please send one of your exported files to to aaron@bundysoft.com so that I can have a look.

If, somehow, the PNG exporter has been switched into 8-bit mode, you can correct this in the export wizard by selecting the PNG format in the drop-list, then pressing the 'options' button, and then double-clicking on the 'bit depth' entry to set it to 16-bit.

Best regards,
Aaron.
User avatar
Aaron
Site Admin
 
Posts: 3696
Joined: Sun Nov 20, 2005 2:41 pm
Location: Melbourne, Australia

Postby ale870 » Wed Sep 16, 2009 5:03 pm

Hello,

I just sent you my png file. I hope you can help me.

THank you!
ale870
New member
 
Posts: 7
Joined: Tue Sep 15, 2009 10:26 pm

Postby Aaron » Wed Sep 16, 2009 9:54 pm

Hi Ale870,

Thanks for the PNG file. The PNG file is indeed 16-bit, and includes values from 0 to 65534 (thus definitely not 8-bit). Furthermore, the histogram shows there are no 8-bit stepping artefacts. What are you using to load the PNG file? Are you converting or resizing the image in any other program?

Best regards,
Aaron.
User avatar
Aaron
Site Admin
 
Posts: 3696
Joined: Sun Nov 20, 2005 2:41 pm
Location: Melbourne, Australia

Postby ale870 » Wed Sep 16, 2009 10:44 pm

IrfanViewer, xnView, PictureMan, and Shiva engine say (everyone) that such file is 8 bit. I will send you, via email, some screenshots.
Filename of PNG file is "test.png".

http://download302.mediafire.com/djdjmlmzdydg/bnhmn1v12hm/TEST_PNG.zip

That ZIP file contains the file open with irfanview and xnview. As you can see, they say it is a 8 bit file.

One thing more: I converted it to tiff 16bit, and imported in shiva engine. The terrain contains the "stairs" (effect caused by 8bit image).

Please check it. Thank you for your help!
ale870
New member
 
Posts: 7
Joined: Tue Sep 15, 2009 10:26 pm

Postby ale870 » Wed Sep 16, 2009 11:06 pm

Update: I create 5 screenshots of the heightmap creation process. It is a zip file (about 700Kb) which contains 5 self-explicative screenshots.
Please look at them.

Thank you!

http://www.mediafire.com/download.php?mytjcb13izy
ale870
New member
 
Posts: 7
Joined: Tue Sep 15, 2009 10:26 pm

Postby Brad789 » Thu Sep 17, 2009 2:27 am

I had a similar problem when searching for a program to edit 16 bit heightfields. Many programs open the file fine but convert it to 8 bit on import. I checked out XnView and it says it's 8 bit even though it's 16. If you're in Vista you can right click on a image file and click on properties, then click on details and you will see Bit Depth as 16 on the png files. You might be able to do that in XP too I'm not sure. Anyways, I can send you a program I whipped up that will convert 16 bit grayscale pngs to 16 bit tiff's if you're comfortable using the command line.

Brad
Brad789
New member
 
Posts: 7
Joined: Fri Jul 24, 2009 6:27 am

Postby ale870 » Thu Sep 17, 2009 7:32 am

Hello,

I know what you say, for in my case the problem is not the conversion (I use Picture Pro, which works/convert to TIFF-16 bit grey, the format I need). But I cannot convert to 16bit an image in 8bit PNG (well, I can convert it, but 8bit image contains data with a 0..255 values in range, instead PNG 16bit works on 0..65535 values range).
My PNG image (generated by L3DT) is 8 bit. I'm sure. I checked it in IrfanViewer, xnView, and Picture Pro: all of them say that is an 8 bit image :(
ale870
New member
 
Posts: 7
Joined: Tue Sep 15, 2009 10:26 pm

Postby Aaron » Thu Sep 17, 2009 9:09 am

Hi Ale870,

I think the problem here is that you are testing for 16-bit files in programs that automatically convert 16-bit images to 8-bit layers.

It is, for example, a known feature of IrfanView that it converts 16-bit files to 8-bit. IrfanView will tell you as much in the 'image properties window', where it states that the original colours in your file are 16-bit.

Image

Photoshop CS2 does however properly load your image and keep it at 16-bit precision:

Image

..as does the Opera web browser, strangely enough:

Image

...and finally, if I import your PNG file back into L3DT and render it in the 3D viewer, I get no 8-bit stepping:

Image

Here's a closer look:

Image

The sad fact is that most image editors represent images in memory as 8-bit colour channels (so 8-bit if greyscale, or 24-bit if RGB). Thus, even if they can import or export 16-bit greyscale files, they nonetheless have crunched the 16-bit data down to 8-bit data. L3DT internally stores heightmaps at 32-bit floating-point precision, and therefore avoids this problem.

For converting 16-bit PNG files into 16-bit TIFF files, I would recommend Photoshop, as it does this correctly.

Best regards,
Aaron.
User avatar
Aaron
Site Admin
 
Posts: 3696
Joined: Sun Nov 20, 2005 2:41 pm
Location: Melbourne, Australia

Postby ale870 » Thu Sep 17, 2009 11:50 am

Ok, thank you. I understand what you say. The problem is I didn't save that image with IrfanView! test.png is the original image L3DT created.
In the link you sent me (in IrfanView Forum) they talk about "saved images":

I work a lot with 16-bit TIFF files (coming from a microscope CCD camera), which IrfanView can open. But when these files are saved (having made modifications or using batch rename etc.), they are converted to 8-bit.


Well, please help me to take another way. I haven't money to buy Photoshop (furthermore I'm a programmer, even if I buy it I will never heavily use it). So can you suggest me another program to make that conversion? I used Picture Pro, which works with 16 bit images, but when it load image test.png it show 8-bit image. Very strange...

One more test (last one): please can you create a png file with L3DT and send me that? (maybe I have some problems with one internal DLL or shared DLL, etc...).

Thank you again for your support.
ale870
New member
 
Posts: 7
Joined: Tue Sep 15, 2009 10:26 pm

Postby Rofar » Thu Sep 17, 2009 9:57 pm

A free (open source) alternative to Photoshop is The Gimp. Also, Paint.NET is a nice lighter weight program that should be able to do it.
Rofar
Luminary
 
Posts: 51
Joined: Tue Nov 22, 2005 10:48 pm
Location: South Carolina

Postby ale870 » Thu Sep 17, 2009 10:29 pm

Update:

About your suggestions (alternatives to Photoshop): thank you, but those programs cannot manage 16-bit greyscale channels.

The only alternative (not free, but cheap) I found is PicturePro.

About the "problem" of 16bit: well, I followed your suggestions (I checked image with irfanview with "image information"), and you are right: irfanview shows the colors it is showing, not real internal color structure. It is true even if I didn't save the image.

So, I made this workflow:

1) make terrain in L3DT
2) Save in PNG 16 bit.
3) Load in Picture Pro, and convert to 16 bit greyscale (as TIF image, since I need that format).
4) Load in my Shiva 3D engine.
5) Applied some scale factors and smooth algorithhms.

It supply good results for my game!

Thank you again!
ale870
New member
 
Posts: 7
Joined: Tue Sep 15, 2009 10:26 pm

Postby Aaron » Thu Sep 17, 2009 10:44 pm

Hi Ale870,

Rofar wrote:A free (open source) alternative to Photoshop is The Gimp. Also, Paint.NET is a nice lighter weight program that should be able to do it.


Oops, not true. Paint.NET and the GIMP do not support 16-bit colour depth, and both will convert 16-bit files to 8-bit [This was tested with GIMP v2.4.5 and Paint.NET v3.36.]

ale870 wrote:The problem is I didn't save that image with IrfanView! test.png is the original image L3DT created.


This I know. The 'test.png' file you sent me is the one I tested in Photoshop, Opera, IrfanView, and L3DT itself, and they all reported that the file is 16-bit (although IrfanView converted it to 8-bit in memory, as is its wont). By the way, as Brad mentioned, Vista also thinks your 'test.png' file is 16-bit:

Image

In conclusion, the file exported by L3DT was 16-bit. If it ended up with 8-bit stepping, it's probably because Picture Pro converted the image to 8-bit in memory before saving it out as a 16-bit TIFF.

ale870 wrote:Well, please help me to take another way. I haven't money to buy Photoshop (furthermore I'm a programmer, even if I buy it I will never heavily use it). So can you suggest me another program to make that conversion?


ImageMagick seems to be able to convert files at 16-bit precision (see this forum thread). It's a command-line program, but it is excellent.

ale870 wrote:One more test (last one): please can you create a png file with L3DT and send me that? (maybe I have some problems with one internal DLL or shared DLL, etc...).


It won't be any different to the file you created in L3DT, which was also 16-bit. But for completeness, here you go:

Image

The same programs that told you that your test.png file was 8-bit will also now tell you that the above image is 8-bit too. They are wrong, for the reasons we've explained. If you'd like to prove this to yourself, I recommend you download libpng and read the PNG file header yourself.

For the sake of comparison, here is the same image saved as 8-bit. Note that the 16-bit image is 365kB, whilst the 8-bit file is only 57kB.

Cheerio,
Aaron.
User avatar
Aaron
Site Admin
 
Posts: 3696
Joined: Sun Nov 20, 2005 2:41 pm
Location: Melbourne, Australia

Postby Rofar » Fri Sep 18, 2009 9:28 pm

Sorry for the bad info guys. I just assumed they did.
Rofar
Luminary
 
Posts: 51
Joined: Tue Nov 22, 2005 10:48 pm
Location: South Carolina


Return to Help and support

Who is online

Users browsing this forum: No registered users and 62 guests