I want to ask how this coefficient is calculated and can the coefficient in the picture be used as a general purpose if I have the airburst data and the projection data
I tried to implement it myself with matlab but I didn't get very good results. Do I need to normalize the input data in the program Here is my matlab code I want to implement the fitting coefficient of FSRF But it didn't work out well % Using ImageJ for operations:% 1. Extract the last 10 frames of the open exposure, convert to 32-bit, compute the average, draw ROI, measure, and save as an Excel file % 2. Extract the stack for the dark field, convert to 32-bit, draw ROI, use multi-measure, and save as an Excel file % 3. Split the stack and merge the stack % 4. Combine into one Excel file with open exposure data first and dark field data following % 5. Copy the mean to a .txt file % Result: mean.txt mean2 = table2array(mean); % Convert imported table type to array type m = mean2(1); n = mean2(2:end); nm = n / m; % Normalization FSRF = nm; x = 1:510; % Number of dark field frames x = x'; y = FSRF; % Dark field data % Fitting function fitfunc = @(params, x) (params(1) * exp(-params(2) * x) + params(3) * exp(-params(4) * x) + params(5) * exp(-params(6) * x) + params(7) * exp(-params(8) * x)); initialGuess = [7e-3, 0.001, 1e-2, 0.01, 1e-2, 0.08, 3e-2, 0.6]; % Initial values paramsFit = lsqcurvefit(fitfunc, initialGuess, x, y); B1_fit = paramsFit(1); A1_fit = paramsFit(2); B2_fit = paramsFit(3); A2_fit = paramsFit(4); B3_fit = paramsFit(5); A3_fit = paramsFit(6); B4_fit = paramsFit(7); A4_fit = paramsFit(8); y_fit = fitfunc(paramsFit, x); plot(x, y, 'ro', x, y_fit, 'b-'); grid on legend('Sample Data', 'Fitted Curve'); save AB.mat A1_fit A2_fit A3_fit A4_fit B1_fit B2_fit B3_fit B4_fit Here is the program I used to fit the coefficients in matlab into c++ // TaoSunLagCorrectionTest.cpp : Defines the entry point for the console application.// #include "stdafx.h" #include "TaoSunLagCorrection.h" #include "rtkLagCorrectionImageFilter.h" #include <chrono> // For timing #include <fstream> // For file operations // Suppress fopen warnings #pragma warning(disable:4996) int main() { int height = 1328; int width = 1024; int angles = 360; //-------------------- Read projection data ---------------- FILE* file1; const char* filename1 = "E:/TaoSunCUDA12/LagCorrection/data/Stack50-409_110kv 15macu 0.5mm 50hz - CT Phantom - full-fan.raw"; // Buffer to store read data float* proj1 = (float*)malloc(height * width * angles * sizeof(float)); if (proj1 == NULL) { printf("Memory allocation failed.\n"); return -1; } file1 = fopen(filename1, "rb"); if (file1 == NULL) { printf("Cannot open file %s\n", filename1); return -1; } // Read data from file into memory (vector) printf("Starting to read projection ... \n"); fread(proj1, sizeof(float), height * width * angles, file1); fclose(file1); //--------------------- Correction ---------------------- float* projoutput = (float*)malloc(height * width * angles * sizeof(float)); // Start timing auto start_time = std::chrono::high_resolution_clock::now(); // Lag correction parameters: detector (inherent characteristics), frame rate (default binning mode) printf("Starting lag correction ... \n"); float m_A[4] = { 0.7055f, 0.141f, 0.0212f, 0.0033f }; float m_B[4] = { 2.911e-3f, 0.4454e-3f, 0.0748e-3f, 0.0042e-3f }; taoSun_LagCorrection(projoutput, proj1, m_A, m_B, height, width, angles); // End timing auto end_time = std::chrono::high_resolution_clock::now(); // Output elapsed time std::chrono::duration<double> elapsed = end_time - start_time; std::cout << "Total execution time: " << elapsed.count() << " seconds" << std::endl; // After processing all projections, write the large memory data to a file in one go printf("Starting to write corrected projection ... \n"); std::ofstream outputFile("E:/TaoSunCUDA12/LagCorrection/data/output0902.raw", std::ios::binary); // Open a new raw file for writing processed data if (!outputFile.is_open()) { std::cerr << "Error: Cannot open output raw file!" << std::endl; return EXIT_FAILURE; } size_t totalSize = angles * height * width * sizeof(float); // Pre-calculate total memory required for all projection data outputFile.write(reinterpret_cast<const char*>(projoutput), totalSize); outputFile.close(); // Close the file // Release the large allocated memory free(projoutput); free(proj1); std::cout << "\n\nTest PASSED! " << std::endl; return 0; }
366B5C00@EDDFEE43.CA4C246700000000.png
Description: Binary data
_______________________________________________ Rtk-users mailing list rtk-us...@openrtk.org https://www.creatis.insa-lyon.fr/mailman/listinfo/rtk-users