Developer documentation
Version 3.0.3-105-gd3941f44
vector_structs.h
Go to the documentation of this file.
1/* Copyright (c) 2008-2022 the MRtrix3 contributors.
2 *
3 * This Source Code Form is subject to the terms of the Mozilla Public
4 * License, v. 2.0. If a copy of the MPL was not distributed with this
5 * file, You can obtain one at http://mozilla.org/MPL/2.0/.
6 *
7 * Covered Software is provided under this License on an "as is"
8 * basis, without warranty of any kind, either expressed, implied, or
9 * statutory, including, without limitation, warranties that the
10 * Covered Software is free of defects, merchantable, fit for a
11 * particular purpose or non-infringing.
12 * See the Mozilla Public License v. 2.0 for more details.
13 *
14 * For more details, see http://www.mrtrix.org/.
15 */
16
17#ifndef __gui_mrview_tool_fixel_structs_h__
18#define __gui_mrview_tool_fixel_structs_h__
19
20namespace MR
21{
22 namespace GUI
23 {
24 namespace MRView
25 {
26 namespace Tool
27 {
30
32 bool loaded = false;
33 float value_min = std::numeric_limits<float>::max ();
34 float value_max = std::numeric_limits<float>::min ();
38
39
40 void clear () {
41 buffer_store.clear();
42 loaded = false;
43 current_min = value_min = std::numeric_limits<float>::max ();
44 current_max = value_max = std::numeric_limits<float>::min ();
45 }
46
47 void add_value (float value) {
48 buffer_store.push_back (value);
49 value_min = std::min (value_min, value);
50 value_max = std::max (value_max, value);
51 }
52
53
58 }
59
60
61 void set_windowing (float min, float max) {
62 current_min = min;
63 current_max = max;
64 }
65
66
67 float get_relative_threshold_lower (FixelValue& fixel_value) const {
68
69 float relative_min = std::numeric_limits<float>::max();
70
71 // Find min value based relative to lower-thresholded fixels
72 for(size_t i = 0, N = buffer_store.size(); i < N; ++i) {
73 if (buffer_store[i] > lessthan)
74 relative_min = std::min(relative_min, fixel_value.buffer_store[i]);
75 }
76
77 // Clamp our value to windowing
78 return std::max(relative_min, fixel_value.current_min);
79 }
80
81
82 float get_relative_threshold_upper (FixelValue& fixel_value) const {
83
84 float relative_max = std::numeric_limits<float>::min();
85
86 // Find max value based relative to upper-thresholded fixels
87 for(size_t i = 0, N = buffer_store.size(); i < N; ++i) {
89 relative_max = std::max(relative_max, fixel_value.buffer_store[i]);
90 }
91
92 // Clamp our value to windowing
93 return std::min(relative_max, fixel_value.current_max);
94 }
95
96 };
97
98 }
99 }
100 }
101}
102
103#endif
VectorType::Scalar value(const VectorType &coefs, typename VectorType::Scalar cos_elevation, typename VectorType::Scalar cos_azimuth, typename VectorType::Scalar sin_azimuth, int lmax)
Definition: SH.h:233
Definition: base.h:24
float get_relative_threshold_lower(FixelValue &fixel_value) const
MEMALIGN(FixelValue) bool loaded
float get_relative_threshold_upper(FixelValue &fixel_value) const
void set_windowing(float min, float max)