void rsInfoFreeParams(rsInfoParameters* p) { rsFree(p->inputpath); rsFree(p->dicompath); rsFree(p->extensionSource); rsFree(p->outputpath); rsUIDestroyInterface(p->interface); rsFree(p); }
void rsOrientationFreeParams(rsOrientationParameters *p) { rsFree(p->inputpath); rsFree(p->outputpath); rsFree(p->dicompath); rsFree(p->orientation); rsFree(p->phaseencdir); rsFree(p->input); rsFree(p->dicom); rsFree(p->output); rsFree(p->callString); rsUIDestroyInterface(p->interface); rsFree(p); }
void rsApplyTransformationFreeParams(rsApplyTransformationParameters *p) { rsFree(p->inputpath); rsFree(p->outputpath); rsFree(p->referencepath); rsFree(p->input); rsFree(p->output); rsFree(p->transform); rsFree(p->callString); rsFree(p->coordinateSpaceTypeInput); rsUIDestroyInterface(p->interface); rsFree(p); }
double rsInterpolation3DLanczosInterpolation(double***data, short xh, short yh, short zh, double voxSize[3], FloatPoint3D *point) { const int order = 3; SignedPoint3D *convStart = rsMakeSignedPoint3D( floor(point->x)-order+1, floor(point->y)-order+1, floor(point->z)-order+1 ); SignedPoint3D *convEnd = rsMakeSignedPoint3D( floor(point->x)+order, floor(point->y)+order, floor(point->z)+order ); double result = 0.0; // return a linear interpolated value if we exceed the bounds of this interpolation method if (!rsSignedPointInVolume(convStart, xh, yh, zh) || !rsSignedPointInVolume(convEnd, xh, yh, zh)) { rsFree(convStart); rsFree(convEnd); return rsTriLinearDistInterpolation(data, xh, yh, zh, voxSize, point); } for (short i=convStart->x; i <= convEnd->x; i++) { for (short j=convStart->y; j <= convEnd->y; j++) { for (short k=convStart->z; k <= convEnd->z; k++) { const double S = data[k][j][i]; // use linear interpolation when dealing with NaN/Inf values if(!isfinite(S)) { return rsTriLinearDistInterpolation(data, xh, yh, zh, voxSize, point); } const double Li = rsInterpolationLanczosKernel(point->x-i, order); const double Lj = rsInterpolationLanczosKernel(point->y-j, order); const double Lk = rsInterpolationLanczosKernel(point->z-k, order); result += S * Li * Lj * Lk; } } } rsFree(convStart); rsFree(convEnd); return result; }
void rsDeobliqueFreeParams(rsDeobliqueParameters *p) { rsFree(p->inputpath); rsFree(p->outputpath); rsFree(p->transformationpath); rsFree(p->input); rsFree(p->output); rsFree(p->transform); rsFree(p->callString); rsUIDestroyInterface(p->interface); rsFree(p); }
void Smoothing::_run() { params->progressCallback = (rsReportProgressCallback*)rsMalloc(sizeof(rsReportProgressCallback)); params->progressCallback->cb = (rsReportProgressCallback_t) RSTool::showProgressCallback; params->progressCallback->data = (void*)oc; rsSmoothingRun(params); rsFree(params->progressCallback); }
void rsFitFreeParams(rsFitParameters *p) { rsFree(p->inputpath); rsFree(p->targetpath); rsFree(p->betaspath); rsFree(p->input); rsFree(p->betas); rsFree(p->target); rsFree(p->callString); rsUIDestroyInterface(p->interface); rsFree(p); }
void Correlation::_run() { params->progressCallback = (rsReportProgressCallback*)rsMalloc(sizeof(rsReportProgressCallback)); params->progressCallback->cb = (rsReportProgressCallback_t) RSTool::showProgressCallback; params->progressCallback->data = (void*)oc; rsCorrelationRun(params); rsFree(params->progressCallback); }
void rsZeropaddingFreeParams(rsZeropaddingParameters *p) { rsFree(p->inputpath); rsFree(p->outputpath); rsFree(p->input); rsFree(p->output); rsFree(p->callString); rsUIDestroyInterface(p->interface); rsFree(p); }
double rsTriLinearDistInterpolation(double***data, short xh, short yh, short zh, double voxSize[3], FloatPoint3D *point) { SignedPoint3D *a = rsMakeSignedPoint3D(floor(point->x), floor(point->y), floor(point->z)); SignedPoint3D *b = rsMakeSignedPoint3D(a->x+1, a->y+1, a->z+1); // construct 8 points surrounding the point to be interpolated SignedPoint3D* points[8] = { rsMakeSignedPoint3D(a->x, a->y, a->z), // q000 rsMakeSignedPoint3D(b->x, a->y, a->z), // q001 rsMakeSignedPoint3D(a->x, b->y, a->z), // q010 rsMakeSignedPoint3D(b->x, b->y, a->z), // q011 rsMakeSignedPoint3D(a->x, a->y, b->z), // q100 rsMakeSignedPoint3D(b->x, a->y, b->z), // q101 rsMakeSignedPoint3D(a->x, b->y, b->z), // q110 rsMakeSignedPoint3D(b->x, b->y, b->z) // q111 }; // determine which points lie within the volume and compute their distances double summedInvDistance=0.0; double weightedInvSum = 0.0; short nValidPoints = 0; for (short i=0; i<8; i++) { BOOL validPoint = rsSignedPointInVolume(points[i], xh, yh, zh); if (validPoint) { const double S = data[points[i]->z][points[i]->y][points[i]->x]; // ignore NaN and Inf values if (!isfinite(S)) { continue; } // inv dist in each direction float invDist[3] = { 1.0 - fabs(point->x - points[i]->x), 1.0 - fabs(point->y - points[i]->y), 1.0 - fabs(point->z - points[i]->z) }; // scale by the corresponding voxel size for (short d=0; d<3; d++) { invDist[d] = invDist[d] / voxSize[d]; } // euclidean dist sqrt((1-dx)^2 + (1-dy)^2 + (1-dz)^2) const double invDistance = pow( ( pow(invDist[0], 2.0) + pow(invDist[1], 2.0) + pow(invDist[2], 2.0) ), 0.5 ); summedInvDistance += invDistance; weightedInvSum += invDistance * S; nValidPoints++; } } // clear data for (short i=0; i<8; i++) { rsFree(points[i]); } rsFree(a); rsFree(b); // terminate with NaN if no points lie withing the volume if (nValidPoints < 1) { return log(-1.0); } // normalize weighted sum and return it return weightedInvSum / summedInvDistance; }