Commit e28f425f authored by sarthou's avatar sarthou
Browse files

Working on inserting Matlab data in onion peel initialisation, still to do: Grad and DispA

parent 600223a6
......@@ -11,4 +11,6 @@ Data/
tests/
resources/tests/
InpaintingAlgorithm/tests/
algorithm/inpainting/libinpainting.a
inpaintingAlgorithmRun
This diff is collapsed.
......@@ -45,23 +45,8 @@ void InpaintingConverger::Inpaint(InpaintingDataSource * const iDataSource, Inpa
residual = iReconstructor->Reconstruct(&detailedOcclusionDataSource, false);
}
iProfiler->AfterInpaintingIteration(curLevel, iteration);
// // // Output of Disp Matrix for debug
// std::cout << "DimDisp = (" << detailedOcclusionDataSource.GetDispX()->GetDimension()->GetSizeX()\
// <<":"<< detailedOcclusionDataSource.GetDispX()->GetDimension()->GetSizeY()<< ":" << \
// detailedOcclusionDataSource.GetDispX()->GetDimension()->GetSizeZ()<<")"<< std::endl;
//std::cout << "No" << (downsamplingLevels-curLevel)*100+iteration <<std::endl;
//detailedOcclusionDataSource.GetDispX()->GetFrame(nbFrame)->Mprint();
/*
for(int nbFrame=0;nbFrame<detailedOcclusionDataSource.GetDispX()->GetDimension()->GetSizeZ();nbFrame++ )
{
detailedOcclusionDataSource.GetDispX()->GetFrame(nbFrame)->MprintToCSV("Data/debug/SaveDispX_"+std::to_string(nbFrame)+"_" + std::to_string((downsamplingLevels-curLevel)*100+iteration));
detailedOcclusionDataSource.GetDispY()->GetFrame(nbFrame)->MprintToCSV("Data/debug/SaveDispY_"+std::to_string(nbFrame)+"_" + std::to_string((downsamplingLevels-curLevel)*100+iteration));
detailedOcclusionDataSource.GetDispZ()->GetFrame(nbFrame)->MprintToCSV("Data/debug/SaveDispZ_"+std::to_string(nbFrame)+"_" + std::to_string((downsamplingLevels-curLevel)*100+iteration));
}*/
}
if(curLevel != 0)
downsampledDataSource.UpsampleShiftMatrices();
......@@ -82,40 +67,18 @@ void InpaintingConverger::OnionPeelInitialisation(InpaintingDataSource * const i
// Slowly peel back the layers!
int peelNo = 0;
do{
// peelingDataSource.GetOcc()->GetFrame(0)->Mprint();
// peelingDataSource.GetOcc()->GetFrame(0)->MprintToCSV("Data/onion_debug/OccF0_"+std::to_string(peelNo));
iProfiler->BeforeInitialisationPeel(peelNo);
// for(int nbFrame=0;nbFrame<peelingDataSource.GetDispX()->GetDimension()->GetSizeZ();nbFrame++ )
// {
// peelingDataSource.GetDispX()->GetFrame(nbFrame)->MprintToCSV("Data/debug/debug_init/InitBeforeDispX_"+std::to_string(nbFrame)+"_" + std::to_string(peelNo));
// peelingDataSource.GetDispY()->GetFrame(nbFrame)->MprintToCSV("Data/debug/debug_init/InitBeforeDispY_"+std::to_string(nbFrame)+"_" + std::to_string(peelNo));
// peelingDataSource.GetDispZ()->GetFrame(nbFrame)->MprintToCSV("Data/debug/debug_init/InitBeforeDispZ_"+std::to_string(nbFrame)+"_" + std::to_string(peelNo));
// }
iSearcher->Search(&peelingDataSource, true);
iReconstructor->Reconstruct(&peelingDataSource, true);
//
// for(int nbFrame=0;nbFrame<peelingDataSource.GetDispX()->GetDimension()->GetSizeZ();nbFrame++ )
// {
// peelingDataSource.GetDispX()->GetFrame(nbFrame)->MprintToCSV("Data/onion_debug/InitAfterDispX_"+std::to_string(peelNo)+"_F" + std::to_string(nbFrame));
// peelingDataSource.GetDispY()->GetFrame(nbFrame)->MprintToCSV("Data/onion_debug/InitAfterDispY_"+std::to_string(peelNo)+"_F" + std::to_string(nbFrame));
// peelingDataSource.GetDispZ()->GetFrame(nbFrame)->MprintToCSV("Data/onion_debug/InitAfterDispZ_"+std::to_string(peelNo)+"_F" + std::to_string(nbFrame));
// }
//
// for(int i = 0; i < peelingDataSource.GetDim()->GetSizeZ(); ++i)
// openCVIO.GeneralIOForRGB(peelingDataSource.GetRed(), peelingDataSource.GetGreen(), peelingDataSource.GetBlue(), i,
// InpaintingIO::IH_DBG_SAVE, "Data/onion_debug/Onion_"+std::to_string(peelNo)+"_F" + std::to_string(i));
iProfiler->AfterInitialisationPeel(peelNo++);
}while(peelingDataSource.Peel());
// for(int i = 0; i < peelingDataSource.GetDim()->GetSizeZ(); ++i){
// peelingDataSource.GetOcc()->GetFrame(i)->MprintToCSV("Data/onion_debug/OccF"+std::to_string(i));
// }
iProfiler->AfterInitialisation();
}
// TODO On doit compléter l'initiatlisation par chargement avec les matrices de déplacement en .csv
void InpaintingConverger::LoadingInitialisation(InpaintingDataSource * const iDataSource,InpaintingProfiler * const iProfiler){
iProfiler->BeforeInitialisation();
InpaintingOpenCVIO openCVIO = InpaintingOpenCVIO();
......@@ -123,18 +86,27 @@ void InpaintingConverger::LoadingInitialisation(InpaintingDataSource * const iDa
openCVIO.LoadRGBMatrixFromVideo("Data/onion_debug/peel_compare/umbrella_after_peel.avi",\
iDataSource->GetRed(), iDataSource->GetGreen(), iDataSource->GetBlue());
openCVIO.LoadOcclusionMatrixFromImage("Data/onion_debug/Occ/OccF0.png",iDataSource->GetOcc());
PaddedMatrix<int> * const frame_x = new PaddedMatrix<int>(iDataSource->GetDim());
PaddedMatrix<int> * const frame_y = new PaddedMatrix<int>(iDataSource->GetDim());
PaddedMatrix<int> * const frame_z = new PaddedMatrix<int>(iDataSource->GetDim());
for(int nbFrame=0;nbFrame<iDataSource->GetDim()->GetSizeZ();nbFrame++)
{
openCVIO.LoadMatrixFromCSV("Data/onion_debug/peel_compare/end_peel_disp/M_EndPeel_DispX_"\
+std::to_string(nbFrame)+".csv",iDataSource->GetDispX(),1);
+std::to_string(nbFrame)+".csv",frame_x,1);
iDataSource->GetDispX()->SetFrame(frame_x,nbFrame);
openCVIO.LoadMatrixFromCSV("Data/onion_debug/peel_compare/end_peel_disp/M_EndPeel_DispY_"\
+std::to_string(nbFrame)+".csv",iDataSource->GetDispY(),1);
openCVIO.LoadMatrixFromCSV("Data/onion_debug/peel_compare/end_peel_disp/M_EndPeel_DispZ_"\
+std::to_string(nbFrame)+".csv",iDataSource->GetDispZ(),1);
+std::to_string(nbFrame)+".csv",frame_y,1);
iDataSource->GetDispY()->SetFrame(frame_y,nbFrame);
openCVIO.LoadMatrixFromCSV("Data/onion_debug/peel_compare/end_peel_disp/M_EndPeel_DispZ_"\
+std::to_string(nbFrame)+".csv",frame_z,1);
iDataSource->GetDispZ()->SetFrame(frame_z,nbFrame);
}
//iDataSource->GetDispX()->GetFrame(27)->Mprint();
iProfiler->AfterInitialisation();
}
......@@ -20,8 +20,10 @@ template <class T> void InpaintingIO::LoadMatrixFromCSV(std::string csvFilename,
lineStream << line;
while(std::getline(lineStream, value, ',') && itOk){
loadedMatrix->GetData()[matIt.GetPosition()] = std::stof(value) * multiplyBy;
// std::cout <<loadedMatrix->GetData()[matIt.GetPosition()] <<";";
itOk = matIt.Next();
}
// std::cout << std::endl;
lineStream.clear();
}
}
......@@ -52,4 +54,4 @@ template <class T> void InpaintingIO::LoadMatrixFromBin(std::string binFilename,
}
template void InpaintingIO::LoadMatrixFromBin<float>(std::string binFilename, PaddedMatrix<float> *loadedMatrix, float multiplyBy);
template void InpaintingIO::LoadMatrixFromBin<int>(std::string binFilename, PaddedMatrix<int> *loadedMatrix, float multiplyBy);
\ No newline at end of file
template void InpaintingIO::LoadMatrixFromBin<int>(std::string binFilename, PaddedMatrix<int> *loadedMatrix, float multiplyBy);
......@@ -28,6 +28,7 @@ template <class T> T PaddedMatrix<T>::Get(int x, int y, int z){
template <class T> PaddedMatrix<T>* PaddedMatrix<T>::GetFrame(int z)
{
// WARNING: Cette méthode renvoie une copie de la frame, la modifier ne modifie donc pas le volume
PaddedMatrixDim * NewDim = new PaddedMatrixDim(dim->GetSizeX(),dim->GetSizeY(),1);
PaddedMatrix<T> * const frame = new PaddedMatrix<T>(NewDim);
......@@ -36,14 +37,37 @@ template <class T> PaddedMatrix<T>* PaddedMatrix<T>::GetFrame(int z)
for(int j=0; j< dim->GetSizeY(); j++)
{
T temp = this->Get(i,j,z);
// std::cout << this->Get(i,j,z) << std::endl;
//std::cout << temp << ";";
frame->Set(i,j,0,temp);
}
//std::cout << std::endl;
}
return frame;
}
template <class T> int PaddedMatrix<T>::SetFrame(PaddedMatrix<T>* _frame, int nbFrame){
if(_frame->GetDimension()->GetSizeX()!= this->GetDimension()->GetSizeX() || _frame->GetDimension()->GetSizeY()!= this->GetDimension()->GetSizeY()){
std::cout << "Problème de dimension entre la frame d'entrée et la matrice" << std::endl;
return -1;
}
else
{
for(int i = 0; i< dim->GetSizeX(); i++)
{
for(int j=0; j< dim->GetSizeY(); j++)
{
T temp = _frame->Get(i,j,0);
this->Set(i,j,nbFrame,temp);
}
}
return 0;
}
}
template <class T> void PaddedMatrix<T>::Mprint(){
int x = dim->GetSizeX();
int y = dim->GetSizeY();
......
......@@ -32,6 +32,8 @@ public:
PaddedMatrixDim const * const GetDimension();
PaddedMatrix<T>* GetFrame(int z);
int SetFrame(PaddedMatrix<T>* _frame, int nbFrame);
void Mprint();
void MprintToCSV(std::string filename);
......
#include <iostream>
#include <typeinfo>
#include "algorithm/inpainting/searchers/ISFull.h"
#include "algorithm/inpainting/searchers/ISProfiler.h"
#include "algorithm/inpainting/reconstructors/IRProfiler.h"
......@@ -19,6 +20,7 @@ int main(){
profiler.BeforeInpainting();
// Select and parameterize the algorithms
InpaintingEvaluator evaluationAlgo = InpaintingEvaluator(50, 5, 5, 5);
ISRandom searchAlgo = ISRandom(20, &evaluationAlgo); //initiated at 20, but 10 in Matlab code
......@@ -36,6 +38,24 @@ int main(){
int sizeX, sizeY, sizeZ;
openCVIO.GetVideoDimensions(videoFileName, sizeX, sizeY, sizeZ);
/*
PaddedMatrixDim * const testdim = new PaddedMatrixDim(66,17,98);
PaddedMatrixDim * const testdimframe = new PaddedMatrixDim(66,17,1);
PaddedMatrix<float> * const occTestMatrix = new PaddedMatrix<float>(testdim);
PaddedMatrix<float> * const TestFrame = new PaddedMatrix<float>(testdimframe);
// std::cout << "(" << occTestMatrix->GetFrame(27)->GetDimension()->GetSizeX()<<\
// ":"<<occTestMatrix->GetFrame(27)->GetDimension()->GetSizeY() << ":"<<\
// occTestMatrix->GetFrame(27)->GetDimension()->GetSizeZ() <<")"<<std::endl;
// std::cout << typeid(occTestMatrix->GetFrame(27)).name() << std::endl;
openCVIO.LoadMatrixFromCSV("Data/onion_debug/peel_compare/end_peel_disp/M_EndPeel_DispX_27.csv",TestFrame,1);
std::cout << "Affichage"<<std::endl;
occTestMatrix->SetFrame(TestFrame,27);
occTestMatrix->GetFrame(27)->Mprint();
//std::cout << occTestMatrix->GetData()[30294] << std::endl;
*/
PaddedMatrixDim * const dim = new PaddedMatrixDim(sizeX, sizeY, sizeZ, 2, 2, 2);
PaddedMatrix<float> * const redMatrix = new PaddedMatrix<float>(dim);
PaddedMatrix<float> * const greenMatrix = new PaddedMatrix<float>(dim);
......@@ -57,8 +77,8 @@ int main(){
for(int i = 0; i < baseIPS.GetDim()->GetSizeZ(); ++i)
openCVIO.GeneralIOForRGB(baseIPS.GetRed(), baseIPS.GetGreen(), baseIPS.GetBlue(), i,
InpaintingIO::IH_DBG_SAVE, "Data/onion_debug/CppOut_WithMatlabInput_F" + std::to_string(i));
profiler.AfterInpainting();
return 0;
}
Supports Markdown
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