The flutter shutter camera simulator
|
Flutter-Shutter camera simulator main file The input is (grayscale or color) png image, a "code" among the list, a noise-level, a Flutter Shutter type (numerical or analog), a velocity $v$. The output are 1) acquired image using a Flutter-Shutter acquisition strategy 2) The reconstructed image. 3) Groundtruth image 4) The difference between the ideal reconstruction and the actual reconstruction with dynamic on [0,255] by an affine contrast change. 5) Txt file that contains the code coefficients 6) Txt file that contains the Fourier transform of the flutter shutter function. (used for invertibility check) 7) The RMSEs (standard output; printf). More...
#include <stdio.h>
#include <stdlib.h>
#include <iostream>
#include <fstream>
#include "mt19937ar.h"
#include <math.h>
#include "io_png/io_png.h"
#include "flutter.h"
#include "standard_routines.h"
#include "midway.h"
#include "borders.h"
#include "codes_flutter.cpp"
Go to the source code of this file.
Defines | |
#define | M_PI 3.14159265358979323846 |
Functions | |
int | main (int argc, char **argv) |
main function call arguemnts are "Image.png" "Flag_{code}" "SNR" "Flag_{NUM | ANALOG}" "Velocity" "Deltat" "Imacquired.png" "ImReconstructed.png" "Groundtruth.png" "Imdiff.png" "code_file_name.txt" "FT_code_file_name.txt" |
Flutter-Shutter camera simulator main file The input is (grayscale or color) png image, a "code" among the list, a noise-level, a Flutter Shutter type (numerical or analog), a velocity $v$. The output are 1) acquired image using a Flutter-Shutter acquisition strategy 2) The reconstructed image. 3) Groundtruth image 4) The difference between the ideal reconstruction and the actual reconstruction with dynamic on [0,255] by an affine contrast change. 5) Txt file that contains the code coefficients 6) Txt file that contains the Fourier transform of the flutter shutter function. (used for invertibility check) 7) The RMSEs (standard output; printf).
IN/OUTputs are 8bits png (grayscale or color)
Sketch of the simulator ********************************
Assume a code of length $L$, (w.l.o.g) Given a noise level and a velocity $v$
I) Simulation of the oberved image
1) Analog Flutter Shutter case : a) Simulate noise less image (convolution against the Flutter Shutter function of the code at velocity $v$); b) Simulate the Poisson R.Vs (given the noise level); c) Crop to avoid periodization artifacts introduced by the DFT to get the observed: L/2 on each sides
2) Numerical Flutter Shutter case : a) Simulate the $N$ images of an Analog Flutter Shutter using the $N$ codes : (1,0,...,0), (0,1,0,...,0), (0,0,1,0,...,0) to (0,...,0,1) at the choosen velocity and noise level; b) Multiply the $k-th$ image obtained above by the coefficient $a_k$ of the code then sum to get the the observed;
II) Deconvolution of the observed image 1) Apply a mirror symmetry in the direction the blur; 2) Deconvolve (in Fourier domain); 3) Crop to remove the symmetry; crop for borders effects L on each sides 4) Comute the RMSE (omitting 3L firsts and lasts columns), write images, etc.
Color image : each channel is processed independatly
Definition in file demo_flutter.cpp.
#define M_PI 3.14159265358979323846 |
M_PI is a POSIX definition for Pi
Definition at line 95 of file demo_flutter.cpp.
int main | ( | int | argc, |
char ** | argv | ||
) |
main function call arguemnts are "Image.png" "Flag_{code}" "SNR" "Flag_{NUM | ANALOG}" "Velocity" "Deltat" "Imacquired.png" "ImReconstructed.png" "Groundtruth.png" "Imdiff.png" "code_file_name.txt" "FT_code_file_name.txt"
Input.png | : file name of the input image (PNG file) Image to use for the simulation (grayscale or color) PNG. |
(int) | "Flag_{code}" indicates the code to use. Codes for the Flutter-Shutter Simulator Code : 0 for Snapshot, 1 for Raskar-code, 2 for rand-code, 3 for constant to 1 code, 4 for Sinc-code: sinc code is the best code given v 5 for motion-invariant photography code; |
(positive | float) "SNR" (Signal-to-Noise Ratio) for the level 100 : 100 (default)" @param (int) " Flag_{NUM | ANALOG}" is "0" or "1" Flutter-shutter type "0 for Analog Flutter OR 1 for Numerical Flutter" @param (float) "Velocity" v is a number" it is the relative velocity between the camera and the landscape counted in pixels per time unit $$ |
(positive | float) : the temporal sampling of the flutter shutter function |
Imacquired.png | : file name for observed image (PNG file) |
ImReconstructed.png ,: | file name for recovered from the observed image (PNG file) |
Groundtruth.png | : file name for the ideal recovered image (PNG file) |
Imdiff.png | : image difference between the recovered and the ideal recovered (PNG file) |
code_file_name.txt | : file name for file that contains the code coefficients $a_k$ (txt file), used for plot generation later on |
FT_code_file_name.txt | : file name for file that contains the Fourier transform of the flutter Shutter function coming from the code, used for plot generation later on |
Color images : each channel is processed independantly
# Readme file for The flutter shutter camera simulator. Basic use : (compile : make) example : ./demo_flutter boat.png 1 100 0 1 1 imacquired.png imreconstructed.png groundtruth.png imdiff.png code.txt FT_code.txt ./demo_flutter ImageIN.png Flag_{code} SNR Flag_{NUM : 1 | ANALOG : 0} Velocity Deltat Imacquired.png ImReconstructed.png Groundtruth.png Imdiff.png code.txt FT_code.txt Flag_{code} : 0 Snapshot, 1 for Agrawal, 2 for rand-code, 3 for constant 1 code, 4 for Sinc-code (sinc code is the best code for |v.deltat|=1), 5 for motion-invariant photography code; Flag_{NUM : 1 | ANALOG : 0} : 1 for numerical flutter shutter, 0 for analog flutter shutter; SNR>0 : for level 100 (mean/std-dev) for signal dependant noise; Velocity : of the landscape in pixel per deltat (float); Deltat>0 : temporal sampling of the (coded) flutter shutter function; Notice : |v.deltat|<2 for any flutter shutter code. ImageIN.png must be PNG (color or grayscale) image (input iamge) Output images : Imacquired.png, ImReconstructed.png, Groundtruth.png, Imdiff.png are all grayscale images. Output txt-files : code.txt FT_code.txt example : ./demo_flutter boat.png 1 100 0 1 1 imacquired.png imrconstructed.png groundtruth.png imdiff.png code.txt FT_code.txt # ABOUT * Author : Yohann Tendero <tendero@cmla.ens-cachan.fr> * Copyright : (C) 2012, IPOL Image Processing On Line http://www.ipol.im/ * Licence : GPL v3+, see GPLv3.txt # OVERVIEW This source code provides in implementation of the algorithm described in http://www.ipol.im/pub/algo/mrt_flutter_shutter/ * the executable file is demo_flutter This program reads and write PNG image. - Compilation. Automated compilation requires the make program. - Library. This code requires the libpng librarym and uses the io_png routines written by Nicolas Limare <nicolas.limare@cmla.ens-cachan.fr> io_png.c is distributed under a GPL3+ or BSD license, at your option. See the included copyright notice, conditions and disclaimer. This code requires the Mersenne Twister pseudo-RNG code Matsumoto, Nishimura. See the included copyright notice, conditions and disclaimer in mt19937ar.c. for details. # COMPILATION 1. Download the code package and extract it. Go to that directory. 2. Compile the source code (on Unix/Linux/Mac OS). run : make # USAGE 'demo_flutter' takes 12 parameters: "Image.png Flag_{code} SNR Flag_{NUM | ANALOG} Velocity Deltat Imacquired.png ImReconstructed.png Groundtruth.png Imdiff.png code.txt FT_code.txt" (input) "Input.png" : file name of the input image (PNG file) Image to use for the simulation (grayscale or color) PNG. (input) "Flag_{code}" is a number that indicate the code use. Codes for the Flutter-Shutter Simulator Code : 0 for Snapshot, 1 for Raskar-code, 2 for rand-code, 3 for constant 1 code, 4 for Sinc-code (sinc code is the best code given v) 5 for motion-invariant photography code. (input) "SNR" is a positive float, (Signal-to-Noise Ratio) for the level 100 : 100 (default)" (input) " Flag_{NUM | ANALOG}" is "0" or "1" Flutter-shutter type "0 for Analog Flutter OR 1 for Numerical Flutter" (input) "Velocity" v is a float" it is the relative velocity between the camera and the landscape counted in pixel per time unit $\Deltat$ (input) "Deltat" (positive float) temporal sampling of the flutter shutter function (output) "Imacquired.png" : file name for observed image (PNG file) (output) "ImReconstructed.png ": file name for recovered from the observed image (PNG file) (output) "Groundtruth.png" : file name for the ideal recovered image (PNG file) (output) "Imdiff.png" : image difference between the recovered and the ideal recovered (PNG file) (output) "code_file_name.txt" : file name for file that contains the code coefficients $a_k$ (txt file), used for plot generation later on (output) "FT_code_file_name.txt" : file name for file that contains the Fourier transform of the flutter Shutter function coming from the code, used for (output) Standard output (printf) : RMSE and RMSE contrast invariant (RMSE contrast invariant is the RMSE after contrast normalization) example : ./demo_flutter boat.png 1 100 0 1 1 imacquired.png imrconstructed.png groundtruth.png imdiff.png code.txt FT_code.txt # ABOUT THIS FILE Copyright 2012 IPOL Image Processing On Line http://www.ipol.im/ Author: Yohann Tendero <tendero@cmla.ens-cachan.fr> Copying and distribution of this file, with or without modification, are permitted in any medium without royalty provided the copyright notice and this notice are preserved. This file is offered as-is, without any warranty.
The steps are the following 1) Read image 2) Simulate the observed 3) Crop (realistic acquisition is non periodic) : of the observed 4) Deconvolve (on the symetrized observed) then crop again 5) Steps5- Compute RMSE, difference (residual noise), write output,etc.
image
width an height of the image
Allocating & initializing
Allocating, init
Step2 Simulate observed
Step3 Crop to avoid periodization (Step3)
Cropping for output images
Transfer to standard color format and normalize the acquired for display (by $ (t) dt$)
CROP IMAGE FOR DIFFERENCE.
The following realize a CROP
Acquired
Reconstruced
Groundtruth
RMSE computation
IMPOSING DYNAMIC[0,255]
Difference
CSV-like files for kernel (flutter shutter fonction and its Fourier transform) to use with gnuplot or similar.
1) WRITE the code into file : code_file_name
2) WRITE the Fourier transform code into file : code_file_name
crop to speed up a little
AVOIDING 3 FIRSTs AND 3 LASTs COLUMNS TO AVOID BORDERS EFFECTS.
RMSE CI is the RMSE AFTER NORMALIZATION OF CONTRAST. For color images the constrast is normalized independantly
Definition at line 153 of file demo_flutter.cpp.