I am learning FBP and for the last 1 month, I am stuck on Backprojection Algorithm. I have done the following steps till now.
Create Sinogram (Radon Transform)
Create Filter (hanning Filter: i used the hanning window function to implement the filter) I know Ram filter works the best but I want to research how a different high pass filter will work on this.
Fast Fourier Transform.(using
dft
function)Apply the filter
Inverse Fourier Transform(using
dft
function)Pass the filtered sinogram through the backprojection algorithm. I am sharing 2 functions here:
Traditional Backprojection Algorithm (Found From LOC: 29)
Mat backprojectionTraditional(Mat inversefft) {
Mat reconstruction(inversefft.size(), CV_32F);
int numOfAngles = 180;
int dtheta = 180 / numOfAngles;
for (int x = 0; x < reconstruction.size().height; x++) {
double delta_t = M_PI / 180;
for (int y = 0; y < reconstruction.size().width; y++) {
reconstruction.at<float>(x, y) = 0.0;
for (int theta = 0; theta < inversefft.size().width; theta += dtheta) {
int s = (x - 0.5 * inversefft.size().height) * sin(theta * delta_t) +
(y - 0.5 * inversefft.size().height) * cos(theta * delta_t) + 0.5 * inversefft.size().height;
if (s > 0 && s < inversefft.size().height) {
reconstruction.at<float>(x, y) += inversefft.at<float>(s, theta);
}
}
if (reconstruction.at<float>(x, y) < 0)reconstruction.at<float>(x, y) = 0;
}
}
rotate(reconstruction, reconstruction, ROTATE_90_CLOCKWISE);
return reconstruction;
}
- The Iterative way as found in one book Page-72
Mat backprojectionIterative(Mat inversefft)
{
Mat iradon(inversefft.size(), CV_32F);
Mat projection(inversefft.size(), CV_32F);
float colsum;
for (int z = 0; z < 180; z++) {
projection = imrotate(inversefft, z);
//imshow("Projected image", projection);
//waitKey(0);
for (int i = 0; i < inversefft.size().width; i++) {
colsum = 0;
for (int j = 0; j < inversefft.size().height; j++) {
colsum += projection.at<float>(j, i);
//cout << colsum << endl;
}
for (int k = 0; k < inversefft.size().height; k++) {
//cout << "Break" << endl;
//cout << colsum << endl;
//cout << iradon.at<float>(k, i) << endl;
iradon.at<float>(k, i) += colsum;
//cout << iradon.at<float>(k, i) << endl;
}
}
//iradon = imrotate(iradon, 90);
//normalize(iradon, iradon, 0, 1, NORM_MINMAX, CV_32F);
//imshow("Reconstructed image", iradon);
//waitKey(0);
}
return iradon;
}
Can anyone tell me how to implement the backprojection algorithm and where is my error?
#P.S - This is my first question, I will fix it as soon as possible if I am not following the community standards. Thank you.
Edit - Since most of the viewers are not understanding the problem statement, I am uploading the results of both of these functions.
After Applying the backprojectionTraditional
function
After Applying the backprojectionIterative
function
The output should be same or nearly close as the input after applying backprojection.