comparison Core/Images/ImageProcessing.cpp @ 3690:a9ce35d67c3c

implementation of "/instances/.../rendered" for grayscale images
author Sebastien Jodogne <s.jodogne@gmail.com>
date Tue, 25 Feb 2020 13:57:43 +0100
parents 3971ec6b1f72
children 2a170a8f1faf
comparison
equal deleted inserted replaced
3689:e85bfba2d307 3690:a9ce35d67c3c
1428 throw OrthancException(ErrorCode_NotImplemented); 1428 throw OrthancException(ErrorCode_NotImplemented);
1429 } 1429 }
1430 } 1430 }
1431 1431
1432 1432
1433 void ImageProcessing::ShiftScale(ImageAccessor& target,
1434 const ImageAccessor& source,
1435 float offset,
1436 float scaling,
1437 bool useRound)
1438 {
1439 // Rewrite "(x + offset) * scaling" as "a * x + b"
1440
1441 const float a = scaling;
1442 const float b = offset * scaling;
1443
1444 switch (target.GetFormat())
1445 {
1446 case PixelFormat_Grayscale8:
1447
1448 switch (source.GetFormat())
1449 {
1450 case PixelFormat_Float32:
1451 if (useRound)
1452 {
1453 ShiftScaleInternal<uint8_t, float, true, false>(
1454 target, source, a, b, std::numeric_limits<uint8_t>::min());
1455 }
1456 else
1457 {
1458 ShiftScaleInternal<uint8_t, float, false, false>(
1459 target, source, a, b, std::numeric_limits<uint8_t>::min());
1460 }
1461 return;
1462
1463 default:
1464 throw OrthancException(ErrorCode_NotImplemented);
1465 }
1466
1467 default:
1468 throw OrthancException(ErrorCode_NotImplemented);
1469 }
1470 }
1471
1472
1433 void ImageProcessing::Invert(ImageAccessor& image, int64_t maxValue) 1473 void ImageProcessing::Invert(ImageAccessor& image, int64_t maxValue)
1434 { 1474 {
1435 const unsigned int width = image.GetWidth(); 1475 const unsigned int width = image.GetWidth();
1436 const unsigned int height = image.GetHeight(); 1476 const unsigned int height = image.GetHeight();
1437 1477