MCPcopy Create free account
hub / github.com/creatale/node-dv / ThresholdRectToPix_Native

Function ThresholdRectToPix_Native

deps/tesseract/opencl/openclwrapper.cpp:2308–2343  ·  view source on GitHub ↗

Reproducing the ThresholdRectToPix native version

Source from the content-addressed store, hash-verified

2306
2307//Reproducing the ThresholdRectToPix native version
2308static void ThresholdRectToPix_Native(const unsigned char* imagedata,
2309 int bytes_per_pixel,
2310 int bytes_per_line,
2311 const int* thresholds,
2312 const int* hi_values,
2313 Pix** pix) {
2314 int top = 0;
2315 int left = 0;
2316 int width = pixGetWidth(*pix);
2317 int height = pixGetHeight(*pix);
2318
2319 *pix = pixCreate(width, height, 1);
2320 uint32_t *pixdata = pixGetData(*pix);
2321 int wpl = pixGetWpl(*pix);
2322 const unsigned char* srcdata = imagedata + top * bytes_per_line +
2323 left * bytes_per_pixel;
2324 for (int y = 0; y < height; ++y) {
2325 const uint8_t *linedata = srcdata;
2326 uint32_t *pixline = pixdata + y * wpl;
2327 for (int x = 0; x < width; ++x, linedata += bytes_per_pixel) {
2328 bool white_result = true;
2329 for (int ch = 0; ch < bytes_per_pixel; ++ch) {
2330 if (hi_values[ch] >= 0 &&
2331 (linedata[ch] > thresholds[ch]) == (hi_values[ch] == 0)) {
2332 white_result = false;
2333 break;
2334 }
2335 }
2336 if (white_result)
2337 CLEAR_DATA_BIT(pixline, x);
2338 else
2339 SET_DATA_BIT(pixline, x);
2340 }
2341 srcdata += bytes_per_line;
2342 }
2343}
2344
2345static double thresholdRectToPixMicroBench(GPUEnv *env, TessScoreEvaluationInputData input, ds_device_type type) {
2346 double time;

Callers 1

Calls 5

pixGetWidthFunction · 0.85
pixGetHeightFunction · 0.85
pixCreateFunction · 0.85
pixGetDataFunction · 0.85
pixGetWplFunction · 0.85

Tested by

no test coverage detected