MCPcopy Create free account
hub / github.com/arrayfire/arrayfire / threshold

Function threshold

examples/image_processing/binary_thresholding.cpp:17–24  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

15using namespace af;
16
17array threshold(const array& in, float thresholdValue) {
18 int channels = in.dims(2);
19 array ret_val = in.copy();
20 if (channels > 1) ret_val = colorSpace(in, AF_GRAY, AF_RGB);
21 ret_val =
22 (ret_val < thresholdValue) * 0.0f + 255.0f * (ret_val > thresholdValue);
23 return ret_val;
24}
25
26/**
27 * Note:

Callers 2

otsuFunction · 0.70
mainFunction · 0.70

Calls 3

colorSpaceFunction · 0.85
dimsMethod · 0.45
copyMethod · 0.45

Tested by

no test coverage detected