MayaFlux 0.5.0
Digital-First Multimedia Processing Framework
Loading...
Searching...
No Matches

◆ read_normalized_at() [1/4]

double MayaFlux::Kakshya::read_normalized_at ( const DataVariant v,
ImageFormat  format,
const std::optional< DataDimension::ValueRange > &  range,
size_t  elem_index 
)

Definition at line 130 of file PixelStorage.cpp.

134{
135 return std::visit(
136 [&](const auto& vec) -> double {
137 using T = typename std::decay_t<decltype(vec)>::value_type;
138
139 if constexpr (std::is_same_v<T, uint8_t>
140 || std::is_same_v<T, uint16_t>
141 || std::is_same_v<T, float>) {
142
143 if (elem_index >= vec.size())
144 return 0.0;
145
146 double raw {};
147 double type_max = 1.0;
148
149 if constexpr (std::is_same_v<T, uint8_t>) {
150 raw = static_cast<double>(vec[elem_index]);
151 type_max = 255.0;
152 } else if constexpr (std::is_same_v<T, uint16_t>) {
153 if (is_float_format(format)) {
154 raw = static_cast<double>(decode_half(vec[elem_index]));
155 } else {
156 raw = static_cast<double>(vec[elem_index]);
157 type_max = 65535.0;
158 }
159 } else {
160 raw = static_cast<double>(vec[elem_index]);
161 }
162
163 if (!range)
164 return raw / type_max;
165
166 if (range->invalid && raw == *range->invalid)
167 return std::numeric_limits<double>::quiet_NaN();
168
169 const double span = range->max - range->min;
170 if (span <= 0.0)
171 return 0.0;
172
173 return std::clamp((raw - range->min) / span, 0.0, 1.0);
174 } else {
175 return 0.0;
176 }
177 },
178 v);
179}
std::vector< double > range(std::span< const double > data, size_t n_windows, uint32_t hop_size, uint32_t window_size)
Value range (max - min) per window.
Definition Analysis.cpp:452

References is_float_format().

Referenced by MayaFlux::Kakshya::VideoStreamContainer::get_value_impl(), and read_normalized_at().

+ Here is the call graph for this function:
+ Here is the caller graph for this function: