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

Function makeGrayQuantIndexTable

deps/leptonica/src/grayquant.c:1842–1863  ·  view source on GitHub ↗

----------------------------------------------------------------------* * Quantization tables for linear thresholds of grayscale images * *----------------------------------------------------------------------*/ ! * \brief makeGrayQuantIndexTable() * * \param[in] nlevels number of output levels * \return table maps input gray level to colormap index, * or NU

Source from the content-addressed store, hash-verified

1840 * </pre>
1841 */
1842l_int32 *
1843makeGrayQuantIndexTable(l_int32 nlevels)
1844{
1845l_int32 *tab;
1846l_int32 i, j, thresh;
1847
1848 PROCNAME("makeGrayQuantIndexTable");
1849
1850 if ((tab = (l_int32 *)LEPT_CALLOC(256, sizeof(l_int32))) == NULL)
1851 return (l_int32 *)ERROR_PTR("calloc fail for tab", procName, NULL);
1852 for (i = 0; i < 256; i++) {
1853 for (j = 0; j < nlevels; j++) {
1854 thresh = 255 * (2 * j + 1) / (2 * nlevels - 2);
1855 if (i <= thresh) {
1856 tab[i] = j;
1857/* fprintf(stderr, "tab[%d] = %d\n", i, j); */
1858 break;
1859 }
1860 }
1861 }
1862 return tab;
1863}
1864
1865
1866/*!

Callers 4

pixThresholdTo2bppFunction · 0.85
pixThresholdTo4bppFunction · 0.85
pixThresholdOn8bppFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected