Skip to content

Commit 1b87277

Browse files
committed
added APRConverter to APR, and then included some calling methods, then you call apr.get_apr(), instead of using the converter
1 parent dcf1cf1 commit 1b87277

File tree

4 files changed

+52
-30
lines changed

4 files changed

+52
-30
lines changed

examples/Example_get_apr.cpp

Lines changed: 19 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -45,33 +45,31 @@ int main(int argc, char **argv) {
4545
//the apr datastructure
4646
APR<uint16_t> apr;
4747

48-
APRConverter<uint16_t> apr_converter;
49-
5048
//read in the command line options into the parameters file
51-
apr_converter.par.Ip_th = options.Ip_th;
52-
apr_converter.par.rel_error = options.rel_error;
53-
apr_converter.par.lambda = options.lambda;
54-
apr_converter.par.mask_file = options.mask_file;
55-
apr_converter.par.min_signal = options.min_signal;
56-
apr_converter.par.SNR_min = options.SNR_min;
57-
apr_converter.par.normalized_input = options.normalize_input;
58-
apr_converter.par.neighborhood_optimization = options.neighborhood_optimization;
59-
apr_converter.par.output_steps = options.output_steps;
49+
apr.parameters.Ip_th = options.Ip_th;
50+
apr.parameters.rel_error = options.rel_error;
51+
apr.parameters.lambda = options.lambda;
52+
apr.parameters.mask_file = options.mask_file;
53+
apr.parameters.min_signal = options.min_signal;
54+
apr.parameters.SNR_min = options.SNR_min;
55+
apr.parameters.normalized_input = options.normalize_input;
56+
apr.parameters.neighborhood_optimization = options.neighborhood_optimization;
57+
apr.parameters.output_steps = options.output_steps;
6058

6159
//where things are
62-
apr_converter.par.input_image_name = options.input;
63-
apr_converter.par.input_dir = options.directory;
64-
apr_converter.par.name = options.output;
65-
apr_converter.par.output_dir = options.output_dir;
60+
apr.parameters.input_image_name = options.input;
61+
apr.parameters.input_dir = options.directory;
62+
apr.parameters.name = options.output;
63+
apr.parameters.output_dir = options.output_dir;
6664

67-
apr_converter.fine_grained_timer.verbose_flag = false;
68-
apr_converter.method_timer.verbose_flag = false;
69-
apr_converter.computation_timer.verbose_flag = false;
70-
apr_converter.allocation_timer.verbose_flag = false;
71-
apr_converter.total_timer.verbose_flag = true;
65+
apr.apr_converter.fine_grained_timer.verbose_flag = false;
66+
apr.apr_converter.method_timer.verbose_flag = false;
67+
apr.apr_converter.computation_timer.verbose_flag = false;
68+
apr.apr_converter.allocation_timer.verbose_flag = false;
69+
apr.apr_converter.total_timer.verbose_flag = true;
7270

7371
//Gets the APR
74-
if(apr_converter.get_apr(apr)){
72+
if(apr.get_apr()){
7573

7674
//Below is IO and outputting of the Implied Resolution Function through the Particle Cell level.
7775

examples/Example_get_apr.h

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,6 @@
66

77
#include "algorithm/APRParameters.hpp"
88
#include "data_structures/Mesh/PixelData.hpp"
9-
#include "algorithm/APRConverter.hpp"
109
#include "data_structures/APR/APR.hpp"
1110

1211

src/algorithm/APRConverter.hpp

Lines changed: 10 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,8 @@ template<typename ImageType>
2727
class APRConverter: public LocalIntensityScale, public ComputeGradient, public LocalParticleCellSet, public PullingScheme {
2828

2929
public:
30+
31+
3032
APRParameters par;
3133
APRTimer fine_grained_timer;
3234
APRTimer method_timer;
@@ -52,20 +54,21 @@ class APRConverter: public LocalIntensityScale, public ComputeGradient, public L
5254
}
5355
};
5456

55-
private:
5657
//get apr without setting parameters, and with an already loaded image.
5758
template<typename T>
5859
bool get_apr_method(APR<ImageType> &aAPR, PixelData<T> &input_image);
5960

61+
template<typename T>
62+
void auto_parameters(const PixelData<T> &input_img);
63+
64+
private:
65+
6066
//pointer to the APR structure so member functions can have access if they need
6167
const APR<ImageType> *apr;
6268

6369
template<typename T>
6470
void init_apr(APR<ImageType>& aAPR, PixelData<T>& input_image);
6571

66-
template<typename T>
67-
void auto_parameters(const PixelData<T> &input_img);
68-
6972
template<typename T>
7073
bool get_apr_method_from_file(APR<ImageType> &aAPR, const TiffUtils::TiffInfo &aTiffFile);
7174

@@ -191,7 +194,7 @@ bool APRConverter<ImageType>::get_apr_method(APR<ImageType> &aAPR, PixelData<T>&
191194
fine_grained_timer.stop_timer();
192195

193196
#ifndef APR_USE_CUDA
194-
method_timer.verbose_flag = true;
197+
//method_timer.verbose_flag = true;
195198
method_timer.start_timer("compute_gradient_magnitude_using_bsplines");
196199
get_gradient(image_temp, grad_temp, local_scale_temp, local_scale_temp2, bspline_offset, par);
197200
method_timer.stop_timer();
@@ -203,7 +206,7 @@ bool APRConverter<ImageType>::get_apr_method(APR<ImageType> &aAPR, PixelData<T>&
203206
method_timer.start_timer("compute_local_intensity_scale");
204207
get_local_intensity_scale(local_scale_temp, local_scale_temp2, par);
205208
method_timer.stop_timer();
206-
method_timer.verbose_flag = false;
209+
//method_timer.verbose_flag = false;
207210

208211
if(par.output_steps){
209212
TiffUtils::saveMeshAsTiff(par.output_dir + "local_intensity_scale_step.tif", local_scale_temp);
@@ -305,7 +308,7 @@ void APRConverter<ImageType>::get_gradient(PixelData<ImageType> &image_temp, Pix
305308
// Input: full sized image.
306309
// Output: down-sampled by 2 gradient magnitude (Note, the gradient is calculated at pixel level then maximum down sampled within the loops below)
307310

308-
fine_grained_timer.verbose_flag = true;
311+
//fine_grained_timer.verbose_flag = true;
309312

310313
fine_grained_timer.start_timer("threshold");
311314

src/data_structures/APR/APR.hpp

Lines changed: 23 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,11 +10,12 @@
1010
#include "../../algorithm/APRParameters.hpp"
1111
#include "../../numerics/APRCompress.hpp"
1212
#include "../../numerics/APRReconstruction.hpp"
13+
#include "../../algorithm/APRConverter.hpp"
14+
1315
#include "../../io/APRWriter.hpp"
1416
#include "APRAccess.hpp"
1517
#include "ExtraParticleData.hpp"
1618

17-
1819
template<typename ImageType>
1920
class APR {
2021

@@ -26,8 +27,11 @@ class APR {
2627
APRWriter apr_writer;
2728
APRReconstruction apr_recon;
2829

30+
2931
public:
32+
3033
APRAccess apr_access;
34+
APRConverter<ImageType> apr_converter;
3135

3236
ExtraParticleData<ImageType> particles_intensities;
3337
std::string name;
@@ -44,6 +48,24 @@ class APR {
4448

4549
inline uint64_t total_number_particles() const { return (apr_access).total_number_particles; }
4650

51+
///////////////////////////////////
52+
///
53+
/// APR Generation Methods (Calls members of the APRConverter class)
54+
///
55+
//////////////////////////////////
56+
57+
bool get_apr(){
58+
//copy across parameters
59+
this->apr_converter.par = parameters;
60+
return this->apr_converter.get_apr(*this);
61+
}
62+
63+
template<typename T>
64+
bool get_apr(PixelData<T>& input_img){
65+
this->apr_converter.par = parameters;
66+
return this->apr_converter.get_apr_method(*this, input_img);
67+
}
68+
4769
///////////////////////////////////
4870
///
4971
/// APR IO Methods (Calls members of the APRWriter class)

0 commit comments

Comments
 (0)