POV-Ray : Newsgroups : povray.binaries.images : Strangely low eval_pigment() values... : Strangely low eval_pigment() values... Server Time
31 Jul 2024 00:27:35 EDT (-0400)
  Strangely low eval_pigment() values...  
From: Jörg 'Yadgar' Bleimann
Date: 24 Oct 2010 17:54:40
Message: <4cc4ab20@news.povray.org>
High!

I recently started preparing for building Khyberspace (= POVghanistan) 
in earnest... I downloaded some SRTM Earth elevation data tiles of 
south-western Afghanistan, converted them to ASCII terrain matrices 
using 3DEM, and then (as 3DEM is not able to correct error pixels when 
they are adjacent to the tile's edges) convert them into 16-bit PNG 
heightfields using a self-programmed POV-Ray script.

Then I stitched together two of these heightfield tiles with error 
pixels (marked in blue by my POV-Ray script) and cut out a 1200 x 1200 
square tile from the mid-section of these combined tiles (attached 
below) which in turn I tried to re-convert into an ASCII matrix readable 
to 3DEM (to more conveniently clean up the remaining error pixels).

But my "png2ascii" script wrote strange values into that ASCII file - 
elevations are far too low, instead of some 350 metres below sea level, 
they should be around 500 metres above sea level! I checked the color 
vector output of eval_pigment(), and in fact the function returned red 
values between 0.01 and 0.05, where it should have been between 0.09 and 
0.16!

What went wrong with eval_pigment()?

Here is the code:

// Converting PNG 16-bit heightfields into SRTM ASCII terrain matrices

// Non-commercial use is free; any commercial usage needs written 
authorization by the copyright owner

#include "functions.inc"

#declare xdim=1200;
#declare ydim=1200;

#declare deadsea=422;
#declare everest=8848;
#declare rng=everest+deadsea;


#declare hf=
pigment
{
   image_map
   {
     png "../png_half_patched/n29e061-5.png"
   }
}

#fopen srtm "n29e061-5.txt" write
#declare b=0;
#while (b<ydim)
   #declare a=0;
   #while (a<xdim)
     #declare cv=eval_pigment(hf, <1/(xdim*2)+a*(1/xdim), 
1/(ydim*2)+b*(1/ydim), 0>);
     #warning vstr(3,cv,",",3,2)
     #declare h=rng*(cv.red+cv.green/256)-deadsea;
     #write (srtm, str(h, 1, 2), " ")
     #declare a=a+1;
   #end
   #declare b=b+1;
#end
#fclose srtm

camera
{
   orthographic
   up <0, ydim, 0>
   right <xdim, 0, 0>
   location <xdim/2, ydim/2, -10>
   look_at <xdim/2, ydim/2, 0>
}

// end of code

See you in Khyberspace!

Yadgar


Post a reply to this message


Attachments:
Download 'n29e061-5.png' (1069 KB)

Preview of image 'n29e061-5.png'
n29e061-5.png


 

Copyright 2003-2023 Persistence of Vision Raytracer Pty. Ltd.