Commit b775485d authored by sarthou's avatar sarthou
Browse files

Modyfing upsample python compare for more adaptablity, code in main.cpp to...

Modyfing upsample python compare for more adaptablity, code in main.cpp to evaluate search func, beware of output in matlab and pixel limit in ISRandom.cpp
parent 2f833ad3
...@@ -256,8 +256,8 @@ void ISRandom::InitialiseDisplacementField(InpaintingDataSource * const iDataPro ...@@ -256,8 +256,8 @@ void ISRandom::InitialiseDisplacementField(InpaintingDataSource * const iDataPro
PaddedMatrixIt volIt = PaddedMatrixIt(levelDim); PaddedMatrixIt volIt = PaddedMatrixIt(levelDim);
do{ do{
// if(detailOccData[volIt.GetPosition()] < DOCC_BORDER) if(detailOccData[volIt.GetPosition()] < DOCC_NEAROCC)
// continue; continue;
int xDispT = dispXData[volIt.GetPosition()]; int xDispT = dispXData[volIt.GetPosition()];
int yDispT = dispYData[volIt.GetPosition()]; int yDispT = dispYData[volIt.GetPosition()];
...@@ -268,8 +268,6 @@ void ISRandom::InitialiseDisplacementField(InpaintingDataSource * const iDataPro ...@@ -268,8 +268,6 @@ void ISRandom::InitialiseDisplacementField(InpaintingDataSource * const iDataPro
volIt.GetCurY(), yDispT, volIt.GetCurY(), yDispT,
volIt.GetCurZ(), zDispT); volIt.GetCurZ(), zDispT);
while(status != 0){ while(status != 0){
// WARNING: MODIFIED FOR ONLY ONE RAND CALL, QUICKER BUT NOT EFFICIENT
//int test = rand();
xDispT = rand() % (levelDim->GetSizeX() - 2 * patchHalfSize - 1) + patchHalfSize - volIt.GetCurX(); xDispT = rand() % (levelDim->GetSizeX() - 2 * patchHalfSize - 1) + patchHalfSize - volIt.GetCurX();
yDispT = rand() % (levelDim->GetSizeY() - 2 * patchHalfSize - 1) + patchHalfSize - volIt.GetCurY(); yDispT = rand() % (levelDim->GetSizeY() - 2 * patchHalfSize - 1) + patchHalfSize - volIt.GetCurY();
zDispT = rand() % (levelDim->GetSizeZ() - 2 * patchHalfSize - 1) + patchHalfSize - volIt.GetCurZ(); zDispT = rand() % (levelDim->GetSizeZ() - 2 * patchHalfSize - 1) + patchHalfSize - volIt.GetCurZ();
......
...@@ -52,57 +52,12 @@ int main(){ ...@@ -52,57 +52,12 @@ int main(){
openCVIO.LoadOcclusionMatrixFromImage(occFileName, occMatrix); openCVIO.LoadOcclusionMatrixFromImage(occFileName, occMatrix);
IDSConcrete baseIPS = IDSConcrete(dim, redMatrix, greenMatrix, blueMatrix, occMatrix); IDSConcrete baseIPS = IDSConcrete(dim, redMatrix, greenMatrix, blueMatrix, occMatrix);
/*
// Work for testing upsampe algorithm
IDSDDownsampling downsampledDataSource = IDSDDownsampling(&baseIPS, 3, 2);
PaddedMatrix<int> * const frame_x = new PaddedMatrix<int>(downsampledDataSource.GetDim());
PaddedMatrix<int> * const frame_y = new PaddedMatrix<int>(downsampledDataSource.GetDim());
PaddedMatrix<int> * const frame_z = new PaddedMatrix<int>(downsampledDataSource.GetDim());
PaddedMatrix<float> * const frame_a = new PaddedMatrix<float>(downsampledDataSource.GetDim());
for(int nbFrame=0;nbFrame<downsampledDataSource.GetDim()->GetSizeZ();nbFrame++)
{
openCVIO.LoadMatrixFromCSV("Data/upsample_ant/UA_matlab/M_UA_Ante_DispX_F"\
+std::to_string(nbFrame)+".csv",frame_x,1);
downsampledDataSource.GetDispX()->SetFrame(frame_x,nbFrame);
openCVIO.LoadMatrixFromCSV("Data/upsample_ant/UA_matlab/M_UA_Ante_DispY_F"\
+std::to_string(nbFrame)+".csv",frame_y,1);
downsampledDataSource.GetDispY()->SetFrame(frame_y,nbFrame);
openCVIO.LoadMatrixFromCSV("Data/upsample_ant/UA_matlab/M_UA_Ante_DispZ_F"\
+std::to_string(nbFrame)+".csv",frame_z,1);
downsampledDataSource.GetDispZ()->SetFrame(frame_z,nbFrame);
openCVIO.LoadMatrixFromCSV("Data/upsample_ant/UA_matlab/M_UA_Ante_DispA_F"\
+std::to_string(nbFrame)+".csv",frame_a,1);
downsampledDataSource.GetDispA()->SetFrame(frame_a,nbFrame);
}
//downsampledDataSource.GetDispX()->GetFrame(70)->Mprint();
downsampledDataSource.MatlabUpsampleShiftMatrix();
// downsampledDataSource.UpsampleShiftMatrices();
downsampledDataSource.SetCurLevel(1);
//downsampledDataSource.GetDispX()->GetFrame(70)->Mprint();
for(int nbFrame=0;nbFrame < downsampledDataSource.GetDim()->GetSizeZ();nbFrame++)
{
downsampledDataSource.GetDispX()->GetFrame(nbFrame)->MprintToCSV("Data/upsample_ant/Cpp_UA_DispX_F"+std::to_string(nbFrame));
downsampledDataSource.GetDispY()->GetFrame(nbFrame)->MprintToCSV("Data/upsample_ant/Cpp_UA_DispY_F"+std::to_string(nbFrame));
downsampledDataSource.GetDispZ()->GetFrame(nbFrame)->MprintToCSV("Data/upsample_ant/Cpp_UA_DispZ_F"+std::to_string(nbFrame));
downsampledDataSource.GetDispA()->GetFrame(nbFrame)->MprintToCSV("Data/upsample_ant/Cpp_UA_DispA_F"+std::to_string(nbFrame));
}
std::cout << "End of upsample test"<< std::endl;
*/
/*
int level = 2; int level = 2;
IDSDDownsampling downsampledDataSource = IDSDDownsampling(&baseIPS, 3, 2); IDSDDownsampling downsampledDataSource = IDSDDownsampling(&baseIPS, 3, 2);
downsampledDataSource.SetCurLevel(level); downsampledDataSource.SetCurLevel(level);
openCVIO.LoadRGBMatrixFromVideo("Data/search_reconstruct/SR_matlab/M_SR_Ante_L3.avi",\ openCVIO.LoadRGBMatrixFromVideo("Data/search_ant/L3_I8/M_SA_Ante_L3_I8.avi",\
downsampledDataSource.GetRed(), downsampledDataSource.GetGreen(), downsampledDataSource.GetBlue()); downsampledDataSource.GetRed(), downsampledDataSource.GetGreen(), downsampledDataSource.GetBlue());
PaddedMatrix<int> * const frame_x = new PaddedMatrix<int>(downsampledDataSource.GetDim()); PaddedMatrix<int> * const frame_x = new PaddedMatrix<int>(downsampledDataSource.GetDim());
...@@ -112,53 +67,54 @@ int main(){ ...@@ -112,53 +67,54 @@ int main(){
PaddedMatrix<float> * const frame_gx = new PaddedMatrix<float>(downsampledDataSource.GetDim()); PaddedMatrix<float> * const frame_gx = new PaddedMatrix<float>(downsampledDataSource.GetDim());
PaddedMatrix<float> * const frame_gy = new PaddedMatrix<float>(downsampledDataSource.GetDim()); PaddedMatrix<float> * const frame_gy = new PaddedMatrix<float>(downsampledDataSource.GetDim());
for(int nbFrame=0;nbFrame<downsampledDataSource.GetDim()->GetSizeZ();nbFrame++) for(int nbFrame=0; nbFrame<downsampledDataSource.GetDim()->GetSizeZ(); nbFrame++)
{ {
openCVIO.LoadMatrixFromCSV("Data/search_reconstruct/SR_matlab/M_SR_Ante_DispX_L"\ openCVIO.LoadMatrixFromCSV("Data/search_ant/L3_I8/M_SA_Ante_DispX_L"\
+std::to_string(level+1)+"_F_"+std::to_string(nbFrame)+".csv",frame_x,1); +std::to_string(level+1)+"_I8_F"+std::to_string(nbFrame)+".csv",frame_x,1);
downsampledDataSource.GetDispX()->SetFrame(frame_x,nbFrame); downsampledDataSource.GetDispX()->SetFrame(frame_x,nbFrame);
openCVIO.LoadMatrixFromCSV("Data/search_reconstruct/SR_matlab/M_SR_Ante_DispY_L"\ openCVIO.LoadMatrixFromCSV("Data/search_ant/L3_I8/M_SA_Ante_DispY_L"\
+std::to_string(level+1)+"_F_"+std::to_string(nbFrame)+".csv",frame_y,1); +std::to_string(level+1)+"_I8_F"+std::to_string(nbFrame)+".csv",frame_y,1);
downsampledDataSource.GetDispY()->SetFrame(frame_y,nbFrame); downsampledDataSource.GetDispY()->SetFrame(frame_y,nbFrame);
openCVIO.LoadMatrixFromCSV("Data/search_reconstruct/SR_matlab/M_SR_Ante_DispZ_L"\ openCVIO.LoadMatrixFromCSV("Data/search_ant/L3_I8/M_SA_Ante_DispZ_L"\
+std::to_string(level+1)+"_F_"+std::to_string(nbFrame)+".csv",frame_z,1); +std::to_string(level+1)+"_I8_F"+std::to_string(nbFrame)+".csv",frame_z,1);
downsampledDataSource.GetDispZ()->SetFrame(frame_z,nbFrame); downsampledDataSource.GetDispZ()->SetFrame(frame_z,nbFrame);
openCVIO.LoadMatrixFromCSV("Data/search_reconstruct/SR_matlab/M_SR_Ante_DispA_L"\ openCVIO.LoadMatrixFromCSV("Data/search_ant/L3_I8/M_SA_Ante_DispA_L"\
+std::to_string(level+1)+"_F_"+std::to_string(nbFrame)+".csv",frame_a,1); +std::to_string(level+1)+"_I8_F"+std::to_string(nbFrame)+".csv",frame_a,1);
downsampledDataSource.GetDispA()->SetFrame(frame_a,nbFrame); downsampledDataSource.GetDispA()->SetFrame(frame_a,nbFrame);
openCVIO.LoadMatrixFromCSV("Data/search_reconstruct/SR_matlab/M_SR_Ante_GradX_L"\ openCVIO.LoadMatrixFromCSV("Data/search_ant/L3_I8/M_SA_Ante_GradX_L"\
+std::to_string(level+1)+"_F_"+std::to_string(nbFrame)+".csv",frame_gx,1); +std::to_string(level+1)+"_I8_F"+std::to_string(nbFrame)+".csv",frame_gx,1);
downsampledDataSource.GetGradX()->SetFrame(frame_gx,nbFrame); downsampledDataSource.GetGradX()->SetFrame(frame_gx,nbFrame);
openCVIO.LoadMatrixFromCSV("Data/search_reconstruct/SR_matlab/M_SR_Ante_GradY_L"\ openCVIO.LoadMatrixFromCSV("Data/search_ant/L3_I8/M_SA_Ante_GradY_L"\
+std::to_string(level+1)+"_F_"+std::to_string(nbFrame)+".csv",frame_gy,1); +std::to_string(level+1)+"_I5_F"+std::to_string(nbFrame)+".csv",frame_gy,1);
downsampledDataSource.GetGradY()->SetFrame(frame_gy,nbFrame); downsampledDataSource.GetGradY()->SetFrame(frame_gy,nbFrame);
} }
// downsampledDataSource.GetOcc()->Mprint();
searchAlgo.Search(&downsampledDataSource, false); searchAlgo.Search(&downsampledDataSource, false);
reconstructAlgo.Reconstruct(&downsampledDataSource, false); // reconstructAlgo.Reconstruct(&downsampledDataSource, false);
for(int nbFrame=0;nbFrame < downsampledDataSource.GetDim()->GetSizeZ();nbFrame++) for(int nbFrame=0;nbFrame < downsampledDataSource.GetDim()->GetSizeZ();nbFrame++)
{ {
openCVIO.GeneralIOForRGB(downsampledDataSource.GetRed(), downsampledDataSource.GetGreen(),\ // openCVIO.GeneralIOForRGB(downsampledDataSource.GetRed(), downsampledDataSource.GetGreen(),\
downsampledDataSource.GetBlue(),nbFrame,InpaintingIO::IH_DBG_SAVE,\ // downsampledDataSource.GetBlue(),nbFrame,InpaintingIO::IH_DBG_SAVE,\
"Data/search_reconstruct/CppOut_SR_L"+std::to_string(level+1)+"_F"+ std::to_string(nbFrame)); // "Data/search_reconstruct/CppOut_SR_L"+std::to_string(level+1)+"_F"+ std::to_string(nbFrame));
downsampledDataSource.GetDispX()->GetFrame(nbFrame)->MprintToCSV("Data/search_reconstruct/CppOut_SR_DispX_L"+std::to_string(level+1)+"_F"+std::to_string(nbFrame)); downsampledDataSource.GetDispX()->GetFrame(nbFrame)->MprintToCSV("Data/search_ant/result_L3_I8/CppOut_SA_DispX_L"+std::to_string(level+1)+"_I8_F"+std::to_string(nbFrame));
downsampledDataSource.GetDispY()->GetFrame(nbFrame)->MprintToCSV("Data/search_reconstruct/CppOut_SR_DispY_L"+std::to_string(level+1)+"_F"+std::to_string(nbFrame)); downsampledDataSource.GetDispY()->GetFrame(nbFrame)->MprintToCSV("Data/search_ant/result_L3_I8/CppOut_SA_DispY_L"+std::to_string(level+1)+"_I8_F"+std::to_string(nbFrame));
downsampledDataSource.GetDispZ()->GetFrame(nbFrame)->MprintToCSV("Data/search_reconstruct/CppOut_SR_DispZ_L"+std::to_string(level+1)+"_F"+std::to_string(nbFrame)); downsampledDataSource.GetDispZ()->GetFrame(nbFrame)->MprintToCSV("Data/search_ant/result_L3_I8/CppOut_SA_DispZ_L"+std::to_string(level+1)+"_I8_F"+std::to_string(nbFrame));
downsampledDataSource.GetDispA()->GetFrame(nbFrame)->MprintToCSV("Data/search_reconstruct/CppOut_SR_DispA_L"+std::to_string(level+1)+"_F"+std::to_string(nbFrame)); downsampledDataSource.GetDispA()->GetFrame(nbFrame)->MprintToCSV("Data/search_ant/result_L3_I8/CppOut_SA_DispA_L"+std::to_string(level+1)+"_I8_F"+std::to_string(nbFrame));
downsampledDataSource.GetGradX()->GetFrame(nbFrame)->MprintToCSV("Data/search_reconstruct/CppOut_SR_GradX_L"+std::to_string(level+1)+"_F"+std::to_string(nbFrame)); downsampledDataSource.GetGradX()->GetFrame(nbFrame)->MprintToCSV("Data/search_ant/result_L3_I8/CppOut_SA_GradX_L"+std::to_string(level+1)+"_I8_F"+std::to_string(nbFrame));
downsampledDataSource.GetGradY()->GetFrame(nbFrame)->MprintToCSV("Data/search_reconstruct/CppOut_SR_GradY_L"+std::to_string(level+1)+"_F"+std::to_string(nbFrame)); downsampledDataSource.GetGradY()->GetFrame(nbFrame)->MprintToCSV("Data/search_ant/result_L3_I8/CppOut_SA_GradY_L"+std::to_string(level+1)+"_I8_F"+std::to_string(nbFrame));
} }
std::cout << "End of search/reconstruct test" << std::endl; std::cout << "End of search/reconstruct test" << std::endl;
*/
// Execute the work // Execute the work
inpainter.Inpaint(&baseIPS, &profiler); inpainter.Inpaint(&baseIPS, &profiler);
......
...@@ -132,21 +132,21 @@ function[imgOut, shiftVolOut] = inpaint_video(varargin) ...@@ -132,21 +132,21 @@ function[imgOut, shiftVolOut] = inpaint_video(varargin)
firstGuess = shiftVol+1-1; firstGuess = shiftVol+1-1;
% write_image_volume(imgVol,strcat('matlab_debug/search_reconstruct/M_SR_Ante_Im_L',int2str(ii))); write_image_volume(imgVol,strcat('matlab_debug/search_ant/M_SA_Ante_Im_L',int2str(ii),'_I',int2str(pp)));
% cd matlab_debug/search_reconstruct/ cd matlab_debug/search_ant/
%
% [~,w,l,maxFrame] = size(shiftVol); [~,w,l,maxFrame] = size(shiftVol);
%
% for nbframe=1:maxFrame for nbframe=1:maxFrame
% csvwrite(strcat('M_SR_Ante_DispX_L',int2str(ii),'_F_',int2str(nbframe-1),'.csv'),reshape(shiftVol(1,:,:,nbframe),[w,l])); csvwrite(strcat('M_SA_Ante_DispX_L',int2str(ii),'_I',int2str(pp),'_F',int2str(nbframe-1),'.csv'),reshape(shiftVol(1,:,:,nbframe),[w,l]));
% csvwrite(strcat('M_SR_Ante_DispY_L',int2str(ii),'_F_',int2str(nbframe-1),'.csv'),reshape(shiftVol(2,:,:,nbframe),[w,l])); csvwrite(strcat('M_SA_Ante_DispY_L',int2str(ii),'_I',int2str(pp),'_F',int2str(nbframe-1),'.csv'),reshape(shiftVol(2,:,:,nbframe),[w,l]));
% csvwrite(strcat('M_SR_Ante_DispZ_L',int2str(ii),'_F_',int2str(nbframe-1),'.csv'),reshape(shiftVol(3,:,:,nbframe),[w,l])); csvwrite(strcat('M_SA_Ante_DispZ_L',int2str(ii),'_I',int2str(pp),'_F',int2str(nbframe-1),'.csv'),reshape(shiftVol(3,:,:,nbframe),[w,l]));
% csvwrite(strcat('M_SR_Ante_DispA_L',int2str(ii),'_F_',int2str(nbframe-1),'.csv'),reshape(shiftVol(4,:,:,nbframe),[w,l])); csvwrite(strcat('M_SA_Ante_DispA_L',int2str(ii),'_I',int2str(pp),'_F',int2str(nbframe-1),'.csv'),reshape(shiftVol(4,:,:,nbframe),[w,l]));
% csvwrite(strcat('M_SR_Ante_GradX_L',int2str(ii),'_F_',int2str(nbframe-1),'.csv'),normGradX(:,:,nbframe)); csvwrite(strcat('M_SA_Ante_GradX_L',int2str(ii),'_I',int2str(pp),'_F',int2str(nbframe-1),'.csv'),normGradX(:,:,nbframe));
% csvwrite(strcat('M_SR_Ante_GradY_L',int2str(ii),'_F_',int2str(nbframe-1),'.csv'),normGradY(:,:,nbframe)); csvwrite(strcat('M_SA_Ante_GradY_L',int2str(ii),'_I',int2str(pp),'_F',int2str(nbframe-1),'.csv'),normGradY(:,:,nbframe));
% end end
%
% cd ../.. cd ../..
% Carry out the 3D PatchMatch % Carry out the 3D PatchMatch
shiftVol = spatio_temporal_patch_match_mex(... shiftVol = spatio_temporal_patch_match_mex(...
...@@ -157,6 +157,22 @@ function[imgOut, shiftVolOut] = inpaint_video(varargin) ...@@ -157,6 +157,22 @@ function[imgOut, shiftVolOut] = inpaint_video(varargin)
occVolDilate,... occVolDilate,...
occVolDilate); occVolDilate);
write_image_volume(imgVol,strcat('matlab_debug/search_ant/M_SA_Post_Im_L',int2str(ii)));
cd matlab_debug/search_ant/
[~,w,l,maxFrame] = size(shiftVol);
for nbframe=1:maxFrame
csvwrite(strcat('M_SA_Post_DispX_L',int2str(ii),'_I',int2str(pp),'_F',int2str(nbframe-1),'.csv'),reshape(shiftVol(1,:,:,nbframe),[w,l]));
csvwrite(strcat('M_SA_Post_DispY_L',int2str(ii),'_I',int2str(pp),'_F',int2str(nbframe-1),'.csv'),reshape(shiftVol(2,:,:,nbframe),[w,l]));
csvwrite(strcat('M_SA_Post_DispZ_L',int2str(ii),'_I',int2str(pp),'_F',int2str(nbframe-1),'.csv'),reshape(shiftVol(3,:,:,nbframe),[w,l]));
csvwrite(strcat('M_SA_Post_DispA_L',int2str(ii),'_I',int2str(pp),'_F',int2str(nbframe-1),'.csv'),reshape(shiftVol(4,:,:,nbframe),[w,l]));
csvwrite(strcat('M_SA_Post_GradX_L',int2str(ii),'_I',int2str(pp),'_F',int2str(nbframe-1),'.csv'),normGradX(:,:,nbframe));
csvwrite(strcat('M_SA_Post_GradY_L',int2str(ii),'_I',int2str(pp),'_F',int2str(nbframe-1),'.csv'),normGradY(:,:,nbframe));
end
cd ../../
imgVolCopy = permute(imgVol,[2 3 4 1]); imgVolCopy = permute(imgVol,[2 3 4 1]);
...@@ -186,21 +202,6 @@ function[imgOut, shiftVolOut] = inpaint_video(varargin) ...@@ -186,21 +202,6 @@ function[imgOut, shiftVolOut] = inpaint_video(varargin)
reconstructionType); reconstructionType);
end end
% write_image_volume(imgVol,strcat('matlab_debug/search_reconstruct/M_SR_Post_Im_L',int2str(ii)));
% cd matlab_debug/search_reconstruct/
%
% [~,w,l,maxFrame] = size(shiftVol);
%
% for nbframe=1:maxFrame
% csvwrite(strcat('M_SR_Post_DispX_L',int2str(ii),'_F_',int2str(nbframe-1),'.csv'),reshape(shiftVol(1,:,:,nbframe),[w,l]));
% csvwrite(strcat('M_SR_Post_DispY_L',int2str(ii),'_F_',int2str(nbframe-1),'.csv'),reshape(shiftVol(2,:,:,nbframe),[w,l]));
% csvwrite(strcat('M_SR_Post_DispZ_L',int2str(ii),'_F_',int2str(nbframe-1),'.csv'),reshape(shiftVol(3,:,:,nbframe),[w,l]));
% csvwrite(strcat('M_SR_Post_DispA_L',int2str(ii),'_F_',int2str(nbframe-1),'.csv'),reshape(shiftVol(4,:,:,nbframe),[w,l]));
% csvwrite(strcat('M_SR_Post_GradX_L',int2str(ii),'_F_',int2str(nbframe-1),'.csv'),normGradX(:,:,nbframe));
% csvwrite(strcat('M_SR_Post_GradY_L',int2str(ii),'_F_',int2str(nbframe-1),'.csv'),normGradY(:,:,nbframe));
% end
%
% cd ../../
else else
%%%%%%%%%%%%%%%%%%%%%%%%%%%%% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%
......
...@@ -45,14 +45,14 @@ function[dispFieldOut] = interpolate_disp_field(dispFieldIn,imgVolFine,scaleStep ...@@ -45,14 +45,14 @@ function[dispFieldOut] = interpolate_disp_field(dispFieldIn,imgVolFine,scaleStep
sizeDispField = size(dispFieldIn); sizeDispField = size(dispFieldIn);
sizeImgVolFine = size(imgVolFine); sizeImgVolFine = size(imgVolFine);
cd matlab_debug/little_upsample % cd matlab_debug/little_upsample
for nbframe=1:98 % for nbframe=1:98
csvwrite(strcat('M_UA_Ante_DispX_F',int2str(nbframe-1),'.csv'),squeeze(dispFieldIn(1,:,:,nbframe))); % csvwrite(strcat('M_UA_Ante_DispX_F',int2str(nbframe-1),'.csv'),squeeze(dispFieldIn(1,:,:,nbframe)));
csvwrite(strcat('M_UA_Ante_DispY_F',int2str(nbframe-1),'.csv'),squeeze(dispFieldIn(2,:,:,nbframe))); % csvwrite(strcat('M_UA_Ante_DispY_F',int2str(nbframe-1),'.csv'),squeeze(dispFieldIn(2,:,:,nbframe)));
csvwrite(strcat('M_UA_Ante_DispZ_F',int2str(nbframe-1),'.csv'),squeeze(dispFieldIn(3,:,:,nbframe))); % csvwrite(strcat('M_UA_Ante_DispZ_F',int2str(nbframe-1),'.csv'),squeeze(dispFieldIn(3,:,:,nbframe)));
csvwrite(strcat('M_UA_Ante_DispA_F',int2str(nbframe-1),'.csv'),squeeze(dispFieldIn(4,:,:,nbframe))); % csvwrite(strcat('M_UA_Ante_DispA_F',int2str(nbframe-1),'.csv'),squeeze(dispFieldIn(4,:,:,nbframe)));
end % end
cd ../.. % cd ../..
%get the interpolated coordinates %get the interpolated coordinates
if (sizeDispField(end) == sizeImgVolFine(end)) %no temporal subsampling if (sizeDispField(end) == sizeImgVolFine(end)) %no temporal subsampling
...@@ -107,28 +107,28 @@ function[dispFieldOut] = interpolate_disp_field(dispFieldIn,imgVolFine,scaleStep ...@@ -107,28 +107,28 @@ function[dispFieldOut] = interpolate_disp_field(dispFieldIn,imgVolFine,scaleStep
saveDispTafterClamp = squeeze(dispFieldOut(3,:,:,68)); saveDispTafterClamp = squeeze(dispFieldOut(3,:,:,68));
%size(saveDispXafterClamp) %size(saveDispXafterClamp)
cd matlab_debug/little_upsample/ % cd matlab_debug/little_upsample/
for nbframe=1:98 % for nbframe=1:98
csvwrite(strcat('M_CoordX_F',int2str(nbframe-1),'.csv'),xCoordsInterp(:,:,nbframe)); % csvwrite(strcat('M_CoordX_F',int2str(nbframe-1),'.csv'),xCoordsInterp(:,:,nbframe));
csvwrite(strcat('M_CoordY_F',int2str(nbframe-1),'.csv'),yCoordsInterp(:,:,nbframe)); % csvwrite(strcat('M_CoordY_F',int2str(nbframe-1),'.csv'),yCoordsInterp(:,:,nbframe));
csvwrite(strcat('M_CoordZ_F',int2str(nbframe-1),'.csv'),tCoordsInterp(:,:,nbframe)); % csvwrite(strcat('M_CoordZ_F',int2str(nbframe-1),'.csv'),tCoordsInterp(:,:,nbframe));
end % end
csvwrite('M_DispZ_BeforeClamp_F68.csv',saveDispTbeforeClamp); % csvwrite('M_DispZ_BeforeClamp_F68.csv',saveDispTbeforeClamp);
csvwrite('M_DispZ_AfterClamp_F68.csv',saveDispTafterClamp); % csvwrite('M_DispZ_AfterClamp_F68.csv',saveDispTafterClamp);
cd ../.. % cd ../..
%deal with the last field : the patch distance %deal with the last field : the patch distance
dispFieldTemp = squeeze(dispFieldIn(4,:,:,:)); dispFieldTemp = squeeze(dispFieldIn(4,:,:,:));
dispFieldOut(4,:,:,:) = reshape(dispFieldTemp(linInds(:)),sizeDispFieldOut(2:4)); dispFieldOut(4,:,:,:) = reshape(dispFieldTemp(linInds(:)),sizeDispFieldOut(2:4));
cd matlab_debug/little_upsample % cd matlab_debug/little_upsample
for nbframe=1:98 % for nbframe=1:98
csvwrite(strcat('M_UA_Post_DispX_F',int2str(nbframe-1),'.csv'),squeeze(dispFieldOut(1,:,:,nbframe))); % csvwrite(strcat('M_UA_Post_DispX_F',int2str(nbframe-1),'.csv'),squeeze(dispFieldOut(1,:,:,nbframe)));
csvwrite(strcat('M_UA_Post_DispY_F',int2str(nbframe-1),'.csv'),squeeze(dispFieldOut(2,:,:,nbframe))); % csvwrite(strcat('M_UA_Post_DispY_F',int2str(nbframe-1),'.csv'),squeeze(dispFieldOut(2,:,:,nbframe)));
csvwrite(strcat('M_UA_Post_DispZ_F',int2str(nbframe-1),'.csv'),squeeze(dispFieldOut(3,:,:,nbframe))); % csvwrite(strcat('M_UA_Post_DispZ_F',int2str(nbframe-1),'.csv'),squeeze(dispFieldOut(3,:,:,nbframe)));
csvwrite(strcat('M_UA_Post_DispA_F',int2str(nbframe-1),'.csv'),squeeze(dispFieldOut(4,:,:,nbframe))); % csvwrite(strcat('M_UA_Post_DispA_F',int2str(nbframe-1),'.csv'),squeeze(dispFieldOut(4,:,:,nbframe)));
end % end
cd ../.. % cd ../..
'end' 'end'
end end
......
...@@ -91,16 +91,11 @@ def evolution(path,MorC,nbFrame,XYZ,idIter): ...@@ -91,16 +91,11 @@ def evolution(path,MorC,nbFrame,XYZ,idIter):
return 0 return 0
def upsample_compare(Mpath,Cpath,nbFrame,XYZ,level,OccMask,outPath,inputMorC,levelBool): def upsample_compare(Mpath,Cpath,nbFrame,XYZ,OccMask,outPath,inputMorC,endPath):
"This function is to compare two set of data, in .csv matrices, and produce a visual output (in .png)" "This function is to compare two set of data, in .csv matrices, and produce a visual output (in .png)"
results=[] results=[]
for i in range(nbFrame): for i in range(nbFrame):
# Add level in the pathway
if(levelBool==True):
endPath = "_L"+str(level)+"_F"
else:
endPath = "_F"
# Load matrices from the first path # Load matrices from the first path
if(inputMorC=='Matlab'): if(inputMorC=='Matlab'):
...@@ -111,8 +106,7 @@ def upsample_compare(Mpath,Cpath,nbFrame,XYZ,level,OccMask,outPath,inputMorC,lev ...@@ -111,8 +106,7 @@ def upsample_compare(Mpath,Cpath,nbFrame,XYZ,level,OccMask,outPath,inputMorC,lev
temp_matlab = temp_matlab[:,0:end_m-1] temp_matlab = temp_matlab[:,0:end_m-1]
# Load matrices for the second path # Load matrices for the second path
endPath = endPath + str(i) + ".csv" temp_cpp = np.genfromtxt(Cpath+XYZ+endPath+str(i)+".csv",delimiter=';')
temp_cpp = np.genfromtxt(Cpath+XYZ+endPath,delimiter=';')
end = np.shape(temp_cpp)[1] end = np.shape(temp_cpp)[1]
diff = temp_matlab-temp_cpp[:,0:end-1] diff = temp_matlab-temp_cpp[:,0:end-1]
...@@ -122,7 +116,7 @@ def upsample_compare(Mpath,Cpath,nbFrame,XYZ,level,OccMask,outPath,inputMorC,lev ...@@ -122,7 +116,7 @@ def upsample_compare(Mpath,Cpath,nbFrame,XYZ,level,OccMask,outPath,inputMorC,lev
# print("i:",i) # print("i:",i)
# print(100*diff) # print(100*diff)
plt.imsave(outPath+XYZ+"_F"+str(i)+".png",diff,cmap="seismic") plt.imsave(outPath+XYZ+endPath+str(i)+".png",diff,cmap="seismic")
diff[diff!=0]=1 diff[diff!=0]=1
diff_sum = 0 diff_sum = 0
...@@ -151,12 +145,21 @@ def upsample_compare(Mpath,Cpath,nbFrame,XYZ,level,OccMask,outPath,inputMorC,lev ...@@ -151,12 +145,21 @@ def upsample_compare(Mpath,Cpath,nbFrame,XYZ,level,OccMask,outPath,inputMorC,lev
if __name__=="__main__": if __name__=="__main__":
OccPath = "Data/resources/beach_umbrella_occlusion.png"
OccMediumPath = "Data/divergence/full_div/M_OccMask_F32_L2_I_1.png" OccMediumPath = "Data/divergence/full_div/M_OccMask_F32_L2_I_1.png"
OccSmallPath = "Data/onion_debug/Occ/OccF0.png"
OccMask = io.imread(OccPath)
OccMediumMask = io.imread(OccMediumPath,as_grey=True) OccMediumMask = io.imread(OccMediumPath,as_grey=True)
OccMediumMask[OccMediumMask<0.1]=0 OccMediumMask[OccMediumMask<0.1]=0
OccMediumMask[OccMediumMask>=0.1]=255 OccMediumMask[OccMediumMask>=0.1]=255
OccSmallMask = io.imread(OccSmallPath,as_grey=True)
OccSmallMask[OccSmallMask<0.1]=0
OccSmallMask[OccSmallMask>=0.1]=255
# compare(frame,XYZ,MatlabPath,CppPath,iterLevel) # compare(frame,XYZ,MatlabPath,CppPath,iterLevel)
# evolution(CppPath,"Cpp",98,"Y",302) # evolution(CppPath,"Cpp",98,"Y",302)
...@@ -177,7 +180,7 @@ if __name__=="__main__": ...@@ -177,7 +180,7 @@ if __name__=="__main__":
# # Upsample compare between C++ old and new implementation # # Upsample compare between C++ old and new implementation
# upsample_compare("Data/upsample/CppOut_",\ # upsample_compare("Data/upsample/CppOut_",\
# "Data/upsample/test_methodCpp/CppOut_",98,"DispX",1,OccMediumMask,"Data/upsample/results/DiffMethod_",1) # "Data/upsample/test_methodCpp/CppOut_",98,"DispX",OccMediumMask,"Data/upsample/results/DiffMethod_","_L1_F")
# # Result: Implementation successful, same result in output, the problem is somewhere else. # # Result: Implementation successful, same result in output, the problem is somewhere else.
# # Transformer .csv en image # # Transformer .csv en image
...@@ -187,8 +190,8 @@ if __name__=="__main__": ...@@ -187,8 +190,8 @@ if __name__=="__main__":
# # Displaying Disp and Grad differences for a SR iteration # # Displaying Disp and Grad differences for a SR iteration
# upsample_compare("Data/search_reconstruct/SR_matlab/M_SR_Post_",\ # upsample_compare("Data/search_reconstruct/SR_matlab/M_SR_Post_",\
# "Data/search_reconstruct/CppOut_SR_",98,"GradY",3,\ # "Data/search_reconstruct/CppOut_SR_",98,"GradY",\
# OccMediumMask,"Data/search_reconstruct/SR_result/Diff_SR_",0) # OccMediumMask,"Data/search_reconstruct/SR_result/Diff_SR_","_F")
# # Result: Huge difference... # # Result: Huge difference...
# # Comparing before and after clamp matrices in Matlab algorithm # # Comparing before and after clamp matrices in Matlab algorithm
...@@ -200,7 +203,7 @@ if __name__=="__main__": ...@@ -200,7 +203,7 @@ if __name__=="__main__":
# #Compare the output of data out of C++ algo, after and before # #Compare the output of data out of C++ algo, after and before
# upsample_compare("Data/upsample_ant/M_UA_Post_","Data/upsample_ant/Cpp_UA_",\ # upsample_compare("Data/upsample_ant/M_UA_Post_","Data/upsample_ant/Cpp_UA_",\
# 98,"DispY",3,OccMediumMask,"Data/upsample_ant/DiffOut_UA_",'Matlab',False) # 98,"DispY",OccMediumMask,"Data/upsample_ant/DiffOut_UA_",'Matlab',"_F")
# # Result: Exactly the same, there is a problem in the analysis # # Result: Exactly the same, there is a problem in the analysis
# # Compare just two frames of DispA for more details # # Compare just two frames of DispA for more details
...@@ -213,7 +216,7 @@ if __name__=="__main__": ...@@ -213,7 +216,7 @@ if __name__=="__main__":
# # Upsample compare of DispA to test the indexation problem # # Upsample compare of DispA to test the indexation problem
# # WARNING: ON THIS DATA SET, YOU HAVE TO CHANGE INDEXING (i-1 on matlab) # # WARNING: ON THIS DATA SET, YOU HAVE TO CHANGE INDEXING (i-1 on matlab)
# upsample_compare("Data/upsample/matlab_upsample/M_upsampleAfter_",\ # upsample_compare("Data/upsample/matlab_upsample/M_upsampleAfter_",\
# "Data/upsample/test_methodCpp/CppOut_",98,"DispZ",1,OccMediumMask,"Data/upsample/results/NewIndNewImp_",'Matlab',True) # "Data/upsample/test_methodCpp/CppOut_",98,"DispZ",OccMediumMask,"Data/upsample/results/NewIndNewImp_",'Matlab',"_L1_F")
# # Result: There was indeed an index problem... X,Y and A exactly the same, but problem with the Z, with small peak of differences. # # Result: There was indeed an index problem... X,Y and A exactly the same, but problem with the Z, with small peak of differences.
# # Looking differences between coords of upsample (M vs Cpp) to see the problem on Z # # Looking differences between coords of upsample (M vs Cpp) to see the problem on Z
...@@ -232,7 +235,17 @@ if __name__=="__main__": ...@@ -232,7 +235,17 @@ if __name__=="__main__":
# plt.imsave("Data/upsample_ant/M_DispZ_DiffClamp_F68.png",im1-im2) # plt.imsave("Data/upsample_ant/M_DispZ_DiffClamp_F68.png",im1-im2)
# # Result: On Z, there is a difference, so clamp might be useful # # Result: On Z, there is a difference, so clamp might be useful
#Compare the output of data out of C++ algo, after and before on DispZ to see if clamp is effective # #Compare the output of data out of C++ algo, after and before on DispZ to see if clamp is effective
upsample_compare("Data/upsample_ant/M_UA_Post_","Data/upsample_ant/Cpp_UA_",\ # upsample_compare("Data/upsample_ant/M_UA_Post_","Data/upsample_ant/Cpp_UA_",\
98,"DispA",3,OccMediumMask,"Data/upsample_ant/DiffOut_UA_",'Matlab',False) # 98,"DispA",OccMediumMask,"Data/upsample_ant/DiffOut_UA_",'Matlab',"_F")
# Result: Implementation succesful but the difference is still here ... WTF # # Result: Implementation succesful !
# #Compare one search iteration
# upsample_compare("Data/search_ant/L3_I5/M_SA_Post_","Data/search_ant/result_L3_I5/CppOut_SA_",\
# 98,"DispX",OccSmallMask,"Data/search_ant/Diff_UA_",'Matlab',"_L3_I5_F")
# # Result: For DispXYZ, about 30% difference, for DispA, nearly 100%,
#Compare one search iteration (at end of level iterations)
upsample_compare("Data/search_ant/L3_I8/M_SA_Post_","Data/search_ant/result_L3_I8/CppOut_SA_",\
98,"DispX",OccSmallMask,"Data/search_ant/Diff_UA_",'Matlab',"_L3_I8_F")
# Result: Mean percentage a bit higher, so there is divergence across iterations.
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