Add build Matrix function and test to
transmission reconstruction.
This commit is contained in:
@@ -5,6 +5,8 @@
|
||||
#include "MatlabReader.h"
|
||||
#include "Matrix.h"
|
||||
#include "transmissionReconstruction/reconstruction/buildMatrix/DGradient.h"
|
||||
#include "transmissionReconstruction/reconstruction/buildMatrix/FMM.h"
|
||||
#include "transmissionReconstruction/reconstruction/buildMatrix/buildMatrix.h"
|
||||
#include "transmissionReconstruction/reconstruction/reconstruction.h"
|
||||
|
||||
|
||||
@@ -85,3 +87,79 @@ TEST_F(Reconstruction_Test, DGradient) {
|
||||
}
|
||||
}
|
||||
|
||||
TEST_F(Reconstruction_Test, correctPath) {
|
||||
auto path = Aurora::Matrix::fromRawData(new double[6]{1,1,10,9,1,1},2,3);
|
||||
auto startPt = Aurora::Matrix::fromRawData(new double[3]{1, .5, 1}, 1, 3);
|
||||
auto endPt = Aurora::Matrix::fromRawData(new double[3]{1, 10, 1}, 1, 3);
|
||||
|
||||
Recon::correctPath(path,startPt,endPt);
|
||||
for (size_t i = 0; i < 10; i++)
|
||||
{
|
||||
EXPECT_DOUBLE_EQ(path[i],1.0);
|
||||
EXPECT_DOUBLE_EQ(path[i+10],1.0+i);
|
||||
EXPECT_DOUBLE_EQ(path[i+20],1.0);
|
||||
}
|
||||
}
|
||||
|
||||
TEST_F(Reconstruction_Test,getPixelLengthApproximation){
|
||||
auto startPt = Aurora::Matrix::fromRawData(new double[3]{1, 1, 1}, 1, 3);
|
||||
auto endPt = Aurora::Matrix::fromRawData(new double[3]{4, 5, 6}, 1, 3);
|
||||
auto res = Aurora::Matrix::fromRawData(new double[3]{.1, .1, .1}, 1, 3);
|
||||
auto weight = Recon::getPixelLengthApproximation(startPt, endPt, res, 10);
|
||||
EXPECT_DOUBLE_AE(weight[0],.0707);
|
||||
}
|
||||
|
||||
TEST_F(Reconstruction_Test,traceLine3D){
|
||||
auto p1 = Aurora::Matrix::fromRawData(new double[3]{1, 10, 12}, 1, 3);
|
||||
auto p2 = Aurora::Matrix::fromRawData(new double[3]{20, 2, 13}, 1, 3);
|
||||
auto discretization = Aurora::Matrix::fromRawData(new double[3]{1, 1, 1}, 1, 3);
|
||||
auto result = Recon::traceLine3D(p1, p2, discretization);
|
||||
MatlabReader m("/home/krad/TestData/traceLine3D.mat");
|
||||
|
||||
auto path = m.read("path");
|
||||
auto ds = m.read("ds");
|
||||
result.path.printf();
|
||||
for (size_t i = 0; i < result.path.getDataSize(); i++)
|
||||
{
|
||||
EXPECT_DOUBLE_AE(result.path.getData()[i],path[i])<<"index:"<<i;
|
||||
}
|
||||
result.ds.printf();
|
||||
for (size_t i = 0; i < result.ds.getDataSize(); i++)
|
||||
{
|
||||
EXPECT_DOUBLE_AE(result.ds.getData()[i],ds[i])<<"index:"<<i;
|
||||
}
|
||||
}
|
||||
|
||||
TEST_F(Reconstruction_Test,traceStraightRay){
|
||||
auto p1 = Aurora::Matrix::fromRawData(new double[3]{1, 1, 1}, 1, 3);
|
||||
auto p2 = Aurora::Matrix::fromRawData(new double[3]{5, 6, 7}, 1, 3);
|
||||
auto res = Aurora::Matrix::fromRawData(new double[3]{.1, .1, .1}, 1, 3);
|
||||
auto dmis = Aurora::Matrix::fromRawData(new double[3]{5, 10, 20}, 1, 3);
|
||||
auto result = Recon::traceStraightRay(p1, p2, res, dmis);
|
||||
EXPECT_EQ(13, result.weighting.getDataSize());
|
||||
EXPECT_DOUBLE_AE(result.weighting[0],0);
|
||||
EXPECT_DOUBLE_AE(result.weighting[1],0.1462);
|
||||
EXPECT_DOUBLE_AE(result.weighting[11],0.0292);
|
||||
EXPECT_DOUBLE_AE(result.weighting[3],0.0439);
|
||||
EXPECT_EQ(13, result.path.getDimSize(0));
|
||||
EXPECT_EQ(3, result.path.getDimSize(1));
|
||||
EXPECT_DOUBLE_AE(result.path[0],1);
|
||||
EXPECT_DOUBLE_AE(result.path[15],2);
|
||||
EXPECT_DOUBLE_AE(result.path[30],3);
|
||||
EXPECT_EQ(13, result.pathLen);
|
||||
}
|
||||
|
||||
TEST_F(Reconstruction_Test,traceStraightRayBresenham){
|
||||
auto p1 = Aurora::Matrix::fromRawData(new double[3]{1, 1, 1}, 1, 3);
|
||||
auto p2 = Aurora::Matrix::fromRawData(new double[3]{5, 6, 7}, 1, 3);
|
||||
auto res = Aurora::Matrix::fromRawData(new double[3]{.1, .1, .1}, 1, 3);
|
||||
auto result = Recon::traceStraightRayBresenham(p1, p2, res);
|
||||
EXPECT_EQ(1, result.weighting.getDataSize());
|
||||
EXPECT_DOUBLE_AE(result.weighting[0],0.1462);
|
||||
EXPECT_EQ(6, result.path.getDimSize(0));
|
||||
EXPECT_EQ(3, result.path.getDimSize(1));
|
||||
EXPECT_DOUBLE_AE(result.path[0],1);
|
||||
EXPECT_DOUBLE_AE(result.path[15],4);
|
||||
EXPECT_DOUBLE_AE(result.path[7],2);
|
||||
EXPECT_EQ(6, result.pathLen);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user