Added custom vector lambertian shading channel (up) and set factor of shadow depth...
[tecorrec.git] / NOTES
blob36b261c933089a7959c92e4fb7d0e56146c742d3
1 Efficient rendering of terrain elevation model
3 start with some top level cells
5 Thursday 20th Nov
6   terrain elev (errors)
7     naive interpolation
8   evaluation
9     views from google earth
10     qualitative
11   image data + info viewing / illumination
12     >1? - resampling
13   resampling together
15 Thurday 27th Nov
16   projection of imagery is not linear lon/lat
17     use gdal library to open file and get projection, and translate between projections
18   found another source of elevation data
19     3arcsec srtm with voids filled in using high resolution relief maps
20     1arcsec same format but made before the above with same maps
21       higher res, but SRTM is more accurate
22   elevation interpolation
23     tried bilinear and bicubic
24     quite a few anomolies
26   meeting
27     segmentation
28       [ ] comparing two regions in different datasets
29       [ ] get source from shadow guys
31 Monday 1st dec
32   using discontinuity measure with mid range IR
33     mir lights up rocks not in shadow, so discontinuity *(1-mir) could work
34   initially working with discontinuity measurement
35     saturation screws up with a lot of it
36     its then that i realised that of course shadow is never saturated
37     any saturated area can be discounted as non-shadow
38     shadows are generally dark throughout the channels
39     so multiply by (1- each channel value)
40     low (unsnowed) vegetation still shows up as shadow
41       is that because its shadows in the complexity of trees etc?
42       these areas have accurate SRTM data
43       perhaps we can use this to prove that they cannot be in shadow
44     characteristics of a cast shadow as travel away from light
45       area of light
46       area of self shadow - we can find this from the elevation data
47       area of cast shadow
48       area of light
49     therefore an area of light followed by an area of shadow
50       without self shadow in between is false
52 Thursday 4th Dec
53   raytracing
54     simple, per pixel towards light until hits terrain
55   edgetracing
56     edges of sun visibility projected into floor
57   lambertian shading
58   meeting
59     negative product might not work as with rgb, but quite good here
60     doesn't work well in non snowy areas
61     constraints transititions along light path of illuminated, self shadow, cast shadow
63 Monday 8th Dec
64   shadow classification isn't great using simple method
65   we could use some PAT techniques
66     features could be log chromaticity values
67     classifications are shadow/non-shadow
68     could restrict to only pixels negative-product classifies as shadow
69   interface
70     menu export->condition in selection
71     condition is channel and threshold (=0.5)
72     list of available channels
73     list of output channels
74     buttons to transfer between, and move up and down
75   generalised negative product
76     now product of powers of negative channels
77     can bias channels, so thermal IR has more effect at eliminating shadows than the others
79 Tuesday 9th Dec
80   [ ] improve shadow classification using self-shadow -> cast-shadow constraint
81   [ ] start terrain improvements
82       [ ] firstly apply 
84 thursday 11th dec
85   [X] error function in terms of parameters
86   [ ] find derivitive (numerically)
87   [X] gradient descent
88   [X] threshold as another parameter or minimise threshold each step
89   [ ] could plot wavelength - importance to shadow classification
90   [X] whether throwing away channels would help - minimiser would solve
91   [ ] test that constraint equations hold on training data (russion relief maps)
92   [ ] take some lines in direction of sun, and do the plot
93       [ ] smooth out small variations between shadow types
94   [ ] ambient occlusion with hemispheres
95       [ ] "shape from shading on a cloudy day"
96   [ ] shape from shading - two images - intersection of cones
97   [ ] scatter plot between angle and colour in shadows
98       [ ] look good on report
99   [ ] lit review before christmas
101 Sunday 14th Dec
102   gradient descent
103     hold off on thresholding
104     error = number of incorrect classifications
105     as threshold goes from 0 to 1, crossing a pixel value
106       pixels in shadow go incorrect
107       pixels in light go correct
108     create a number of bins in range, e.g. for each slider value
109     single pass through pixels
110       if classified as shadow: +1 to bin
111         as threshold hits that value, error will increase
112       if classified as non-shadow: -1 from bin
113         as threshold hits that value, error will decrease
115 mon 15th dec
116   gradient descent comes up with something like:
117     threshold: 2.47319e-6
118     0.9, 1.2, 0.8, 2.6, 19.5, 14, 10.7, 8.5, 3.3
119     when adapted to larger terrain, optimal threshold is: 1.8692e-6
120     error ~6.32%
121   another gradient descent:
122     threshold: 0.000581442
123     0.1, 0.8, 0.9, 0.9, 15.8, 7.2, 6.2, 6.9, 2.8
124     error ~6.26%
126 tue 16th dec
127   added elevation channel, showing void
128   when change lambertian shading to light from top, and go high resolution
129     do voids appear darker, i.e. significantly steeper?
130     there's definitely some relationship, but its not entirely accurate
132 Thu 18th dec
133   lit review
134     about 6 papers per section
135     terrain
136       any attempt at estimation
137       Edwin did radar shape from shading
138       "francot" "chalaper" - surface integration
139       shape from shading from snow covered terrain
140     multispectral stuff
141     srtm paper?
142       yes
143       section on data sources
144         sensors etc
145         adv/disadv, accuracy
147   try gradient descent on big terrain area
148     check if it holds generally
149   scatter plots
150     normal angle to sun / value
151     normal z component / value
153 Thu 15th jan
154   shadow edge dictionary - low level (finding edges) -> higher level (meaning)
155   shadow rules
156     will ?[cg]ause? any problem
157     tree/graph/finite state automata
158     tree of allowed rules
159     Consistency - what to do when not
160     cost with moving
161     confidence in how good
162     minimal cost change
163     smoothness across
164   general rules - state machine
165     do sample - check consistent
166     add shading to cost
168 cost function
169   variables to include
170     change of height values (appropriately scaled)
171       (h-h0)^2 * certainty
172     shadow entrance constraints
173       difference of gradients to tangential
174         (-dh/dw - sin(elev_sun))^2
175       negative change in gradient
176         max(0,d^2h/dw^2)^2
177       elevation relative to transition exit, from elevation of sun
178         (h_exit+(w_enter-w_exit)*sin(elev_sun) - h)^2
179     total rate of change of gradient (smoothness) in both directions
180       (d^2h/dx^2)^2
181       (d^2h/dy^2)^2
182     shadow elevation constraint - below line between entrance and exit
183       (max(0, h - (h_exit*(w_exit-w) + h_enter*(w-w_enter)) / (w_exit-w_enter)))^2
184     lit pixels must be facing the sun
185       min(0, -dh/dw - sin(elev_sun))^2
186     angle between normals and shape-from-shading/occlusion normals
187       factoring in reliability of shape-from-shading (e.g. snow/rock)
188   requirements
189     quick access to a pixel's sun direction shadow entrance/exit
190     elevation field upsampled to match imagery?
192 Thur 22nd Jan
193   [ ] plot theta(N,L)/I to check shading is accurate
194   for shadow and non shadow
195   should look like cos in sun
196   tell us albedo (x=0), reflection when face on
197   [ ] what shape for shadow region?
198   integrate over L for occlusion
199     imagine hemisphere on surface (slanted)
200     the bottom part is cut off (horizon)
201     -- we integrate from one side to the other, across the slope
202     -- integrate the L.N across the points in the arc of a circle
203     albedo*L*int(0,pi, int(theta,pi, L.N dx) dy)
204     -- N is (0,0,1)
205     -- L is (cos(x)*sin(y), cos(y), sin(x)*sin(y))
206     -- L.N = sin(x)*sin(y)
207     albedo*L*int(0,pi, int(theta,pi, sin(x)*sin(y) dx) dy)
208     -- sin(y) doesn't depend on x
209     albedo*L*int(0,pi, sin(y)*int(theta,pi, sin(x) dx) dy)
210     -- int sin(x) dx = -cos(x)
211     albedo*L*int(0,pi, sin(y)*[-cos(pi)+cos(theta)] dy)
212     -- cos(pi) = -1
213     albedo*L*int(0,pi, sin(y)*[1+cos(theta)] dy)
214     -- [1+cos(theta)] doesn't depend on y
215     albedo*L*[1+cos(theta)]*int(0,pi, sin(y) dy)
216     albedo*L*[1+cos(theta)]*[-cos(pi) + cos(0)]
217     -- cos(pi) = -1, cos(0) = 1
218     albedo*L*[1+cos(theta)]*2
219     -- rearrange
220     2*albedo*L*(1+cos(theta))
222 Monday 26th Jan
223   so to implement the above cost function, we need at each pixel:
224     current elevation (turn into height map)
225     gradient in light directions
226     rate of change of gradient in x, y, light direction
227     whether classified as shadow, or lit
228     whether on a boundary of shadow and light
229     sun elevation and direction
230     if in shadow:
231       distance to and current elevation at shadow entrance and exit in light direction
233 fix list
234 [ ] seems - not important
235 [ ] when creating texture for region, don't up sample, select larger area
237 todo
238 [X] proper texturing
239     [X] selection of channels to display
240 [ ] more sensible sampling of elevation data
241     [X] edges of box should interpolate
242     [X] inner vertices should be sensible
243 [ ] srtm
244     [X] basic linear interpolation
245     [X] spline interpolation
246     [X] gui to toggle {flat, unprocessed, corrected -> refined}
247     [ ] self shadow lines
248         [ ] different colours for ridges and valleys
249 [ ] interaction
250     [X] focus extended altitude
251     [X] mouse click -> lon lat transformation
252     [ ] terrain grab while dragging
253     [X] selection of region
254     [ ] region image preview (full resolution)
255     [ ] multiple viewports
256         [ ] interaction (observers) can be locked together
257         [ ] data view can be locked together
258 [ ] image processing
259     [ ] should be able to add processing bands to those on the colour mapper
260     [X] input bands should be derivable from digital elevation model
261         e.g. could do calculations in world space instead of texture space
262         [X] get texture space normal at a pixel
263         [X] get texture space lighting direction at a pixel
264         [X] get elevation at a pixel
265         [X] get geographical coordinate at a pixel
266         examples
267           [X] shadow from DEM
268           [X] lambertian shading (automatic self shadow detection)
269           [ ] combination of the two (pixel product)
270           [ ] chromaticity based on lambertian shading shows colour
271 [ ] shadow detection
272     [X] in region, detect shadow areas
273         [X] from imagery
274         [X] from elevation data using raytracing
275     [ ] vectorisation
276     [ ] border and highlight in both views
278 texturing
279   problems
280     textures are BIG
281       8401 x 7461 - 63MB  x6
282       4201 x 3731 - 16MB  x2
283       16801 x 14921 - 250MB x1
284       660MB
285   solution
286     downsample entire image to a reasonable size
287       1/8 x 1/8 = 1/64th size = ~10MB
288       or use the thumbnail in each image
289     when a portion of the image is desired in higher detail
290       reload portion of the image at full resolution
291       1/8 x 1/8 = 1/64th size of image
292     when a portion of the image is no longer being used
293       discard of it
295   class tcBigImage
296     width, height
297     thumbnail texture
298     rows, cols
299     cells[rows][cols]
300       texture
301       image data
303 image processing
304   image data should be made up of channels
305     some channels are source bands from GeoTIFF files
306     some are derived from other channels
307   tcChannelManager
308     manages a set of channels that are referred to in a colour map widget
309   tcChannel
310     functionality for keeping data around so as not to have to reload
311       after creating GL texture
312     results can be floating point, bytes, bits
313     histograms and various plots based on the pixel data
314     data changed event triggers invalidation of textures
315       and invalidation of channels derived from this channel
316   tcChannelConstant : tcImageChannel
317     constant colour - e.g. black (for a null channel to avoid clicking rgb each time)
318   tcChannelFile : tcImageChannel
319     data from a GeoTIFF file
320   tcChannelProcess
321     acts on a number of input channels to produce a number of output channels
322     can be configured with a gui
323   tcChannelProcessChromaticity : tcChannelProcess
324     divide a set of channels by another channel or a value
325     out: float
326   tcChannelProcessIlluminantInvariant : tcChannelProcess
327     input log chromaticities
328     can configure illuminant direction
329       if two dimentions, use a dial
330       for > 2 dimentions, select a shadow / non shadow adjascent bit of image
331         or select multiple such known shadow changes and average
332         find variation vector from this
333         easy to reuse this vector
334   tcChannelProcessIlluminantDiscontinuity : tcChannelProcess
335     see cic13
336     shows discontinuity between adjascent pixels in x or y direction
337     i.e. you might show two of these in different colour channels
339 renderCell
340   determine if we need to subdivide quality in this cell
341     if we're close, then we do
342     find distance from each corner 
343     use distance[i] < max(dist(corner[i], corner[j]))*factor
344   if we should subdivide
345     renderCell on each of the 4 subdivisions
346   determine the quality at this level
347     find distance to center
348     apply magic function to find detail level
349     render the cell in this detail level