summaryrefslogtreecommitdiffstats
path: root/matlab/mex
diff options
context:
space:
mode:
authorWim van Aarle <wimvanaarle@gmail.com>2015-02-24 15:17:38 +0100
committerWim van Aarle <wimvanaarle@gmail.com>2015-02-24 15:17:38 +0100
commit9e48494ecc1e4655bd6c25b34bb5c53c80c30d7a (patch)
tree9943ca9ac4d3f9fff1183a9ee93bceeb0112d88c /matlab/mex
parent3f5e4b145c22d2dd512d584cd71bd4ae60c08a49 (diff)
downloadastra-9e48494ecc1e4655bd6c25b34bb5c53c80c30d7a.tar.gz
astra-9e48494ecc1e4655bd6c25b34bb5c53c80c30d7a.tar.bz2
astra-9e48494ecc1e4655bd6c25b34bb5c53c80c30d7a.tar.xz
astra-9e48494ecc1e4655bd6c25b34bb5c53c80c30d7a.zip
fixed get_geometry for fanflat_vec
Diffstat (limited to 'matlab/mex')
-rw-r--r--matlab/mex/astra_mex_data2d_c.cpp4
-rw-r--r--matlab/mex/mexHelpFunctions.cpp72
2 files changed, 41 insertions, 35 deletions
diff --git a/matlab/mex/astra_mex_data2d_c.cpp b/matlab/mex/astra_mex_data2d_c.cpp
index b219179..bd70e1b 100644
--- a/matlab/mex/astra_mex_data2d_c.cpp
+++ b/matlab/mex/astra_mex_data2d_c.cpp
@@ -373,7 +373,7 @@ void astra_mex_data2d_store(int nlhs, mxArray* plhs[], int nrhs, const mxArray*
*/
void astra_mex_data2d_get_geometry(int nlhs, mxArray* plhs[], int nrhs, const mxArray* prhs[])
{
- // step1: input
+ // parse input
if (nrhs < 2) {
mexErrMsgTxt("Not enough arguments. See the help document for a detailed argument list. \n");
return;
@@ -384,7 +384,7 @@ void astra_mex_data2d_get_geometry(int nlhs, mxArray* plhs[], int nrhs, const mx
}
int iDataID = (int)(mxGetScalar(prhs[1]));
- // step2: get data object
+ // fetch data object
CFloat32Data2D* pDataObject = astra::CData2DManager::getSingleton().get(iDataID);
if (!pDataObject || !pDataObject->isInitialized()) {
mexErrMsgTxt("Data object not found or not initialized properly.\n");
diff --git a/matlab/mex/mexHelpFunctions.cpp b/matlab/mex/mexHelpFunctions.cpp
index 9b65e77..63d2003 100644
--- a/matlab/mex/mexHelpFunctions.cpp
+++ b/matlab/mex/mexHelpFunctions.cpp
@@ -213,61 +213,67 @@ mxArray* createProjectionGeometryStruct(astra::CProjectionGeometry2D* _pProjGeom
// temporary map to store the data for the MATLAB struct
std::map<std::string, mxArray*> mGeometryInfo;
- // detectorCount
- mGeometryInfo["DetectorCount"] = mxCreateDoubleScalar(_pProjGeom->getDetectorCount());
-
- if (!_pProjGeom->isOfType("fanflat_vec")) {
- // detectorWidth
+ // parallel beam
+ if (_pProjGeom->isOfType("parallel")) {
+ mGeometryInfo["type"] = mxCreateString("parallel");
+ mGeometryInfo["DetectorCount"] = mxCreateDoubleScalar(_pProjGeom->getDetectorCount());
mGeometryInfo["DetectorWidth"] = mxCreateDoubleScalar(_pProjGeom->getDetectorWidth());
- // pfProjectionAngles
mxArray* pAngles = mxCreateDoubleMatrix(1, _pProjGeom->getProjectionAngleCount(), mxREAL);
double* out = mxGetPr(pAngles);
for (int i = 0; i < _pProjGeom->getProjectionAngleCount(); i++) {
out[i] = _pProjGeom->getProjectionAngle(i);
}
- mGeometryInfo["ProjectionAngles"] = pAngles;
+ mGeometryInfo["ProjectionAngles"] = pAngles;
}
- else {
+
+ // fanflat
+ else if (_pProjGeom->isOfType("fanflat")) {
+ astra::CFanFlatProjectionGeometry2D* pFanFlatGeom = dynamic_cast<astra::CFanFlatProjectionGeometry2D*>(_pProjGeom);
+
+ mGeometryInfo["type"] = mxCreateString("fanflat");
+ mGeometryInfo["DetectorCount"] = mxCreateDoubleScalar(_pProjGeom->getDetectorCount());
+ mGeometryInfo["DetectorWidth"] = mxCreateDoubleScalar(_pProjGeom->getDetectorWidth());
+ mGeometryInfo["DistanceOriginSource"] = mxCreateDoubleScalar(pFanFlatGeom->getOriginSourceDistance());
+ mGeometryInfo["DistanceOriginDetector"] = mxCreateDoubleScalar(pFanFlatGeom->getOriginDetectorDistance());
+
+ mxArray* pAngles = mxCreateDoubleMatrix(1, pFanFlatGeom->getProjectionAngleCount(), mxREAL);
+ double* out = mxGetPr(pAngles);
+ for (int i = 0; i < pFanFlatGeom->getProjectionAngleCount(); i++) {
+ out[i] = pFanFlatGeom->getProjectionAngle(i);
+ }
+ mGeometryInfo["ProjectionAngles"] = pAngles;
+ }
+
+ // fanflat_vec
+ else if (_pProjGeom->isOfType("fanflat_vec")) {
astra::CFanFlatVecProjectionGeometry2D* pVecGeom = dynamic_cast<astra::CFanFlatVecProjectionGeometry2D*>(_pProjGeom);
- mxArray* pVectors = mxCreateDoubleMatrix(1, pVecGeom->getProjectionAngleCount()*6, mxREAL);
+
+ mGeometryInfo["type"] = mxCreateString("fanflat_vec");
+ mGeometryInfo["DetectorCount"] = mxCreateDoubleScalar(pVecGeom->getDetectorCount());
+
+ mxArray* pVectors = mxCreateDoubleMatrix(pVecGeom->getProjectionAngleCount(), 6, mxREAL);
double* out = mxGetPr(pVectors);
int iDetCount = pVecGeom->getDetectorCount();
+ int iAngleCount = pVecGeom->getProjectionAngleCount();
for (int i = 0; i < pVecGeom->getProjectionAngleCount(); i++) {
const SFanProjection* p = &pVecGeom->getProjectionVectors()[i];
- out[6*i + 0] = p->fSrcX;
- out[6*i + 1] = p->fSrcY;
- out[6*i + 2] = p->fDetSX + 0.5f*iDetCount*p->fDetUX;
- out[6*i + 3] = p->fDetSY + 0.5f*iDetCount*p->fDetUY;
- out[6*i + 4] = p->fDetUX;
- out[6*i + 5] = p->fDetUY;
+ out[0*iAngleCount + i] = p->fSrcX;
+ out[1*iAngleCount + i] = p->fSrcY;
+ out[2*iAngleCount + i] = p->fDetSX + 0.5f*iDetCount*p->fDetUX;
+ out[3*iAngleCount + i] = p->fDetSY + 0.5f*iDetCount*p->fDetUY;
+ out[4*iAngleCount + i] = p->fDetUX;
+ out[5*iAngleCount + i] = p->fDetUY;
}
mGeometryInfo["Vectors"] = pVectors;
}
- // parallel specific options
- if (_pProjGeom->isOfType("parallel")) {
- // type
- mGeometryInfo["type"] = mxCreateString("parallel");
- }
- // fanflat specific options
- else if (_pProjGeom->isOfType("fanflat")) {
- astra::CFanFlatProjectionGeometry2D* pFanFlatGeom = dynamic_cast<astra::CFanFlatProjectionGeometry2D*>(_pProjGeom);
- // detectorCount
- mGeometryInfo["DistanceOriginSource"] = mxCreateDoubleScalar(pFanFlatGeom->getOriginSourceDistance());
- // detectorWidth
- mGeometryInfo["DistanceOriginDetector"] = mxCreateDoubleScalar(pFanFlatGeom->getOriginDetectorDistance());
- // type
- mGeometryInfo["type"] = mxCreateString("fanflat");
- }
+ // sparse_matrix
else if (_pProjGeom->isOfType("sparse_matrix")) {
astra::CSparseMatrixProjectionGeometry2D* pSparseMatrixGeom = dynamic_cast<astra::CSparseMatrixProjectionGeometry2D*>(_pProjGeom);
mGeometryInfo["type"] = mxCreateString("sparse_matrix");
mGeometryInfo["MatrixID"] = mxCreateDoubleScalar(CMatrixManager::getSingleton().getIndex(pSparseMatrixGeom->getMatrix()));
}
- else if(_pProjGeom->isOfType("fanflat_vec")) {
- mGeometryInfo["type"] = mxCreateString("fanflat_vec");
- }
// build and return the MATLAB struct
return buildStruct(mGeometryInfo);