25
25
#define M_PI 3.14159265358979323846
26
26
#endif
27
27
28
- constexpr int default_p = 400 ;
29
- constexpr int default_q = 400 ;
30
- constexpr double default_S_to_D = 1.0 ;
31
- static const std::string default_original_bmpname = " input.bmp" ;
32
- static const std::string default_radon_bmpname = " radon.bmp" ;
33
- static const std::string default_restored_bmpname = " restored.bmp" ;
34
- static const std::string default_errors_bmpname = " errors.bmp" ;
35
- constexpr int default_crop = 1 ;
36
- #ifdef _WIN64
37
- static const std::string program_name = " compute_tomography.exe" ;
38
- #else
39
- static const std::string program_name = " compute_tomography" ;
40
- #endif
41
- constexpr double arbitrary_error_threshold = 0.1 ;
42
- static const std::string usage_info =
43
- " \n \
44
- Usage:\n \
45
- ======\n \
46
- " + program_name + " p q in radon_out restored_out S_to_D err_out crop\n \
47
- Inputs:\n \
48
- -------\n \
49
- p - number of projection directions considered for the Radon\n \
50
- transform (number of angles spanning a range of M_PI).\n \
51
- p must be a strictly positive integer (default value is " +
52
- std::to_string (default_p) + ").\n\
53
- q - number of samples of the Radon transform for every\n\
54
- projection direction.\n\
55
- q must be a strictly positive integer (default value is " +
56
- std::to_string(default_q) + " ).\n\
57
- in - name of the input image used to generate Radon transform data.\n\
58
- The file must be a 24-bit uncompressed bitmap file.\n\
59
- \"" + default_original_bmpname + "\" is considered by default.\n\
60
- S_to_D - ratio of the scanning width used for sampling the Radon\n\
61
- transform (for any projection direction) to the diagonal of\n\
62
- the input image.\n\
63
- S_to_D must be a floating-point value larger than or equal\n\
64
- to 1.0 (default value is " +
65
- std::to_string(default_S_to_D) + " ).\n\
66
- crop - integer flag indicating whether to crop the generated bitmap\n\
67
- output images to their range of relevance or not. Images are\n\
68
- (resp. are not ) cropped if the value is 1 (resp. 0 ).\n\
69
- The supported values are 0 and 1 (default value is "
70
- + std::to_string(default_crop) + " ).\n\
71
- Outputs:\n\
72
- --------\n\
73
- radon_out - name of a 24-bit uncompressed bitmap image file storing a\n\
74
- gray-scaled image representing the generated Radon\n\
75
- transform data points.\n\
76
- \"" + default_radon_bmpname + "\" is used by default.\n\
77
- restored_out - name of a 24-bit uncompressed bitmap image file storing a\n\
78
- gray-scaled image representing the image reconstructed\n\
79
- from the Radon transform data points.\n\
80
- \"" + default_restored_bmpname + "\" is used by default.\n\
81
- err_out - name of a 24-bit uncompressed bitmap image file storing a\n\
82
- gray-scaled image representing the pixel-wise error in the\n\
83
- restored_out file. This file is created only if the mean\n\
84
- global error is found to exceed "
85
- + std::to_string(100.0 *arbitrary_error_threshold) +
86
- "% of the maximum\n\
87
- gray-scale value in the original image.\n\
88
- \"" + default_errors_bmpname + "\" is considered by default.\n\
89
- ";
90
-
91
28
namespace dft_ns = oneapi::mkl::dft;
92
29
using real_descriptor_t =
93
30
dft_ns::descriptor<dft_ns::precision::DOUBLE, dft_ns::domain::REAL>;
@@ -807,6 +744,65 @@ double compute_errors(padded_matrix& errors,
807
744
}
808
745
809
746
int main (int argc, char **argv) {
747
+ constexpr int default_p = 400 ;
748
+ constexpr int default_q = 400 ;
749
+ constexpr double default_S_to_D = 1.0 ;
750
+ constexpr std::string_view default_original_bmpname = " input.bmp" ;
751
+ constexpr std::string_view default_radon_bmpname = " radon.bmp" ;
752
+ constexpr std::string_view default_restored_bmpname = " restored.bmp" ;
753
+ constexpr std::string_view default_errors_bmpname = " errors.bmp" ;
754
+ constexpr int default_crop = 1 ;
755
+ constexpr double arbitrary_error_threshold = 0.1 ;
756
+ /* ----------------------- USAGE INFO START --------------------------------*/
757
+ const std::string usage_info =
758
+ " \n \
759
+ Usage:\n \
760
+ ======\n \
761
+ " + std::string (argv[0 ]) + " p q in radon_out restored_out S_to_D err_out crop\n \
762
+ Inputs:\n \
763
+ -------\n \
764
+ p - number of projection directions considered for the Radon\n \
765
+ transform (number of angles spanning a range of M_PI).\n \
766
+ p must be a strictly positive integer (default value is " +
767
+ std::to_string (default_p) + " ).\n \
768
+ q - number of samples of the Radon transform for every\n \
769
+ projection direction.\n \
770
+ q must be a strictly positive integer (default value is " +
771
+ std::to_string (default_q) + " ).\n \
772
+ in - name of the input image used to generate Radon transform data.\n \
773
+ The file must be a 24-bit uncompressed bitmap file.\n \
774
+ \" " + std::string (default_original_bmpname) + " \" is considered by default.\n \
775
+ S_to_D - ratio of the scanning width used for sampling the Radon\n \
776
+ transform (for any projection direction) to the diagonal of\n \
777
+ the input image.\n \
778
+ S_to_D must be a floating-point value larger than or equal\n \
779
+ to 1.0 (default value is " +
780
+ std::to_string (default_S_to_D) + " ).\n \
781
+ crop - integer flag indicating whether to crop the generated bitmap\n \
782
+ output images to their range of relevance or not. Images are\n \
783
+ (resp. are not) cropped if the value is 1 (resp. 0).\n \
784
+ The supported values are 0 and 1 (default value is "
785
+ + std::to_string (default_crop) + " ).\n \
786
+ Outputs:\n \
787
+ --------\n \
788
+ radon_out - name of a 24-bit uncompressed bitmap image file storing a\n \
789
+ gray-scaled image representing the generated Radon\n \
790
+ transform data points.\n \
791
+ \" " + std::string (default_radon_bmpname) + " \" is used by default.\n \
792
+ restored_out - name of a 24-bit uncompressed bitmap image file storing a\n \
793
+ gray-scaled image representing the image reconstructed\n \
794
+ from the Radon transform data points.\n \
795
+ \" " + std::string (default_restored_bmpname) + " \" is used by default.\n \
796
+ err_out - name of a 24-bit uncompressed bitmap image file storing a\n \
797
+ gray-scaled image representing the pixel-wise error in the\n \
798
+ restored_out file. This file is created only if the mean\n \
799
+ global error is found to exceed "
800
+ + std::to_string (100.0 *arbitrary_error_threshold) +
801
+ " % of the maximum\n \
802
+ gray-scale value in the original image.\n \
803
+ \" " + std::string (default_errors_bmpname) + " \" is considered by default.\n \
804
+ " ;
805
+ /* ------------------------ USAGE INFO END --------------------------------*/
810
806
if (argc > 1 &&
811
807
(std::strcmp (argv[1 ], " -h" ) == 0 || std::strcmp (argv[1 ], " -H" ) == 0 )) {
812
808
std::cout << usage_info << std::endl;
@@ -817,15 +813,15 @@ int main(int argc, char **argv) {
817
813
const int q = argc > 2 ? std::atoi (argv[2 ]) :
818
814
default_q;
819
815
const std::string original_bmpname = argc > 3 ? argv[3 ] :
820
- default_original_bmpname;
816
+ std::string ( default_original_bmpname) ;
821
817
const std::string radon_bmpname = argc > 4 ? argv[4 ] :
822
- default_radon_bmpname;
818
+ std::string ( default_radon_bmpname) ;
823
819
const std::string restored_bmpname = argc > 5 ? argv[5 ] :
824
- default_restored_bmpname;
820
+ std::string ( default_restored_bmpname) ;
825
821
const double S_to_D = argc > 6 ? std::atof (argv[6 ]) :
826
822
default_S_to_D;
827
823
const std::string errors_bmpname = argc > 7 ? argv[7 ] :
828
- default_errors_bmpname;
824
+ std::string ( default_errors_bmpname) ;
829
825
const int crop = argc > 8 ? std::atoi (argv[8 ]) :
830
826
default_crop;
831
827
// validate numerical input arguments
0 commit comments