Skip to content
Snippets Groups Projects
Commit 41fcad3e authored by jstark's avatar jstark
Browse files

Changed image size type from size_t to int.

parent 6bf07eee
No related branches found
No related tags found
No related merge requests found
Pipeline #3426 failed
...@@ -41,9 +41,9 @@ inline bool exists_test (const std::string& name) { ...@@ -41,9 +41,9 @@ inline bool exists_test (const std::string& name) {
* #pixels per dimension. * #pixels per dimension.
* @return Std::vector containing the count of pixels for each dimension as it was read from the csv file. * @return Std::vector containing the count of pixels for each dimension as it was read from the csv file.
*/ */
std::vector<size_t> get_size(const std::string & path_to_file) std::vector<int> get_size(const std::string & path_to_file)
{ {
std::vector<size_t> stack_dimst_1d; std::vector<int> stack_dimst_1d;
// check if file exists and stream input csv file // check if file exists and stream input csv file
if(!exists_test(path_to_file)){ if(!exists_test(path_to_file)){
std::cout << "------------------------------------------------------------------------" << std::endl; std::cout << "------------------------------------------------------------------------" << std::endl;
...@@ -67,7 +67,7 @@ std::vector<size_t> get_size(const std::string & path_to_file) ...@@ -67,7 +67,7 @@ std::vector<size_t> get_size(const std::string & path_to_file)
while ( getline(file, field) ) // 1 field per axis while ( getline(file, field) ) // 1 field per axis
{ {
std::istringstream iss(field); std::istringstream iss(field);
size_t val; int val;
iss >> val; iss >> val;
stack_dimst_1d.push_back(val); // add the #pixels for current axis to the array stack_dimst_1d.push_back(val); // add the #pixels for current axis to the array
} }
...@@ -89,7 +89,7 @@ std::vector<size_t> get_size(const std::string & path_to_file) ...@@ -89,7 +89,7 @@ std::vector<size_t> get_size(const std::string & path_to_file)
* manually or loaded from a csv file before (see: #get_size()) * manually or loaded from a csv file before (see: #get_size())
*/ */
template <size_t Phi_0, typename grid_type> template <size_t Phi_0, typename grid_type>
void load_pixel_onto_grid(grid_type & grid, std::string file_name, std::vector <size_t> & stack_dims) void load_pixel_onto_grid(grid_type & grid, std::string file_name, std::vector <int> & stack_dims)
{ {
constexpr size_t x = 0; constexpr size_t x = 0;
constexpr size_t y = 1; constexpr size_t y = 1;
...@@ -107,7 +107,7 @@ void load_pixel_onto_grid(grid_type & grid, std::string file_name, std::vector < ...@@ -107,7 +107,7 @@ void load_pixel_onto_grid(grid_type & grid, std::string file_name, std::vector <
auto & v_cl = create_vcluster(); auto & v_cl = create_vcluster();
if (v_cl.rank() == 0) if (v_cl.rank() == 0)
{ {
for (size_t d = 0; d < grid_type::dims; d++) for (int d = 0; d < grid_type::dims; d++)
{ {
std::cout << "# grid points in dimension " << d << " = " << grid.size(d) << std::endl; std::cout << "# grid points in dimension " << d << " = " << grid.size(d) << std::endl;
} }
...@@ -121,14 +121,14 @@ void load_pixel_onto_grid(grid_type & grid, std::string file_name, std::vector < ...@@ -121,14 +121,14 @@ void load_pixel_onto_grid(grid_type & grid, std::string file_name, std::vector <
std::vector<BYTE> pixel_line; // one x-line of the image stack which will be read std::vector<BYTE> pixel_line; // one x-line of the image stack which will be read
size_t sz_img[grid_type::dims]; size_t sz_img[grid_type::dims];
for (size_t d = 0; d < grid_type::dims; d++) for (int d = 0; d < grid_type::dims; d++)
{ {
sz_img[d] = stack_dims[d]; sz_img[d] = stack_dims[d];
} }
grid_sm<grid_type::dims,void> ginfo_image(sz_img); // in order to get the image related key later on grid_sm<grid_type::dims,void> ginfo_image(sz_img); // in order to get the image related key later on
double refinement[grid_type::dims]; double refinement[grid_type::dims];
for (size_t d = 0; d < grid_type::dims; d++) for (int d = 0; d < grid_type::dims; d++)
{ {
refinement[d] = (double) grid.size(d) / (double)stack_dims[d]; // get the factor, by which the grid resolution differs from the image stack resolution refinement[d] = (double) grid.size(d) / (double)stack_dims[d]; // get the factor, by which the grid resolution differs from the image stack resolution
if (v_cl.rank() == 0) std::cout << "effective refinement in dimension " << d << " = " << refinement[d] << std::endl; if (v_cl.rank() == 0) std::cout << "effective refinement in dimension " << d << " = " << refinement[d] << std::endl;
...@@ -141,7 +141,7 @@ void load_pixel_onto_grid(grid_type & grid, std::string file_name, std::vector < ...@@ -141,7 +141,7 @@ void load_pixel_onto_grid(grid_type & grid, std::string file_name, std::vector <
// In case a patch starts within a group of nodes to which same pixel-value should be assigned, get the // In case a patch starts within a group of nodes to which same pixel-value should be assigned, get the
// respective rest-offset // respective rest-offset
size_t rest_offset = (size_t) (fmod(gkey.get(0), refinement[x])); // get the remainder int rest_offset = (int) (fmod(gkey.get(0), refinement[x])); // get the remainder
// get l as the length of one x-line of the original image stack for the specific patch on the processor // get l as the length of one x-line of the original image stack for the specific patch on the processor
...@@ -154,7 +154,7 @@ void load_pixel_onto_grid(grid_type & grid, std::string file_name, std::vector < ...@@ -154,7 +154,7 @@ void load_pixel_onto_grid(grid_type & grid, std::string file_name, std::vector <
// in case that the grid has a different resolution than the underlying image stack: // in case that the grid has a different resolution than the underlying image stack:
// create a key which is used to get the offset for the file reading // create a key which is used to get the offset for the file reading
// the indices in this key are corrected by the refinement factor // the indices in this key are corrected by the refinement factor
for (size_t d = 0; d < grid_type::dims; d++) for (int d = 0; d < grid_type::dims; d++)
{ {
gkey.set_d(d, floor(gkey.get(d) / refinement[d])); gkey.set_d(d, floor(gkey.get(d) / refinement[d]));
} }
...@@ -172,7 +172,7 @@ void load_pixel_onto_grid(grid_type & grid, std::string file_name, std::vector < ...@@ -172,7 +172,7 @@ void load_pixel_onto_grid(grid_type & grid, std::string file_name, std::vector <
// run over a whole grid-line in x and assign pixel values from pixel_line to grid nodes // run over a whole grid-line in x and assign pixel values from pixel_line to grid nodes
// if the grid is finer in x as the image stack, the same pixel value from pixel_line is // if the grid is finer in x as the image stack, the same pixel value from pixel_line is
// assigned refinement[x] times // assigned refinement[x] times
for (size_t k = 0; k < patch_size; ++k) for (int k = 0; k < patch_size; ++k)
{ {
auto key = dom.get(); auto key = dom.get();
// get the correct index of the pixel to be read from pixel_line by considering a potential rest-offset, // get the correct index of the pixel to be read from pixel_line by considering a potential rest-offset,
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment