I want to use the adaptiveThreshold
function from OpenCV in order to determine appropriate, local thresholds for values in a vector<double>
.
adaptiveThreshold
is specified in the docs as follows:
void adaptiveThreshold(InputArray src, OutputArray dst, double maxValue, int adaptiveMethod, int thresholdType, int blockSize, double C)
Note that src
has to be a Source 8-bit single-channel image (so the input needs to be of type CV_8UC1
if I understand correctly, please correct me if I'm wrong here...).
Since my vector<double>
is not of type CV_8UC1
, one way to approach this would be to normalize the values within a range of 0
and 255
and then feed the resulting normalized values as a vector<unsigned char>
into the adaptiveThreshold
function.
This might look good at first sight, but it comes with a large loss of precision as the values within my original vector<double>
grow very large and get normalized down to the range of 0
to 255
.
So, I am wondering if there isn't an option to use the adaptiveThreshold
function for a wider range of values. It seems so unlogical to me that it should only work with values with a max of 255
... It feels like I oversee something quite simple but I can't figure out how to solve the issue...
I'm afraid there isn't such an option for a wider range of values. But it is fairly easy to derive a version that takes 'double' values as OpenCV is open source. Just find the source code of adaptiveThreshold() and change it for your own use.