MCPcopy Create free account
hub / github.com/SatDump/SatDump / normalize

Function normalize

src-core/common/image/processing.cpp:216–241  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

214 }
215
216 void normalize(Image &img)
217 {
218 int max = 0;
219 int min = img.maxval();
220
221 // Get min and max
222 for (size_t i = 0; i < img.size(); i++)
223 {
224 int val = img.get(i);
225
226 if (val > max)
227 max = val;
228 if (val < min)
229 min = val;
230 }
231
232 if (abs(max - min) == 0) // Avoid division by 0
233 return;
234
235 // Compute scaling factor
236 float factor = img.maxval() / float(max - min);
237
238 // Scale entire image
239 for (size_t i = 0; i < img.size(); i++)
240 img.set(i, img.clamp((img.get(i) - min) * factor));
241 }
242
243 void linear_invert(Image &img)
244 {

Callers 5

updateImageMethod · 0.85
compute_boundariesFunction · 0.85
loadExternalLayerFunction · 0.85
saveMethod · 0.85

Calls 5

maxvalMethod · 0.80
sizeMethod · 0.45
getMethod · 0.45
setMethod · 0.45
clampMethod · 0.45

Tested by

no test coverage detected