# Last edited on 2012-01-04 18:39:00 by stolfilocal # ---------------------------------------------------------------------- # 2012-01-01 COMPUTING IMAGE ALIGNMENT MATRICES Trying to stitch L52a and L62a. Collected lists of pairs of points, match-points-L52a-L62a.txt match-points-L53a-L63a.txt match-points-L52a-L53a.txt match-points-L62a-L63a.txt Used my program "image_stitch" to compute projective matrices: cat match-points-L52a-L62a.txt \ | sed -e 's:[\#].*$::g' \ | image_stitch \ -image1 0 0 7954 6739 \ -image2 0 0 7858 6723 \ -verbose \ -maxIter 5 -maxErr 0 L52a --> common L52a+L62a: [ 9.978552e-01 2.854092e+03 2.676458e+00 ] [ 2.493827e-07 9.974641e-01 1.582791e-04 ] [ 2.392760e-08 -4.429913e-04 9.986605e-01 ] L62a --> common L52a+L62a: [ 1.002867e+00 -2.869552e+03 -2.232931e+00 ] [ -2.507297e-07 1.003260e+00 -1.583361e-04 ] [ -2.413959e-08 5.137850e-04 1.001341e+00 ] cat match-points-L53a-L63a.txt \ | sed -e 's:[\#].*$::g' \ | image_stitch \ -image1 0 0 7964 6704 \ -image2 0 0 7989 6711 \ -verbose \ -maxIter 5 -maxErr 0 L53a --> common L53a+L63a: [ 9.991486e-01 2.853258e+03 4.032725e+00 ] [ 7.663796e-08 9.975632e-01 6.284571e-05 ] [ 3.596283e-08 -4.433668e-04 9.996219e-01 ] L63a --> common L53a+L63a: [ 1.001072e+00 -2.863295e+03 -3.858561e+00 ] [ -7.690525e-08 1.002663e+00 -6.272662e-05 ] [ -3.604911e-08 5.477267e-04 1.000378e+00 ] cat match-points-L52a-L53a.txt \ | sed -e 's:[\#].*$::g' \ | image_stitch \ -image1 0 0 7954 6739 \ -image2 0 0 7858 6723 \ -verbose \ -maxIter 5 -maxErr 0 L52a --> common L52a+L53a: [ 1.001148e+00 5.918085e+02 -2.672411e+03 ] [ 4.265716e-08 1.000530e+00 -2.417539e-05 ] [ -2.206431e-07 -1.261262e-03 1.000480e+00 ] L53a --> common L52a+L53a: [ 9.994671e-01 -5.878144e+02 2.669691e+03 ] [ -4.260651e-08 9.994953e-01 -8.965589e-05 ] [ 2.203660e-07 1.130386e-03 1.000109e+00 ] cat match-points-L62a-L63a.txt \ | sed -e 's:[\#].*$::g' \ | image_stitch \ -image1 0 0 7858 6723 \ -image2 0 0 7989 6711 \ -verbose \ -maxIter 5 -maxErr 0 L62a --> common L62a+L63a: [ 9.979362e-01 5.746496e+02 -2.671957e+03 ] [ 4.035555e-09 9.992840e-01 -5.597638e-05 ] [ 3.022650e-07 1.534916e-03 1.000372e+00 ] L63a --> common L62a+L63a: [ 1.001260e+00 -5.798940e+02 2.674298e+03 ] [ -4.060483e-09 1.000719e+00 4.515039e-05 ] [ -3.025272e-07 -1.360232e-03 9.988201e-01 ] Computing the average of matrices >>> STOPPED HERE >>> Temporarily joined images in pairs, L52a+L62a/L2_BAND${band}-r100-p.png L53a+L63a/L2_BAND${band}-r100-p.png I had a file match-points-L52a+L62a-L53a+L63a.txt of matching points between L52a+L62a and L53a+L63a. Trying to obtain from it separate files matching the original images, namely L52a-L53a and L62a-L63a Then looked for matching points in the two sets, placed in file "match-points-L52a+L62a-L53a+L63a.txt" Used my program "image_stitch" to compute projective matrices: cat match-points-L52a+L62a-L53a+L63a.txt | sed -e 's:[\#].*$::g' | image_stitch L52a+L62a --> MOSAIC: [ 1.000000e+00 5.833805e+02 -2.672259e+03 ] [ 0.000000e+00 9.999983e-01 -4.029029e-05 ] [ 0.000000e+00 2.147547e-04 1.000578e+00 ] L53a+L63a --> MOSAIC: [ 1.000000e+00 -5.839551e+02 2.670692e+03 ] [ -0.000000e+00 1.000002e+00 4.026709e-05 ] [ 0.000000e+00 -2.146310e-04 9.994225e-01 ] Saved the matrices to files matrix-L52a-to-L52a+L62a.txt matrix-L62a-to-L52a+L62a.txt matrix-L53a-to-L53a+L63a.txt matrix-L63a-to-L53a+L63a.txt matrix-L52a+L62a-to-MOSAIC.txt matrix-L53a+L63a-to-MOSAIC.txt Multiplying the matrices: multiply-matrices.gawk matrix-L52a-to-L52a+L62a.txt matrix-L52a+L62a-to-MOSAIC.txt > matrix-L52a-to-MOSAIC.txt multiply-matrices.gawk matrix-L62a-to-L52a+L62a.txt matrix-L52a+L62a-to-MOSAIC.txt > matrix-L62a-to-MOSAIC.txt multiply-matrices.gawk matrix-L53a-to-L53a+L63a.txt matrix-L53a+L63a-to-MOSAIC.txt > matrix-L53a-to-MOSAIC.txt multiply-matrices.gawk matrix-L63a-to-L53a+L63a.txt matrix-L53a+L63a-to-MOSAIC.txt > matrix-L63a-to-MOSAIC.txt PERFORMING IMAGE ALIGNMENT To determine the mosaic size, we take the size of each image and the shift elements of its matrix (assuming that the linear submatrix is very close to the identity): img Orig size Shift Approx range after shift ---- ----------- ----------- --------------------------- img NH NV DH DV MINH MAXH MINV MAXV L52a 7954 x 6739 +3445 -2667 +3444 +11400 -2668 +4073 L62a 7858 x 6723 -2285 -2678 -2286 +5574 -2678 +4045 L53a 7964 x 6704 +2272 +2675 +2271 +10237 +2674 +9380 L63a 7989 x 6711 -3446 +2664 -3447 +4544 +2663 +9376 ---- ----------- ----- ----- ------ ------ ------ ------ ALL -3447 +11400 -2678 +9380 After mapping the images will span about 14847 by 12058 pixels Round it to 15000 by 12200, shift by 3650 2800. # ---------------------------------------------------------------------- # 2011-12-XX IMAGE STITCHING IN PAIRS # bands=( 1 2 3 4 5 7 ) bands=( 4 5 7 ) for band in ${bands[@]} ; do cd ${tdir}/L52a convert L2_BAND${band}-r100.png PGM:- \ | pnmprojmap \ -xAxis right \ -yAxis down \ -iOrg 0 0 \ -undef 0.0 \ -matrix \ 1.000000e+00 2.861678e+03 4.607864e+00 \ 0.000000e+00 9.974954e-01 -5.340948e-04 \ 0.000000e+00 -5.838737e-04 1.000056e+00 \ -oSize 13800 7000 \ -oOrg 2900 120 \ -maxval 256 \ -verbose \ - \ | convert PGM:- L2_BAND${band}-r100-p.png cd ${tdir}/L62a convert L2_BAND${band}-r100.png PGM:- \ | pnmprojmap \ -xAxis right \ -yAxis down \ -iOrg 0 0 \ -undef 0.0 \ -matrix \ 1.000000e+00 -2.868867e+03 -6.139767e+00 \ -0.000000e+00 1.002511e+00 5.354061e-04 \ -0.000000e+00 5.853072e-04 9.999444e-01 \ -oSize 13800 7000 \ -oOrg 2900 120 \ -maxval 256 \ -verbose \ - \ | convert PGM:- L2_BAND${band}-r100-p.png done # bands=( 1 2 3 4 5 7 ) bands=( 4 5 7 ) for band in ${bands[@]} ; do cd ${tdir}/L53a convert L2_BAND${band}-r100.png PGM:- \ | pnmprojmap \ -xAxis right \ -yAxis down \ -iOrg 0 0 \ -undef 0.0 \ -matrix \ +1.000000e+00 +2.856341e+03 +5.140625e+00 \ +0.000000e+00 +9.976831e-01 -2.149450e-04 \ +0.000000e+00 -6.372855e-04 +1.000026e+00 \ -oSize 13800 7000 \ -oOrg 2900 120 \ -maxval 256 \ -verbose \ - \ | convert PGM:- L2_BAND${band}-r100-p.png cd ${tdir}/L63a convert L2_BAND${band}-r100.png PGM:- \ | pnmprojmap \ -xAxis right \ -yAxis down \ -iOrg 0 0 \ -undef 0.0 \ -matrix \ +1.000000e+00 -2.862978e+03 -5.755859e+00 \ -0.000000e+00 +1.002322e+00 +2.154386e-04 \ -0.000000e+00 +6.387490e-04 +9.999742e-01 \ -oSize 13800 7000 \ -oOrg 2900 120 \ -maxval 256 \ -verbose \ - \ | convert PGM:- L2_BAND${band}-r100-p.png done MERGING THE IMAGES - PRELIMINARY Combining the two images L52a L62a: cd ${tdir} # bands=( 1 2 3 4 5 7 ) bands=( 4 5 7 ) for band in ${bands[@]} ; do for img in L52a L62a ; do fname="${img}/L2_BAND${band}-r100" convert ${fname}-p.png ${fname}-p.pgm done fname1="L52a/L2_BAND${band}-r100" fname2="L62a/L2_BAND${band}-r100" fname12="L52a+L62a/L2_BAND${band}-r100" pnmxarith \ -maximum \ ${fname1}-p.pgm \ ${fname2}-p.pgm \ | convert PGM:- ${fname12}-p.png rm -f ${fname1}-p.pgm rm -f ${fname2}-p.pgm done cd ${tdir} for band in ${bands[@]} ; do fname12="L52a+L62a/L2_BAND${band}" convert ${fname12}-r100-p.png -resize '50%' ${fname12}-r050-p.png convert ${fname12}-r100-p.png -resize '25%' ${fname12}-r025-p.png convert ${fname12}-r100-p.png -resize '5%' ${fname12}-r005-p.png done Combining the two images L53a+L63a: cd ${tdir} mkdir -p L53a+L63a # bands=( 1 2 3 4 5 7 ) bands=( 4 5 7 ) for band in ${bands[@]} ; do for img in L53a L63a ; do fname="${img}/L2_BAND${band}-r100" convert ${fname}-p.png ${fname}-p.pgm done fname1="L53a/L2_BAND${band}-r100" fname2="L63a/L2_BAND${band}-r100" fname12="L53a+L63a/L2_BAND${band}-r100" pnmxarith \ -maximum \ ${fname1}-p.pgm \ ${fname2}-p.pgm \ | convert PGM:- ${fname12}-p.png rm -f ${fname1}-p.pgm rm -f ${fname2}-p.pgm done cd ${tdir} for band in ${bands[@]} ; do fname12="L53a+L63a/L2_BAND${band}" convert ${fname12}-r100-p.png -resize '50%' ${fname12}-r050-p.png convert ${fname12}-r100-p.png -resize '25%' ${fname12}-r025-p.png convert ${fname12}-r100-p.png -resize '5%' ${fname12}-r005-p.png done