- bj.BackprojectView (filteredProj, darray.viewAngle());
-
-#ifdef HAVE_SGP
- if (trace >= TRACE_PLOT) {
- SGPDriver sgpDriverProj ("Projection");
- SGP sgpProj (sgpDriverProj);
- EZPlot ezplotProj (sgpProj);
-
- ezplotProj.ezset ("clear");
- ezplotProj.ezset ("title Filtered Projection");
- ezplotProj.ezset ("xticks major 5.");
- ezplotProj.ezset ("xlabel ");
- ezplotProj.ezset ("ylabel ");
- ezplotProj.ezset ("yporigin .5.");
- ezplotProj.ezset ("ylength .5.");
- ezplotProj.ezset ("box.");
- ezplotProj.ezset ("grid.");
- ezplotProj.addCurve (plot_xaxis, detval, m_nDet);
- ezplotProj.plot();
- ezplotProj.ezset ("clear");
- ezplotProj.ezset ("xticks major 5.");
- ezplotProj.ezset ("xlabel ");
- ezplotProj.ezset ("ylabel ");
- ezplotProj.ezset ("ylength .5.");
- ezplotProj.ezset ("box");
- ezplotProj.ezset ("grid");
- ezplotProj.addCurve (plot_xaxis, filteredProj, n_filteredProj);
- ezplotProj.plot();
-
- cout << "Do you want to exit with current pic (y/n)? " << flush;
- char str[256];
- fgets(str, sizeof(str), stdin);
- if (tolower(str[0]) == 'y') {
- break;
+ double* pdThetaValuesForT = new double [pProjNew->nView()];
+ double* pdRaysumsForT = new double [pProjNew->nView()];
+
+ // interpolate to evenly spaced theta (views)
+ double dDetPos = pProjNew->m_detStart;
+ for (int iD = 0; iD < pProjNew->nDet(); iD++, dDetPos += pProjNew->m_detInc) {
+ parallel.getThetaAndRaysumsForT (iD, pdThetaValuesForT, pdRaysumsForT);
+
+ double dViewAngle = m_rotStart;
+ int iLastFloor = -1;
+ for (int iV = 0; iV < pProjNew->nView(); iV++, dViewAngle += pProjNew->m_rotInc) {
+ DetectorValue* detValues = pProjNew->getDetectorArray (iV).detValues();
+
+ detValues[iD] = parallel.interpolate (pdThetaValuesForT, pdRaysumsForT, pProjNew->nView(), dViewAngle, &iLastFloor);
+ }
+ }
+ delete pdThetaValuesForT;
+ delete pdRaysumsForT;
+
+ // interpolate to evenly space t (detectors)
+ double* pdOriginalDetPositions = new double [pProjNew->nDet()];
+ parallel.getDetPositions (pdOriginalDetPositions);
+
+ double* pdDetValueCopy = new double [pProjNew->nDet()];
+ double dViewAngle = m_rotStart;
+ for (int iV = 0; iV < pProjNew->nView(); iV++, dViewAngle += pProjNew->m_rotInc) {
+ DetectorArray& detArray = pProjNew->getDetectorArray (iV);
+ DetectorValue* detValues = detArray.detValues();
+ detArray.setViewAngle (dViewAngle);
+
+ for (int i = 0; i < pProjNew->nDet(); i++)
+ pdDetValueCopy[i] = detValues[i];
+
+ double dDetPos = pProjNew->m_detStart;
+ int iLastFloor = -1;
+ for (int iD = 0; iD < pProjNew->nDet(); iD++, dDetPos += pProjNew->m_detInc) {
+ detValues[iD] = parallel.interpolate (pdOriginalDetPositions, pdDetValueCopy, pProjNew->nDet(), dDetPos, &iLastFloor);
+ }
+ }
+ delete pdDetValueCopy;
+ delete pdOriginalDetPositions;
+
+ return pProjNew;
+}
+
+
+///////////////////////////////////////////////////////////////////////////////
+//
+// Class ParallelRaysums
+//
+// Used for converting divergent beam raysums into Parallel raysums
+//
+///////////////////////////////////////////////////////////////////////////////
+
+ParallelRaysums::ParallelRaysums (const Projections* pProjections, int iThetaRange)
+: m_iNumCoordinates(0), m_iNumView(pProjections->nView()), m_iNumDet(pProjections->nDet()),
+ m_iThetaRange (iThetaRange), m_pCoordinates(NULL)
+{
+ int iGeometry = pProjections->geometry();
+ double dDetInc = pProjections->detInc();
+ double dDetStart = pProjections->detStart();
+ double dFocalLength = pProjections->focalLength();
+
+ m_iNumCoordinates = m_iNumView * m_iNumDet;
+ m_pCoordinates = new ParallelRaysumCoordinate [m_iNumCoordinates];
+ m_vecpCoordinates.reserve (m_iNumCoordinates);
+ for (int i = 0; i < m_iNumCoordinates; i++)
+ m_vecpCoordinates[i] = m_pCoordinates + i;
+
+ int iCoordinate = 0;
+ for (int iV = 0; iV < m_iNumView; iV++) {
+ double dViewAngle = pProjections->getDetectorArray(iV).viewAngle();
+ const DetectorValue* detValues = pProjections->getDetectorArray(iV).detValues();
+
+ double dDetPos = dDetStart;
+ for (int iD = 0; iD < m_iNumDet; iD++) {
+ ParallelRaysumCoordinate* pC = m_vecpCoordinates[iCoordinate++];
+
+ if (iGeometry == Scanner::GEOMETRY_PARALLEL) {
+ pC->m_dTheta = dViewAngle;
+ pC->m_dT = dDetPos;
+ } else if (iGeometry == Scanner::GEOMETRY_EQUILINEAR) {
+ double dFanAngle = atan (dDetPos / pProjections->sourceDetectorLength());
+ pC->m_dTheta = dViewAngle + dFanAngle;
+ pC->m_dT = dFocalLength * sin(dFanAngle);
+
+ } else if (iGeometry == Scanner::GEOMETRY_EQUIANGULAR) {
+ // fan angle is same as dDetPos
+ pC->m_dTheta = dViewAngle + dDetPos;
+ pC->m_dT = dFocalLength * sin (dDetPos);