Mon, May 30 2005
11:10:26
|
|
Request created by hbowman
|
|
Subject: i.rectify: automatic resolution calculation is wrong
The automatic target resolution calculation in i.rectify is bad.
imagery/i.rectify/get_wind.c
[w1 is starting window, w2 is target window]
w2->ns_res = (w2->north - w2->south) / w1->rows;
w2->ew_res = (w2->east - w2->west ) / w1->cols;
Say you have a map which is much taller than it is wide and after
rectification it will be rotated 90 degrees to be very wide but not very tall.
The above code will leave the resultant map with many divisions in the
vertical, and few in the horizontal, ruining the data quality. The effect is
less and less obvious as the rotation nears 0 or 180 degrees.
any ideas on how to fix this?
the previous step is calculating the georeferenced versions of the source
map's 4 corners. (which has its own problems...)
Hamish
|
|
Mon, May 30 2005
11:11:00
|
|
Area changed to grass6 by hbowman
|
|
Mon, May 30 2005
11:33:58
|
|
User notified by hbowman
|
|
Mon, May 30 2005
11:34:11
|
|
Priority changed to 75 by hbowman
|
|
Sat, Aug 20 2005
12:27:21
|
|
Area changed to grass6.1 by msieczka
|
|
Wed, Aug 31 2005
20:51:43
|
|
Area changed to grass6 by mneteler
|
|
Tue, May 9 2006
23:22:16
|
|
Mail sent by cshock
|
|
This same problem or a similar one is encountered and solved in r.tileset
(This is actually almost all the work that r.tileset does since it doesn't
make optimal tilings). In r.tileset the problem might be the reverse of the
one encountered here. It is trying to find a resolution in the source
projection which will cover a specified resolution in the destination.
r.tilesets resolution calculation:
Projects destination bounding box (nsew) into the source (this makes 4 corners)
Find the bounding box (nsew) in the source of the above
Project the source bounding box back (nsew) into the destination (this makes
4
corners).
Now we have the four points of the corners in the destination of the bounding
box in the source of the bounding box in the destination.
We use this to calculate the lengths of the sides of the source bounding box
of the destination bounding box.
In each edge in the source we calculate it's length in the destination by the
metric of x scaled to 1/xres and y scaled to 1/yres. We take the maximum of
these in each direction. This is how many cells wide and tall the source
should be.
Note: The projection might do things like bulge in the middle. The bounding
box of bounding box doesn't really guarantee that we get the maximum lengths
through things. These transformations are very difficult to imagine. |
|
Tue, May 9 2006
23:39:59
|
|
Mail sent by cshock
|
|
This is a differential geometry problem related to the Jacobian. You have a
map for rectifying:
(x, y) = f (u, v)
Where u and v are the coordinates in the image and x and y are the coordinates
in the location. For the x resolution you want to find the smallest amount x
changes when u or v change. For the y resolution you want to find the smallest
amount y changes when u or v change.
So you want to find the minimum of (d is delta for partial derivatives):
(dx / du) (f) * u-resolution
(dx / dv) (f) * v-resolution
for x resolution and
(dy / du) (f) * u-resolution
(dy / dv) (f) * v-resolution
for y resolution.
You only care about these minumums over the existing u and v values. |
|
Wed, May 10 2006
02:12:49
|
|
Mail sent by cshock
|
|
This can be simplified and clarified bit. Let's assume that we already have
already taken care of the resolution scale of u and v (we have, since each 1
u
or 1 v is 1 cell). We have a transformation (split into components) of:
x = fx (u, v)
y = fy (u, v)
The x resolution is the minimum of
magnitude(gradient(fx(u, v)))
over the range of u and v.
The y resolution is the minimum of
magnitude(gradient(fy(u, v)))
over the range of u and v.
These functions (fx and fy) look like:
sqrt ( polynomial_in_u_and_v^2 + polynomial_in_u_and_v^2 )
Actually performing this minimization (we have big long boundaries that
probably must be checked) will be a bit tricky. |
|