Commit 8d3a590d authored by sarthou's avatar sarthou
Browse files

Code working, modification of Patch Match mex for trying a personal RNG

parent 88eeb304
......@@ -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);
......
......@@ -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 = ((rand1%( (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 = ((rand2%( (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 = ((rand3%( (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>
......
......@@ -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>
......
#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);
}
#ifndef TEST_MEX_RAND_H
#define TEST_MEX_RAND_H
int rand1(int lim);
#endif //TEST_MEX_RAND_H
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment