Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
finding relationship between x, y coordinates of two images
#1
I have two images of the same thing. The extent and alignment are the same. One is low resolution (ppi) and has been geo referenced. The other is the same image where the ppi has been increased and the image size reduced with the scaling tool. 

I don't want to georeference all those points on this new image. It seems like there should be a relationship between the x, y coordinates of the pixels of the two images so I should be able to calculate where a pixel from the old image will line up on the new image.

I thought it would be a simple ratio, but so far it hasn't worked. The points move but are off by a lot.

I have read that the scaling tool has a number of interpolation methods and that may influence this relationship.

Does anyone know anything about this?

I'm actually trying to load the points from the old image onto the new higher ppi image in QGIS. I'm not sure if it has any settings for interpolation method when doing this operation or not. From there is will be warped. The warping included interpolation methods, but I'm not there yet.


Here is some info on the two images:

My old low ppi raster is:
3772 x 1936 pixels
0.4517  x 0.2319 inches print size  (11.47318 x 5.89026 mm)
8350 x 8350 PPI

The new high ppi raster is:
10190 x 5225 pixels
16.883 x 8.708 in print size  (428.8282 x 221.1832 mm)
600 x 600 PPI
Reply
#2
(09-08-2025, 12:43 PM)TMORT Wrote: I don't want to georeference all those points on this new image. It seems like there should be a relationship between the x, y coordinates of the pixels of the two images so I should be able to calculate where a pixel from the old image will line up on the new image.
...snip....
I have read that the scaling tool has a number of interpolation methods and that may influence this relationship.

Gimp might not be accurate enough for your needs however, first a general comment.
The aspect ratio (height/width) for each is not identical big = 2.70148   small = 2.6988  A very small difference that might make only 5 pixels out over 10,000 pix but up to you to decide.  Scaling in mm units might make that difference, work in pixels.

Edit: This is what I mean. The width should be 3776 pix not 3772  only 4 pix but.....

   

The interpolation method should make no difference in image pixel size,  it only affects quality, although a single pixel in the small image might spread out a bit when upscaled. 

Pleased that you are working in pixels.  Wink  and I hope still using Gimp 2.10
Ofnuts has a Gimp 2.10 plugin ofn-path-edits.py from http://sourceforge.net/projects/gimp-pat...s/scripts/  that gives pixel co-ordinates , start and end of a path(s)   It might allow you to calculate relative positions.  (but remember that difference in aspect ratios)

   
Reply
#3
<blanket type=wet>

Images are one thing and maps are another. A map of the surface of earth has a specific projection and unless you are using the very same projection for both maps (in the case of some projections such as Lambert, the latitude/longitude of the center is important) they won't overlap when scaled.

Another problem when using random images is that the capture process may introduce distortion. Camera lenses have distortion (but these are well known and easy to fix, at least for "prime" lenses), while household/business scanners often have even more distortion, that is rarely mentioned and is complicated to fix.  

So, your chance of having two maps of different origins differing only by a scale factor are abysmally small.  

<\blanket>

Assuming you are talking about plain images (or identical map projections), when you use the Unified Transform tool you get the values of the transform matrix(*). Applying this matrix to the X,Y source coordinates will give you the X,Y coordinates of the target and vice-versa. You could have to invert the matrix.

Interpolation method is irrelevant. What it does is that when Gimp want to compute the value of a pixel at X,Y in the target, it uses the matrix to compute the X,Y value in the source. These are rarely integers, and the role of the interpolation method is, given an X,Y in the source, to compute the best possible value to apply to the target. Just rounding off is the "Nearest neighbor" or "None" algorithm, using a linear interpolation (5.33 would be two thirds of the pixel at 5 and one third of the pixel at 6) is the "Linear" one as you guess.

(*) Technically this matrix is used under the hood in all transform tools. But in simple tools it is best replaced by  a simple concept, such as the scale factor or the rotation angle, so you have to use the UT to confront the matrix, which is the only thing of value to display. Using the UT could also allow you to fix and take in account small rotations/perspective (as far as they are introduced by the map reproduction/scan, not by the map projection itself).
Reply
#4
Maybe this can help you : https://docs.qgis.org/3.40/en/docs/user_...encer.html
Reply


Forum Jump: