-
Notifications
You must be signed in to change notification settings - Fork 0
/
DepthFromDefocus.c
69 lines (55 loc) · 2.3 KB
/
DepthFromDefocus.c
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
#include <stdio.h>
#include <string.h>
#include <stdlib.h>
#include "include.h"
int main( int argc, char* argv[]){
printf("Depth From Defocus depth estimation\n");
/*----------------------------------------*/
/* read inputs arguments */
/*----------------------------------------*/
IMG* inputLeft = readImage( argv[1] );
IMG* inputRight = readImage( argv[2] );
IMG* apertureLeft = readImage( argv[3] );
IMG* apertureRight = readImage( argv[4] );
if( inputLeft && inputRight && apertureLeft && apertureRight == NULL){
printf("input argumetns are wrong\n");
printf("arg[0] : process name %s\n", argv[0]);
printf("arg[1] : left input image : %s\n", argv[1]);
printf("arg[2] : right input image : %s\n", argv[2]);
printf("arg[3] : left psf image : %s\n", argv[3]);
printf("arg[4] : right psf image : %s\n", argv[4]);
return 0;
}
double paramLeft[2], paramRight[2];
paramLeft[0] = atof( argv[5] );
paramLeft[1] = atof( argv[6] );
paramRight[0] = atof( argv[7] );
paramRight[1] = atof( argv[8] );
printf( "parameter left = %lf , %lf\n", paramLeft[0], paramLeft[1]);
printf( "parameter right = %lf , %lf\n", paramRight[0], paramRight[1]);
// save images to debug directry (dirname : argv[argc-2] )
if( isalpha( argv[argc-2][0] )){
strcpy( tmpImagesDir, argv[argc-2] );
saveDebugImages = YES;
printf("save debugging images to %s\n", tmpImagesDir);
}else{
saveDebugImages = NO;
}
printf("save images to %s\n", argv[argc-1]);
/*----------------------------------------*/
/* make psf in freq */
/*----------------------------------------*/
freq *psfLeft[MAX_DISPARITY];
freq *psfRight[MAX_DISPARITY];
makeBlurPSFFreq( apertureLeft, paramLeft, psfLeft,
Point( inputLeft->width, inputLeft->height), MAX_DISPARITY);
makeBlurPSFFreq( apertureRight, paramRight, psfRight,
Point( inputRight->width, inputRight->height), MAX_DISPARITY);
/*----------------------------------------*/
/* depth estimation */
/*----------------------------------------*/
IMG* dst = latentBaseEstimationIMG( inputLeft, inputRight, psfLeft, psfRight);
//IMG* dst = deblurBaseEstimationIMGFreq( inputLeft, inputRight, psfLeft, psfRight );
saveImage( dst, argv[argc-1] );
return 0;
}