23 #ifndef INTERPOLATIONFUNCTIONS_H_ 24 #define INTERPOLATIONFUNCTIONS_H_ 29 auto findDefectDetectors(T* data, std::vector<double>& filterFunction, std::vector<int>& defectDetectors,
30 unsigned int numberOfDetectors,
unsigned int numberOfProjections,
double threshMin,
31 double threshMax) ->
void {
33 std::vector<double> var(numberOfDetectors, 0.0);
34 unsigned int scale = 2;
36 for(
auto detInd = 0u; detInd < numberOfDetectors; detInd++){
37 double varMax = data[detInd];
38 double varMin = varMax;
39 for(
auto projInd = 0u; projInd < numberOfProjections - 1; projInd++){
40 var[detInd] += std::abs((
double)data[detInd + projInd*numberOfDetectors] - (
double)data[detInd + (projInd+1)*numberOfDetectors]);
41 if(data[detInd + projInd*numberOfDetectors] > varMax)
42 varMax = (double)data[detInd + projInd*numberOfDetectors];
43 if(data[detInd + projInd*numberOfDetectors] < varMin)
44 varMin = (double)data[detInd + projInd*numberOfDetectors];
46 var[detInd] *= std::pow(varMax - varMin, scale);
48 int addNeighboursToFlickering{2};
49 for(
auto detectorSeg = 0; detectorSeg < 2; detectorSeg++){
50 for(
auto i = 0u; i < numberOfDetectors/2; i++){
51 double thresh_segment = 0.0;
52 for(
auto j = 0; j < 9; j++){
53 int ind = (i - j) % (numberOfDetectors/2);
54 thresh_segment += filterFunction[j] * var[ind + detectorSeg * (numberOfDetectors/2)];
55 ind = (i + j) % (numberOfDetectors/2);
56 thresh_segment += filterFunction[j] * var[ind + detectorSeg * (numberOfDetectors/2)];
58 unsigned int detInd = detectorSeg * (numberOfDetectors/2) + i;
59 if(var[detInd] < threshMin*thresh_segment){
60 defectDetectors[detInd] = 1;
63 if(var[detInd] > threshMax * thresh_segment){
64 for(
int offset = -addNeighboursToFlickering; offset <= addNeighboursToFlickering; offset++){
65 defectDetectors[(detInd+offset)%numberOfDetectors] = 1;
75 unsigned int numberOfDetectors,
unsigned int numberOfProjections) ->
void {
76 unsigned int detID = 0;
78 while(detID < numberOfDetectors){
79 if(defectDetectors[detID]){
80 unsigned int det0 = detID;
82 while(defectDetectors[detID] && defectDetectors[(detID+1)%numberOfDetectors]){
86 for(
auto i = det0; i <= detID; i++){
87 float w1 = ((float)i - (
float)det0 + 1.0)/((float)detID - (
float)det0 + 2.0);
89 for(
auto projId = 0u; projId < numberOfProjections; projId++){
90 data[(i%numberOfDetectors) + projId*numberOfDetectors] = w0 * data[(det0-1)%numberOfDetectors + projId*numberOfDetectors] +
91 w1 * data[(detID+1)%numberOfDetectors + projId*numberOfDetectors];
auto interpolateDefectDetectors(T *data, std::vector< int > &defectDetectors, unsigned int numberOfDetectors, unsigned int numberOfProjections) -> void
auto findDefectDetectors(T *data, std::vector< double > &filterFunction, std::vector< int > &defectDetectors, unsigned int numberOfDetectors, unsigned int numberOfProjections, double threshMin, double threshMax) -> void
__constant__ float scale[1]