File tree Expand file tree Collapse file tree 1 file changed +28
-0
lines changed
Expand file tree Collapse file tree 1 file changed +28
-0
lines changed Original file line number Diff line number Diff line change @@ -160,6 +160,34 @@ class APR {
160160 parts[apr_iterator] = img_by_level[apr_iterator.level ()].at (apr_iterator.y (),apr_iterator.x (),apr_iterator.z ());
161161 }
162162 }
163+
164+ template <typename U,typename V>
165+ void get_parts_from_img (PixelData<U>& img,ExtraParticleData<V>& parts){
166+ //
167+ // Bevan Cheeseman 2016
168+ //
169+ // Samples particles from an image using the nearest pixel (rounded up, i.e. next pixel after particles that sit on off pixel locations)
170+ //
171+
172+ // initialization of the iteration structures
173+ APRIterator<ImageType> apr_iterator (*this ); // this is required for parallel access
174+ uint64_t particle_number;
175+ parts.data .resize (apr_iterator.total_number_particles ());
176+
177+
178+ #ifdef HAVE_OPENMP
179+ #pragma omp parallel for schedule(static) private(particle_number) firstprivate(apr_iterator)
180+ #endif
181+ for (particle_number = 0 ; particle_number < apr_iterator.total_number_particles (); ++particle_number) {
182+ // needed step for any parallel loop (update to the next part)
183+ apr_iterator.set_iterator_to_particle_by_number (particle_number);
184+
185+ parts[apr_iterator] = img.at (apr_iterator.y_nearest_pixel (),apr_iterator.x_nearest_pixel (),apr_iterator.z_nearest_pixel ());
186+
187+ }
188+
189+ }
190+
163191};
164192
165193
You can’t perform that action at this time.
0 commit comments