Commit 37c013d5 authored by sarthou's avatar sarthou
Browse files

All python files commented, and separated for clarity

parent 3e8561a5
import numpy as np
import matplotlib.pyplot as plt
from skimage import io
from skimage import measure
import cv2
import compare
import dispcompare
import scipy.signal
"""This file is for comparing result of one search/reconstruction iteration,
in order to locate the problem"""
np.set_printoptions(threshold=np.nan)
OccPath = "Data/resources/beach_umbrella_occlusion.png"
OccMediumPath = "Data/divergence/full_div/M_OccMask_F32_L2_I_1.png"
OccSmallPath = "Data/onion_debug/Occ/OccF0.png"
# Loading masks if needed
OccMask = io.imread(OccPath)
OccSmallMask = io.imread(OccSmallPath,as_grey=True)
OccSmallMask[OccSmallMask<0.1]=0
OccSmallMask[OccSmallMask>=0.1]=255
OccMediumMask = io.imread(OccMediumPath,as_grey=True)
OccMediumMask[OccMediumMask<0.1]=0
OccMediumMask[OccMediumMask>=0.1]=255
Cpp_SR_Path = "Data/search_reconstruct/CppOut_SR_L3_F"
M_SR_Path = "Data/search_reconstruct/SR_matlab/M_SR_Post_Im_L3_frame_"
"""
# Compare output of the two algos on one level (L3) to visualise what is wrong
compare.visual_compare(Cpp_SR_Path,M_SR_Path,[98,17,66,3],\
"Data/search_reconstruct/SR_result/SR_OutComp_L3_F")
pixCountSR = compare.FullPixCompare(Cpp_SR_Path,M_SR_Path,[98,17,66,3],OccSmallPath,0.1)
plt.plot((pixCountSR[0,:]+pixCountSR[1,:]+pixCountSR[2,:])/3,'black')
plt.axhline(np.mean((pixCountSR[0,:]+pixCountSR[1,:]+pixCountSR[2,:])/3),color='red')
plt.xlabel("number of frame (time)")
plt.ylabel("Percentage of pixels different in each image on the mask")
plt.legend()
plt.title("Evolution de la différence de pixel entre les images Matlab et C++\
sur une itération Recherche/Reconstruction \n \
Avg:"+str(np.mean((pixCountSR[0,:]+pixCountSR[1,:]+pixCountSR[2,:])/3))+\
" Ecart-type: "+str(np.std((pixCountSR[0,:]+pixCountSR[1,:]+pixCountSR[2,:])/3)))
plt.show()
# Compare full outputs of both algorithms, please find something...
compare.visual_compare("Data/fullReconstructedImgF","Data/resources/beach_umbrella_f",[98,68,264,3],"Data/visu_comp_F")
# Result: ...
# ####Comparison between matlab and C++ with L1_I14 search injection
compare.visual_compare("Data/search_ant/result_L1_I14/CppOut_F","Data/resources/beach_umbrella_f",[98,68,264,3],"Data/visual_compare/visu_comp_L1_I14_F")
#Result: Still the same, but pix compare will be interesting
# plot pix compare between matlab and C++ with L1_I14 injection
pixCountSR = compare.FullPixCompare("Data/search_ant/result_L1_I14/CppOut_F",\
"Data/resources/beach_umbrella_f",[98,68,264,3],OccPath,0.1)
plt.plot((pixCountSR[0,:]+pixCountSR[1,:]+pixCountSR[2,:])/3,'black')
plt.axhline(np.mean((pixCountSR[0,:]+pixCountSR[1,:]+pixCountSR[2,:])/3),color='red')
plt.xlabel("number of frame (time)")
plt.ylabel("Percentage of pixels different in each image on the mask")
plt.legend()
plt.title("Evolution de la différence de pixel entre les images Matlab et C++\
sur une itération Recherche/Reconstruction avec injection sur le niveau L1-I14 \n \
Avg:"+str(np.mean((pixCountSR[0,:]+pixCountSR[1,:]+pixCountSR[2,:])/3))+\
" Ecart-type: "+str(np.std((pixCountSR[0,:]+pixCountSR[1,:]+pixCountSR[2,:])/3)))
plt.show()
# Result: plus de 60% de différence, cohérent.
# Comparison between matlab and C++ with L1_I14 reconstruction injection
compare.visual_compare("Data/reconstruct_ant/result_L1_I14/CppOut_F",\
"Data/reconstruct_ant/L1_I14/M_RA_Post_Im_L1_I14_frame_",[98,68,264,3],\
"Data/reconstruct_ant/visu_comp_L1_I14_F")
# Result: Weird noise
# plot pix compare between matlab and C++ reconstruction with L1_I14 injection
pixCountSR = compare.FullPixCompare("Data/reconstruct_ant/result_L1_I14/CppOut_F",\
"Data/reconstruct_ant/L1_I14/M_RA_Post_Im_L1_I14_frame_",[98,68,264,3],OccPath,0.1)
plt.plot((pixCountSR[0,:]+pixCountSR[1,:]+pixCountSR[2,:])/3,'black')
plt.axhline(np.mean((pixCountSR[0,:]+pixCountSR[1,:]+pixCountSR[2,:])/3),color='red')
plt.xlabel("number of frame (time)")
plt.ylabel("Percentage of pixels different in each image on the mask")
plt.legend()
plt.title("Evolution de la différence de pixel entre les images Matlab et C++\
sur une itération Recherche/Reconstruction avec injection sur le niveau L1-I14 \n \
Avg:"+str(np.mean((pixCountSR[0,:]+pixCountSR[1,:]+pixCountSR[2,:])/3))+\
" Ecart-type: "+str(np.std((pixCountSR[0,:]+pixCountSR[1,:]+pixCountSR[2,:])/3)))
plt.show()
# Result: 3% de différence en moyenne, le problème ne doit pas venir de la reconstruction.
"""
"""Search/reconstruction """
#Compare one search iteration
dispcompare.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)
dispcompare.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.
# Result 2: Testing with new value of HalfPatchSize (à 3), no significant change (0.4%)
# Compare two executions of search algo on same dataset, to see random dispersion
dispcompare.upsample_compare("Data/aleatoire/al_cpp_iter1_L3_I8/CppOut_AL1_",\
"Data/aleatoire/al_cpp_iter2_L3_I8/CppOut_AL2_",98,"DispX",OccSmallMask,\
"Data/aleatoire/diff_AL_Cpp_",'Cpp',"_L3_I8_F")
# Result: 0% WTF ! Aucun aléatoire, c'est pas normal
# Compare two executions of search algo on same dataset, to see random dispersion
dispcompare.upsample_compare("Data/aleatoire/al_matlab_iter1_L3_I8/M_AL_Post_",\
"Data/aleatoire/al_matlab_iter2_L3_I8/M_AL_Post_",98,"DispX",OccSmallMask,\
"Data/aleatoire/diff_AL_M_Post_",'Matlab',"_L3_I8_F")
# Result: 0%... ok c'est rassurant pour le c++, apparemment le fait
# de fixer la seed rend l'algo déterministe
# Compare two executions of search algo on same dataset, on the highest level just to see the difference
dispcompare.upsample_compare("Data/search_ant/L1_I14/M_AL_Post_",\
"Data/search_ant/result_L1_I14/CppOut_AL_",98,"DispX",OccMask,\
"Data/search_ant/diff_AL_Cpp_",'Matlab',"_L1_I14_F")
# Result:
# Compare reconstruction algo
dispcompare.upsample_compare("Data/reconstruct_ant/L1_I14/M_RA_Post_",\
"Data/reconstruct_ant/result_L1_I14/CppOut_RA_",98,"GradX",OccMask,\
"Data/reconstruct_ant/diff_RA_",'Matlab',"_L1_I14_F")
# Result: Disp at 0 (which is normal) but reconstruct if Grad at 60% ...
......@@ -356,6 +356,7 @@ if __name__ == '__main__':
#
# cap.release()
# cv2.destroyAllWindows()
# # The inverse operation can be done with the ffmpeg command on Linux (see man ffmpeg)
#MSSIM(VolMatlab,VolOri,0.01,0.03,(3,4))
......@@ -474,67 +475,3 @@ if __name__ == '__main__':
# plt.ylabel("Pourcentage de pixels différents sur le masque d'occlusion")
# plt.title("Evolution de la différence de pixels au fil des iterations entre Matlab et C++")
# plt.show()
"""Working on Search/reconstruct"""
# # visual_compare(Cpp_SR_Path,M_SR_Path,[98,17,66,3],"Data/search_reconstruct/SR_result/SR_OutComp_L3_F")
#
# pixCountSR = FullPixCompare(Cpp_SR_Path,M_SR_Path,[98,17,66,3],OccSmallPath,0.1)
# plt.plot((pixCountSR[0,:]+pixCountSR[1,:]+pixCountSR[2,:])/3,'black')
#
# plt.axhline(np.mean((pixCountSR[0,:]+pixCountSR[1,:]+pixCountSR[2,:])/3),color='red')
#
# plt.xlabel("number of frame (time)")
# plt.ylabel("Percentage of pixels different in each image on the mask")
# plt.legend()
# plt.title("Evolution de la différence de pixel entre les images Matlab et C++\
# sur une itération Recherche/Reconstruction \n \
# Avg:"+str(np.mean((pixCountSR[0,:]+pixCountSR[1,:]+pixCountSR[2,:])/3))+\
# " Ecart-type: "+str(np.std((pixCountSR[0,:]+pixCountSR[1,:]+pixCountSR[2,:])/3)))
# plt.show()
# # Compare full outputs of both algorithms, please find something...
# visual_compare("Data/fullReconstructedImgF","Data/resources/beach_umbrella_f",[98,68,264,3],"Data/visu_comp_F")
# # Result: ...
# Comparison between matlab and C++ with L1_I14 injection
# visual_compare("Data/search_ant/result_L1_I14/CppOut_F","Data/resources/beach_umbrella_f",[98,68,264,3],"Data/visual_compare/visu_comp_L1_I14_F")
# Result: Still the same, but pix compare will be interesting
# # plot pix compare between matlab and C++ with L1_I14 injection
# pixCountSR = FullPixCompare("Data/search_ant/result_L1_I14/CppOut_F",\
# "Data/resources/beach_umbrella_f",[98,68,264,3],OccPath,0.1)
#
# plt.plot((pixCountSR[0,:]+pixCountSR[1,:]+pixCountSR[2,:])/3,'black')
# plt.axhline(np.mean((pixCountSR[0,:]+pixCountSR[1,:]+pixCountSR[2,:])/3),color='red')
#
# plt.xlabel("number of frame (time)")
# plt.ylabel("Percentage of pixels different in each image on the mask")
# plt.legend()
# plt.title("Evolution de la différence de pixel entre les images Matlab et C++\
# sur une itération Recherche/Reconstruction avec injection sur le niveau L1-I14 \n \
# Avg:"+str(np.mean((pixCountSR[0,:]+pixCountSR[1,:]+pixCountSR[2,:])/3))+\
# " Ecart-type: "+str(np.std((pixCountSR[0,:]+pixCountSR[1,:]+pixCountSR[2,:])/3)))
# plt.show()
# # Result: plus de 60% de différence, cohérent.
# # Comparison between matlab and C++ with L1_I14 injection
# visual_compare("Data/reconstruct_ant/result_L1_I14/CppOut_F","Data/reconstruct_ant/L1_I14/M_RA_Post_Im_L1_I14_frame_",[98,68,264,3],"Data/reconstruct_ant/visu_comp_L1_I14_F")
# # Result: Weird noise
# # plot pix compare between matlab and C++ reconstruction with L1_I14 injection
# pixCountSR = FullPixCompare("Data/reconstruct_ant/result_L1_I14/CppOut_F",\
# "Data/reconstruct_ant/L1_I14/M_RA_Post_Im_L1_I14_frame_",[98,68,264,3],OccPath,0.1)
#
# plt.plot((pixCountSR[0,:]+pixCountSR[1,:]+pixCountSR[2,:])/3,'black')
# plt.axhline(np.mean((pixCountSR[0,:]+pixCountSR[1,:]+pixCountSR[2,:])/3),color='red')
#
# plt.xlabel("number of frame (time)")
# plt.ylabel("Percentage of pixels different in each image on the mask")
# plt.legend()
# plt.title("Evolution de la différence de pixel entre les images Matlab et C++\
# sur une itération Recherche/Reconstruction avec injection sur le niveau L1-I14 \n \
# Avg:"+str(np.mean((pixCountSR[0,:]+pixCountSR[1,:]+pixCountSR[2,:])/3))+\
# " Ecart-type: "+str(np.std((pixCountSR[0,:]+pixCountSR[1,:]+pixCountSR[2,:])/3)))
# plt.show()
# # Result: 3% de différence en moyenne, le problème ne doit pas venir de la reconstruction.
......@@ -142,142 +142,7 @@ def upsample_compare(Mpath,Cpath,nbFrame,XYZ,OccMask,outPath,inputMorC,endPath):
if __name__=="__main__":
OccPath = "Data/resources/beach_umbrella_occlusion.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[OccMediumMask<0.1]=0
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)
# evolution(CppPath,"Cpp",98,"Y",302)
# ###Quick Load of occlusion
# VolOnion = np.zeros((4,17,67))
# VolOnion[0,:,:]=np.genfromtxt("Data/onion_debug/OccF0_"+str(0)+".csv",delimiter=";")
# VolOnion[1,:,:]=np.genfromtxt("Data/onion_debug/OccF0_"+str(1)+".csv",delimiter=";")
# VolOnion[2,:,:]=np.genfromtxt("Data/onion_debug/OccF0_"+str(2)+".csv",delimiter=";")
# VolOnion[3,:,:]=np.genfromtxt("Data/onion_debug/OccF0_last.csv",delimiter=";")
# plt.figure()
# plt.subplot(2,2,1)
# plt.imshow(VolOnion[1,:,:,])
# plt.subplot(2,2,2)
# plt.imshow(VolOnion[2,:,:,])
# plt.subplot(2,2,3)
# plt.imshow(VolOnion[3,:,:,])
# plt.show()
# # Upsample compare between C++ old and new implementation
# upsample_compare("Data/upsample/CppOut_",\
# "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.
# # Transformer .csv en image
# for i in range(98):
# img = np.genfromtxt("Data/upsample/test_methodCpp/CppOut_DispX_L1_F"+str(i)+".csv",delimiter=";")
# plt.imsave("Data/upsample/test_methodCpp/test_DispX_L1_F"+str(i)+".png",img,cmap='seismic')
# # Displaying Disp and Grad differences for a SR iteration
# upsample_compare("Data/search_reconstruct/SR_matlab/M_SR_Post_",\
# "Data/search_reconstruct/CppOut_SR_",98,"GradY",\
# OccMediumMask,"Data/search_reconstruct/SR_result/Diff_SR_","_F")
# # Result: Huge difference...
# # Comparing before and after clamp matrices in Matlab algorithm
# im1 = np.genfromtxt("Data/upsample_ant/M_DispX_BeforeClamp_F32.csv",delimiter=',')
# im2 = np.genfromtxt("Data/upsample_ant/M_DispX_AfterClamp_F32.csv",delimiter=',')
#
# plt.imsave("Data/upsample_ant/M_DispX_DiffClamp_F32.png",im1-im2)
# # Result: Exactly the same, clamp unusued
# #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_",\
# 98,"DispY",OccMediumMask,"Data/upsample_ant/DiffOut_UA_",'Matlab',"_F")
# # Result: Exactly the same, there is a problem in the analysis
# # Compare just two frames of DispA for more details
# im1 = np.genfromtxt("Data/upsample/matlab_upsample/M_upsampleAfter_DispA_L1_F47.csv",delimiter=',')
# im2 = np.genfromtxt("Data/upsample/CppOut_DispA_L1_F48.csv",delimiter=';')
# end = np.shape(im2)[1]
# plt.imsave("Data/upsample/results/DiffM_NewC_DispA_L1_F48.png",im1-im2[:,0:end-1],cmap='seismic')
# # Result: Ok there is a problem in the indexation of data...
# # Upsample compare of DispA to test the indexation problem
# # WARNING: ON THIS DATA SET, YOU HAVE TO CHANGE INDEXING (i-1 on matlab)
# upsample_compare("Data/upsample/matlab_upsample/M_upsampleAfter_",\
# "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.
# # Looking differences between coords of upsample (M vs Cpp) to see the problem on Z
# for i in range(98):
# im1 = np.genfromtxt("Data/upsample_ant/coord/M_CoordZ_F"+str(i)+".csv",delimiter=',')
# im2 = np.genfromtxt("Data/upsample_ant/coord/Cpp_UA_CoordZ_F"+str(i)+".csv",delimiter=';')
# end = np.shape(im2)[1]
# print(np.sum(im1-im2[:,0:end-1]-np.ones(np.shape(im1))))
# plt.imsave("Data/upsample_ant/coord/Diff_UA_CoordZ_F"+str(i)+".png",im1-im2[:,0:end-1])
# # Result: Don't seem to have a difference in the coord matrices between matlab and C++, maybe during clamp ?
# # Comparing before and after clamp matrices in Matlab algorithm
# im1 = np.genfromtxt("Data/upsample_ant/M_DispZ_BeforeClamp_F68.csv",delimiter=',')
# im2 = np.genfromtxt("Data/upsample_ant/M_DispZ_AfterClamp_F68.csv",delimiter=',')
#
# plt.imsave("Data/upsample_ant/M_DispZ_DiffClamp_F68.png",im1-im2)
# # 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
# upsample_compare("Data/upsample_ant/M_UA_Post_","Data/upsample_ant/Cpp_UA_",\
# 98,"DispA",OccMediumMask,"Data/upsample_ant/DiffOut_UA_",'Matlab',"_F")
# # 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.
# # Result 2: Testing with new value of HalfPatchSize (à 3), no significant change (0.4%)
"""A faire pour ce weekend ou la semaine prochaine:
- Regarder si l'inversion du booleen dans Search est positive
- Recoder l'implémentation hard coded du HalfPatchSize (pas utile mais bon au moins ce sera fait)
- Vérifier (en printant sur une vraie itération) que il n'y a pas de problème
de valeur de bord de masque lors de la fonction rand_search => normalement\
non sauf peut être dans l'init
"""
# # Compare two executions of search algo on same dataset, to see random dispersion
# upsample_compare("Data/aleatoire/al_cpp_iter1_L3_I8/CppOut_AL1_",\
# "Data/aleatoire/al_cpp_iter2_L3_I8/CppOut_AL2_",98,"DispX",OccSmallMask,\
# "Data/aleatoire/diff_AL_Cpp_",'Cpp',"_L3_I8_F")
# # Result: 0% WTF ! Aucun aléatoire, c'est pas normal
# # Compare two executions of search algo on same dataset, to see random dispersion
# upsample_compare("Data/aleatoire/al_matlab_iter1_L3_I8/M_AL_Post_",\
# "Data/aleatoire/al_matlab_iter2_L3_I8/M_AL_Post_",98,"DispX",OccSmallMask,\
# "Data/aleatoire/diff_AL_M_Post_",'Matlab',"_L3_I8_F")
# # Result: 0%... ok c'est rassurant pour le c++, apparemment le fait
# # de fixer la seed rend l'algo déterministe
# # Compare two executions of search algo on same dataset, on the highest level just to see the difference
# upsample_compare("Data/search_ant/L1_I14/M_AL_Post_",\
# "Data/search_ant/result_L1_I14/CppOut_AL_",98,"DispX",OccMask,\
# "Data/search_ant/diff_AL_Cpp_",'Matlab',"_L1_I14_F")
# # Result:
# Compare reconstruction algo
upsample_compare("Data/reconstruct_ant/L1_I14/M_RA_Post_",\
"Data/reconstruct_ant/result_L1_I14/CppOut_RA_",98,"GradX",OccMask,\
"Data/reconstruct_ant/diff_RA_",'Matlab',"_L1_I14_F")
# Result: Disp at 0 (which is normal) but reconstruct if Grad at 60% ...
# # Transformer .csv en image
# for i in range(98):
# img = np.genfromtxt("Data/upsample/test_methodCpp/CppOut_DispX_L1_F"+str(i)+".csv",delimiter=";")
# plt.imsave("Data/upsample/test_methodCpp/test_DispX_L1_F"+str(i)+".png",img,cmap='seismic')
......@@ -5,7 +5,13 @@ from skimage import measure
import cv2
import compare
import scipy.signal
"""This file is for looking in the impact of differents RNG, on the algorithm,
with differents metrics.
- _Ori_ paths are outputs of original algorithm, with use of srand(0).
- M_Seed is the result of Matlab algorithm with a manual RNG (see code in patch_match_tools.cpp)
- C_Seed are results of C++ algorithm with a seed initialised with time
(seed and seed2 are just two calls of the algorithm, to see the random impact)
"""
np.set_printoptions(threshold=np.nan)
......
import numpy as np
import matplotlib.pyplot as plt
from skimage import io
from skimage import measure
import cv2
import compare
import dispcompare
import scipy.signal
"""This file is for comparing result of the upsample algorithm, Matlab and the
two different implementations in C++.
A problem was found on the previous C++ implementation.
A new one was made, strictly identical to the Matlab one (with vectorisation).
Finally, it was corrected (clamp issue). It is now working perfectly """
np.set_printoptions(threshold=np.nan)
OccPath = "Data/resources/beach_umbrella_occlusion.png"
OccMediumPath = "Data/divergence/full_div/M_OccMask_F32_L2_I_1.png"
OccSmallPath = "Data/onion_debug/Occ/OccF0.png"
# Loading masks if needed
OccMask = io.imread(OccPath)
OccSmallMask = io.imread(OccSmallPath,as_grey=True)
OccSmallMask[OccSmallMask<0.1]=0
OccSmallMask[OccSmallMask>=0.1]=255
OccMediumMask = io.imread(OccMediumPath,as_grey=True)
OccMediumMask[OccMediumMask<0.1]=0
OccMediumMask[OccMediumMask>=0.1]=255
# # Comparing before and after clamp matrices in Matlab algorithm
# im1 = np.genfromtxt("Data/upsample_ant/M_DispX_BeforeClamp_F32.csv",delimiter=',')
# im2 = np.genfromtxt("Data/upsample_ant/M_DispX_AfterClamp_F32.csv",delimiter=',')
# plt.imsave("Data/upsample_ant/M_DispX_DiffClamp_F32.png",im1-im2)
# # Result: Exactly the same, clamp unusued
# #Compare the output of data out of C++ algo, after and before
# dispcompare.upsample_compare("Data/upsample_ant/M_UA_Post_","Data/upsample_ant/Cpp_UA_",\
# 98,"DispY",OccMediumMask,"Data/upsample_ant/DiffOut_UA_",'Matlab',"_F")
# # Result: Exactly the same, there is a problem in the analysis
# # Compare just two frames of DispA for more details
# im1 = np.genfromtxt("Data/upsample/matlab_upsample/M_upsampleAfter_DispA_L1_F47.csv",delimiter=',')
# im2 = np.genfromtxt("Data/upsample/CppOut_DispA_L1_F48.csv",delimiter=';')
# end = np.shape(im2)[1]
# plt.imsave("Data/upsample/results/DiffM_NewC_DispA_L1_F48.png",im1-im2[:,0:end-1],cmap='seismic')
# # Result: Ok there is a problem in the indexation of data...
# # Upsample compare of DispA to test the indexation problem
# # WARNING: ON THIS DATA SET, YOU HAVE TO CHANGE INDEXING (i-1 on matlab)
# dispcompare.upsample_compare("Data/upsample/matlab_upsample/M_upsampleAfter_",\
# "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.
# # Looking differences between coords of upsample (M vs Cpp) to see the problem on Z
# for i in range(98):
# im1 = np.genfromtxt("Data/upsample_ant/coord/M_CoordZ_F"+str(i)+".csv",delimiter=',')
# im2 = np.genfromtxt("Data/upsample_ant/coord/Cpp_UA_CoordZ_F"+str(i)+".csv",delimiter=';')
# end = np.shape(im2)[1]
# print(np.sum(im1-im2[:,0:end-1]-np.ones(np.shape(im1))))
# plt.imsave("Data/upsample_ant/coord/Diff_UA_CoordZ_F"+str(i)+".png",im1-im2[:,0:end-1])
# # Result: Don't seem to have a difference in the coord matrices between matlab and C++, maybe during clamp ?
# # Comparing before and after clamp matrices in Matlab algorithm
# im1 = np.genfromtxt("Data/upsample_ant/M_DispZ_BeforeClamp_F68.csv",delimiter=',')
# im2 = np.genfromtxt("Data/upsample_ant/M_DispZ_AfterClamp_F68.csv",delimiter=',')
# plt.imsave("Data/upsample_ant/M_DispZ_DiffClamp_F68.png",im1-im2)
# # 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
dispcompare.upsample_compare("Data/upsample_ant/M_UA_Post_","Data/upsample_ant/Cpp_UA_",\
98,"DispA",OccMediumMask,"Data/upsample_ant/DiffOut_UA_",'Matlab',"_F")
# Result: Implementation succesful !
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