A simple but interesting program to increase the resolution and reduce noise in images.
A simple super resolution program that takes a directory of n images in JPEG and that it generates a single super resolution image. It finds from the diretory, the most focused image, and uses it has a reference. It then, finds the alignment transform of all images to that reference image that is more focused, it aligns with sub-pixel accuracy at the same time in XX, YY axies, in rotation, and in zoom, and then applies to each image the transformation. Then it scales each image image up, using a bicubic spline interpolation, or a Lanczos3 interpolation, or even a Drizzle algorithm ( the algorithm that NASA invented for the Hubbble Telescope ) and then it sums them up or combines them, in the case of the drizzle method and generates a single final image.
It can be used to make just a better 1x time upscalling image from many with lower noise, a 2x, a 3x, a 4x times (thats 16x more megapixeis) and even greater x5 or x6 times. My computer is a slow one, and I tested with fotos from a 33 Mpixel camera for a 4x upscalling with a diretory with 2 , 10 and 40 fotos of the same scene, but you can use 100 fotos or 200 fotos if you like.
The fotos have to be taken handheld without great movement, but the handhell is paramount, because those little random offset position naturally created is what will generate, the diffent points of views that have different information in each image, and that can be combined to have a greater image resolution and a much better signal to noise ratio. That is, almost no noise in the final image even when the origina images are noisy images.
make
# Usage:
# program_name <input_dir_path> <output_file_path> <float number of times to upscale>
# eg:
./super_resolution_n_images_to_1.exe ./input_images_001/ /dev/shm/sr/sr_x2_clock_book.png 2
or
./super_resolution_n_images_to_1.exe ./input_images_001/ /dev/shm/sr/sr_x3_clock_book.png 3
or
./super_resolution_n_images_to_1.exe ./input_images_001/ /dev/shm/sr/sr_x4_clock_book.png 4
# Note : /dev/shm/ is the RAM disk that comes standard with every Linux.On a slow computer...
time ./super_resolution_n_images_to_1.exe ../multiple_images_to_one_super_resolution/clock_book/ /dev/shm/sr/sr_x4_clock_book_lanczos3.png 4
===> Super resolution n images to 1.
Scanning directory: ../multiple_images_to_one_super_resolution/clock_book/
Output File: /dev/shm/sr/sr_x4_clock_book_lanczos3.png
Super Res Scale: 4 x
Min Focus Ratio: 0.8
Found 178 images. Calculating the image that is more focused, to use it has a reference:
0 - focus : 0.0010400 - 533A029.JPG <===
1 - focus : 0.0010050 - 533A030.JPG
2 - focus : 0.0010153 - 533A031.JPG
3 - focus : 0.0009506 - 533A032.JPG
4 - focus : 0.0009402 - 533A033.JPG
5 - focus : 0.0010107 - 533A034.JPG
6 - focus : 0.0010230 - 533A035.JPG
7 - focus : 0.0009901 - 533A036.JPG
8 - focus : 0.0009974 - 533A037.JPG
9 - focus : 0.0010163 - 533A038.JPG
10 - focus : 0.0010244 - 533A039.JPG
11 - focus : 0.0010454 - 533A040.JPG <===
12 - focus : 0.0010019 - 533A041.JPG
13 - focus : 0.0010175 - 533A042.JPG
14 - focus : 0.0010273 - 533A043.JPG
15 - focus : 0.0010212 - 533A044.JPG
16 - focus : 0.0010474 - 533A045.JPG <===
17 - focus : 0.0010258 - 533A046.JPG
18 - focus : 0.0010217 - 533A047.JPG
19 - focus : 0.0010099 - 533A048.JPG
20 - focus : 0.0010246 - 533A049.JPG
21 - focus : 0.0010113 - 533A050.JPG
22 - focus : 0.0009995 - 533A051.JPG
23 - focus : 0.0010312 - 533A052.JPG
24 - focus : 0.0010113 - 533A053.JPG
25 - focus : 0.0009997 - 533A054.JPG
26 - focus : 0.0009505 - 533A055.JPG
27 - focus : 0.0010309 - 533A056.JPG
28 - focus : 0.0009881 - 533A057.JPG
29 - focus : 0.0010382 - 533A058.JPG
30 - focus : 0.0010373 - 533A059.JPG
31 - focus : 0.0010305 - 533A060.JPG
32 - focus : 0.0009621 - 533A061.JPG
33 - focus : 0.0010286 - 533A062.JPG
34 - focus : 0.0010400 - 533A063.JPG
35 - focus : 0.0010368 - 533A064.JPG
36 - focus : 0.0010356 - 533A065.JPG
37 - focus : 0.0010321 - 533A066.JPG
38 - focus : 0.0010183 - 533A067.JPG
39 - focus : 0.0009519 - 533A068.JPG
Found 178 images. Loading reference: 533A045.JPG
Reference Focus Score: 0.0010474
Processing sequence...
ID | Filename | dX (px) | dY (px) | Rot (deg) | Zoom | Focus | Score (MSE)
----|----------------------|------------|------------|-----------|---------|-----------|------------
000 | 533A029.JPG | -00121.939 | -00112.723 | 0000.7227 | 1.00070 | 00.001040 | 000.001163
001 | 533A030.JPG | -00094.791 | -00119.016 | 0000.5996 | 1.00027 | 00.001005 | 000.001040
002 | 533A031.JPG | -00058.576 | -00062.213 | 0000.5156 | 1.00008 | 00.001015 | 000.000674
003 | 533A032.JPG | -00060.172 | -00064.309 | 0000.4395 | 1.00025 | 00.000951 | 000.000686
004 | 533A033.JPG | -00078.160 | -00038.119 | 0000.4209 | 1.00018 | 00.000940 | 000.000783
005 | 533A034.JPG | -00040.127 | -00007.248 | 0000.3994 | 0.99990 | 00.001011 | 000.000535
006 | 533A035.JPG | -00048.781 | -00024.240 | 0000.3623 | 1.00004 | 00.001023 | 000.000551
007 | 533A036.JPG | -00044.240 | 000010.566 | 0000.3438 | 0.99971 | 00.000990 | 000.000579
008 | 533A037.JPG | -00149.832 | -00123.053 | 0000.0713 | 1.00363 | 00.000997 | 000.001742
009 | 533A038.JPG | -00027.051 | 000009.191 | 0000.2812 | 0.99979 | 00.001016 | 000.000481
010 | 533A039.JPG | -00033.322 | -00017.533 | 0000.2607 | 0.99998 | 00.001024 | 000.000467
011 | 533A040.JPG | -00022.682 | 000007.746 | 0000.1846 | 0.99990 | 00.001045 | 000.000456
012 | 533A041.JPG | -00054.377 | 000005.039 | 0000.1777 | 0.99992 | 00.001002 | 000.000606
013 | 533A042.JPG | -00037.271 | 000001.535 | 0000.2910 | 1.00023 | 00.001017 | 000.000500
014 | 533A043.JPG | -00045.812 | 000015.217 | 0000.1709 | 1.00023 | 00.001027 | 000.000557
015 | 533A044.JPG | -00027.039 | -00000.533 | 0000.1182 | 1.00004 | 00.001021 | 000.000458
016 | Reference image ../multiple_images_to_one_super_resolution/clock_book/533A045.JPG
017 | 533A046.JPG | -00011.236 | -00008.539 | -000.0352 | 0.99996 | 00.001026 | 000.000404
018 | 533A047.JPG | 000008.338 | -00007.822 | -000.0664 | 0.99984 | 00.001022 | 000.000405
019 | 533A048.JPG | 000002.287 | -00011.217 | -000.0820 | 0.99975 | 00.001010 | 000.000409
020 | 533A049.JPG | -00029.498 | 000016.311 | -000.0996 | 0.99994 | 00.001025 | 000.000467
021 | 533A050.JPG | 000003.959 | 000000.436 | -000.1572 | 0.99984 | 00.001011 | 000.000399
022 | 533A051.JPG | -00015.156 | 000014.840 | -000.1934 | 0.99986 | 00.001000 | 000.000426
023 | 533A052.JPG | -00029.100 | 000006.861 | -000.2607 | 1.00006 | 00.001031 | 000.000444
024 | 533A053.JPG | -00014.932 | -00015.900 | -000.3086 | 1.00016 | 00.001011 | 000.000415
025 | 533A054.JPG | -00046.900 | -00017.553 | -000.3145 | 1.00027 | 00.001000 | 000.000515
026 | 533A055.JPG | -00032.535 | -00058.408 | -000.4180 | 1.00018 | 00.000950 | 000.000520
027 | 533A056.JPG | -00001.135 | -00014.871 | -000.1777 | 1.00016 | 00.001031 | 000.000414
028 | 533A057.JPG | -00003.006 | -00005.867 | 0000.7412 | 0.99998 | 00.000988 | 000.000421
029 | 533A058.JPG | -00025.008 | 000008.877 | 0001.1768 | 1.00041 | 00.001038 | 000.000460
030 | 533A059.JPG | -00065.426 | 000007.070 | 0001.1084 | 1.00074 | 00.001037 | 000.000639
031 | 533A060.JPG | -00042.963 | -00147.414 | 0001.0039 | 1.00121 | 00.001030 | 000.000929
032 | 533A061.JPG | -00108.488 | -00135.406 | 0001.0215 | 1.00191 | 00.000962 | 000.001070
033 | 533A062.JPG | -00084.795 | -00143.584 | 0000.9443 | 1.00182 | 00.001029 | 000.000992
034 | 533A063.JPG | -00086.059 | -00141.355 | 0000.9355 | 1.00188 | 00.001040 | 000.000993
035 | 533A064.JPG | -00119.803 | -00103.555 | 0000.9180 | 1.00195 | 00.001037 | 000.001040
036 | 533A065.JPG | -00102.697 | -00113.455 | 0000.8594 | 1.00187 | 00.001036 | 000.000966
037 | 533A066.JPG | -00105.477 | -00134.443 | 0000.8262 | 1.00195 | 00.001032 | 000.001049
038 | 533A067.JPG | -00135.049 | -00127.129 | 0000.8311 | 1.00221 | 00.001018 | 000.001198
039 | 533A068.JPG | -00099.682 | -00143.965 | 0000.7637 | 1.00184 | 00.000952 | 000.001049
Alignment complete. Resolving and Sharpening...
Applying Unsharp Mask (Strength: 0.50)...
Saving to: /dev/shm/sr/sr_x4_clock_book_lanczos3.png
Done.
real 41m34,925s
user 40m35,823s
sys 0m58,923sMIT Open Source license
Best regards,
Joao Carvalho