MCPcopy Create free account
hub / github.com/Tom94/tev / postprocessLab

Function postprocessLab

src/imageio/TiffImageLoader.cpp:1435–1545  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

1433}
1434
1435Task<void> postprocessLab(
1436 TIFF* tif,
1437 const uint16_t photometric,
1438 const uint16_t dataBitsPerSample,
1439 const size_t numColorChannels,
1440 const MultiChannelView<float>& rgbaView,
1441 ImageData& resultData,
1442 const int priority
1443) {
1444 if (numColorChannels != 3) {
1445 throw ImageLoadError{"CIELAB images without 3 color channels are not supported."};
1446 }
1447
1448 const Vector2i size = resultData.size();
1449 const size_t numPixels = posProd(size);
1450
1451 // Step 1: Decode the encoded values to CIE L*a*b* [L: 0..100, a: -128..127, b: -128..127]
1452 if (photometric == PHOTOMETRIC_CIELAB) {
1453 co_await ThreadPool::global().parallelFor(
1454 0uz,
1455 numPixels,
1456 numPixels * numColorChannels,
1457 [&](size_t i) {
1458 rgbaView[0, i] *= 100.0f;
1459 for (size_t c = 1; c < numColorChannels; ++c) {
1460 float& v = rgbaView[c, i];
1461 v *= 255.0f;
1462 v = v >= 128.0f ? v - 256.0f : v;
1463 }
1464 },
1465 priority
1466 );
1467 } else if (photometric == PHOTOMETRIC_ICCLAB) {
1468 co_await ThreadPool::global().parallelFor(
1469 0uz,
1470 numPixels,
1471 numPixels * numColorChannels,
1472 [&](size_t i) {
1473 rgbaView[0, i] *= 100.0f;
1474 for (size_t c = 1; c < numColorChannels; ++c) {
1475 float& v = rgbaView[c, i];
1476 v = v * 255.0f - 128.0f;
1477 }
1478 },
1479 priority
1480 );
1481 } else if (photometric == PHOTOMETRIC_ITULAB) {
1482 Vector3f decodeMin = {0.0f, -85.0f, -85.0f}, decodeMax = {100.0f, 85.0f, 85.0f};
1483 if (const auto decode = tiffGetSpan<float>(tif, TIFFTAG_DECODE); decode.size() >= 6) {
1484 decodeMin = {decode[0], decode[2], decode[4]};
1485 decodeMax = {decode[1], decode[3], decode[5]};
1486
1487 tlog::debug("Found ITULAB Decode tag: min={} max={}", decodeMin, decodeMax);
1488 }
1489
1490 co_await ThreadPool::global().parallelFor(
1491 0uz,
1492 numPixels,

Callers 1

readTiffImageFunction · 0.85

Calls 8

posProdFunction · 0.85
xyzToChromaMatrixFunction · 0.85
rec709ChromaFunction · 0.85
adaptWhiteBradfordFunction · 0.85
whiteD50Function · 0.85
whiteD65Function · 0.85
parallelForMethod · 0.80
sizeMethod · 0.45

Tested by

no test coverage detected