Skip to content
GitLab
Menu
Projects
Groups
Snippets
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
Menu
Open sidebar
Sarthou Benoît
PRE
Commits
8d3a590d
Commit
8d3a590d
authored
Jul 31, 2017
by
sarthou
Browse files
Code working, modification of Patch Match mex for trying a personal RNG
parent
88eeb304
Changes
7
Hide whitespace changes
Inline
Side-by-side
MATLAB Inpainting/Patch_match/patch_match.cpp
View file @
8d3a590d
...
...
@@ -158,7 +158,7 @@ nTupleVolume<T> * patch_match_ANN(nTupleVolume<T> *imgVolA, nTupleVolume<T> *img
}
else
//normal patchMatch
{
//
srand(0);
srand
(
0
);
mexPrintf
(
"Initialisation
\n
"
);
initialise_displacement_field
(
dispField
,
imgVolA
,
imgVolB
,
firstGuessVol
,
imgVolOcc
,
params
);
...
...
MATLAB Inpainting/Patch_match/patch_match_tools.cpp
View file @
8d3a590d
...
...
@@ -164,6 +164,21 @@ void initialise_displacement_field(
hPatchSizeCeilY
=
(
int
)
ceil
(((
float
)
arrivalVolume
->
patchSizeY
)
/
2
);
hPatchSizeCeilT
=
(
int
)
ceil
(((
float
)
arrivalVolume
->
patchSizeT
)
/
2
);
long
a
=
100001
;
std
::
ofstream
fichier
(
"save_rand.txt"
,
std
::
ios
::
out
|
std
::
ios
::
app
);
//déclaration du flux et ouverture du fichier
if
(
fichier
)
{
std
::
cout
<<
"Ouverture"
<<
std
::
endl
;
}
else
{
std
::
cout
<<
"Erreur à l'ouverture !"
<<
std
::
endl
;
}
fichier
<<
"
\n
Disp Init
\n
"
;
for
(
i
=
0
;
i
<
(
dispField
->
xSize
);
i
++
)
for
(
j
=
0
;
j
<
(
dispField
->
ySize
);
j
++
)
for
(
k
=
0
;
k
<
(
dispField
->
tSize
);
k
++
)
...
...
@@ -182,28 +197,40 @@ void initialise_displacement_field(
isNotOcc
=
!
check_is_occluded
(
occVol
,
xDisp
+
i
,
yDisp
+
j
,
tDisp
+
k
)
&&
check_in_inner_boundaries
(
arrivalVolume
,
xDisp
+
i
,
yDisp
+
j
,
tDisp
+
k
,
params
);
//int randcount = 0;
//if there is a valid first guess
while
(
isNotOcc
==
0
){
a
=
(
a
*
125
)
%
2796203
;
int
rand1
=
a
;
a
=
(
a
*
125
)
%
2796203
;
int
rand2
=
a
;
a
=
(
a
*
125
)
%
2796203
;
int
rand3
=
a
;
fichier
<<
"("
<<
rand1
<<
","
<<
rand2
<<
","
<<
rand3
<<
")"
;
//MY_PRINTF("(%d,%d,%d)",rand1,rand2,rand3);
//randcount = randcount + 1;
// Special case where the patch size is the size of the dimension
if
(
arrivalVolume
->
xSize
==
arrivalVolume
->
patchSizeX
)
xDisp
=
0
;
else
xDisp
=
((
rand
()
%
(
(
arrivalVolume
->
xSize
)
-
2
*
hPatchSizeCeilX
-
1
))
+
hPatchSizeX
)
-
i
;
xDisp
=
((
rand
1
%
(
(
arrivalVolume
->
xSize
)
-
2
*
hPatchSizeCeilX
-
1
))
+
hPatchSizeX
)
-
i
;
if
(
arrivalVolume
->
ySize
==
arrivalVolume
->
patchSizeY
)
yDisp
=
0
;
else
yDisp
=
((
rand
()
%
(
(
arrivalVolume
->
ySize
)
-
2
*
hPatchSizeCeilY
-
1
))
+
hPatchSizeY
)
-
j
;
yDisp
=
((
rand
2
%
(
(
arrivalVolume
->
ySize
)
-
2
*
hPatchSizeCeilY
-
1
))
+
hPatchSizeY
)
-
j
;
if
(
arrivalVolume
->
tSize
==
arrivalVolume
->
patchSizeT
)
tDisp
=
0
;
else
tDisp
=
((
rand
()
%
(
(
arrivalVolume
->
tSize
)
-
2
*
hPatchSizeCeilT
-
1
))
+
hPatchSizeT
)
-
k
;
tDisp
=
((
rand
3
%
(
(
arrivalVolume
->
tSize
)
-
2
*
hPatchSizeCeilT
-
1
))
+
hPatchSizeT
)
-
k
;
isNotOcc
=
!
check_is_occluded
(
occVol
,
xDisp
+
i
,
yDisp
+
j
,
tDisp
+
k
)
&&
check_in_inner_boundaries
(
arrivalVolume
,
xDisp
+
i
,
yDisp
+
j
,
tDisp
+
k
,
params
);
}
fichier
<<
"//"
;
//MY_PRINTF("randcount: %d",randcount);
if
(
check_in_inner_boundaries
(
departVolume
,
i
,
j
,
k
,
params
))
ssdTemp
=
ssd_patch_measure
<
T
>
(
departVolume
,
arrivalVolume
,
dispField
,
occVol
,
i
,
j
,
k
,
i
+
xDisp
,
j
+
yDisp
,
k
+
tDisp
,
-
1
,
params
);
else
...
...
@@ -214,7 +241,9 @@ void initialise_displacement_field(
dispField
->
set_value
(
i
,
j
,
k
,
1
,(
T
)
yDisp
);
dispField
->
set_value
(
i
,
j
,
k
,
2
,(
T
)
tDisp
);
dispField
->
set_value
(
i
,
j
,
k
,
3
,(
T
)
ssdTemp
);
//set the ssd error
//MY_PRINTF("\n");
}
fichier
.
close
();
}
template
<
class
T
>
...
...
MATLAB Inpainting/Patch_match/patch_match_tools.h
View file @
8d3a590d
...
...
@@ -6,6 +6,7 @@
#include "common_patch_match.h"
#include "../Image_structures/image_structures.h"
#include "patch_match_measure.h"
bool
check_min_shift_distance
(
int
xShift
,
int
yShift
,
int
tShift
,
const
parameterStruct
*
params
);
template
<
class
T
>
...
...
MATLAB Inpainting/Patch_match/spatio_temporal_patch_match_mex.mexa64
View file @
8d3a590d
No preview for this file type
MATLAB Inpainting/test_mex_rand.cpp
View file @
8d3a590d
#include <stdio.h>
#include <stdlib.h>
#include <fstream>
#include <iostream>
#include <mex.h>
#include "test_mex_rand.h"
void
mexFunction
(
int
nlhs
,
mxArray
*
plhs
[],
int
nrhs
,
const
mxArray
*
prhs
[])
{
srand
(
0
);
/* Now generate 5 pseudo-random numbers */
int
i
;
int
lim
=
100
;
long
a
=
100001
;
std
::
ofstream
fichier
(
"save_rand.txt"
,
std
::
ios
::
out
|
std
::
ios
::
app
);
//déclaration du flux et ouverture du fichier
if
(
fichier
)
{
std
::
cout
<<
"Ouverture"
<<
std
::
endl
;
}
else
{
std
::
cout
<<
"Erreur à l'ouverture !"
<<
std
::
endl
;
}
for
(
i
=
0
;
i
<
5
;
i
++
)
{
mexPrintf
(
"rand[%d]= %u
\n
"
,
i
,
rand
());
a
=
(
a
*
125
)
%
2796203
;
fichier
<<
a
;
// mexPrintf("%u\n",((a % lim) + 1));
// mexPrintf ("rand1[%d]= %u\n",
// i, rand1(100));
// mexPrintf ("rand[%d]= %u\n",
// i, rand());
}
fichier
.
close
();
return
;
}
int
rand1
(
int
lim
)
{
static
long
a
=
100001
;
a
=
(
a
*
125
)
%
2796203
;
return
((
a
%
lim
)
+
1
);
}
MATLAB Inpainting/test_mex_rand.h
0 → 100644
View file @
8d3a590d
#ifndef TEST_MEX_RAND_H
#define TEST_MEX_RAND_H
int
rand1
(
int
lim
);
#endif //TEST_MEX_RAND_H
MATLAB Inpainting/test_mex_rand.mexa64
View file @
8d3a590d
No preview for this file type
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment