Mercurial > hg > orthanc
comparison OrthancFramework/Sources/Images/ImageProcessing.cpp @ 4081:259c33759937 framework
integration mainline->framework
author | Sebastien Jodogne <s.jodogne@gmail.com> |
---|---|
date | Mon, 22 Jun 2020 19:04:45 +0200 |
parents | Core/Images/ImageProcessing.cpp@f18eaade6153 Core/Images/ImageProcessing.cpp@d6362b2c4b61 |
children | 26efd0404d97 |
comparison
equal
deleted
inserted
replaced
4078:c5c41f66ec29 | 4081:259c33759937 |
---|---|
391 } | 391 } |
392 } | 392 } |
393 | 393 |
394 | 394 |
395 // Computes "a * x + b" at each pixel => Note that this is not the | 395 // Computes "a * x + b" at each pixel => Note that this is not the |
396 // same convention as in "ShiftScale()" | 396 // same convention as in "ShiftScale()", but it is the convention of |
397 // "ShiftScale2()" | |
397 template <typename TargetType, | 398 template <typename TargetType, |
398 typename SourceType, | 399 typename SourceType, |
399 bool UseRound, | 400 bool UseRound, |
400 bool Invert> | 401 bool Invert> |
401 static void ShiftScaleInternal(ImageAccessor& target, | 402 static void ShiftScaleInternal(ImageAccessor& target, |
1373 throw OrthancException(ErrorCode_NotImplemented); | 1374 throw OrthancException(ErrorCode_NotImplemented); |
1374 } | 1375 } |
1375 } | 1376 } |
1376 | 1377 |
1377 | 1378 |
1378 void ImageProcessing::ShiftScale(ImageAccessor& image, | 1379 void ImageProcessing::ShiftScale2(ImageAccessor& image, |
1379 float offset, | 1380 float offset, |
1380 float scaling, | 1381 float scaling, |
1381 bool useRound) | 1382 bool useRound) |
1382 { | 1383 { |
1383 // Rewrite "(x + offset) * scaling" as "a * x + b" | 1384 // We compute "a * x + b" |
1384 | |
1385 const float a = scaling; | 1385 const float a = scaling; |
1386 const float b = offset * scaling; | 1386 const float b = offset; |
1387 | 1387 |
1388 switch (image.GetFormat()) | 1388 switch (image.GetFormat()) |
1389 { | 1389 { |
1390 case PixelFormat_Grayscale8: | 1390 case PixelFormat_Grayscale8: |
1391 if (useRound) | 1391 if (useRound) |
1436 throw OrthancException(ErrorCode_NotImplemented); | 1436 throw OrthancException(ErrorCode_NotImplemented); |
1437 } | 1437 } |
1438 } | 1438 } |
1439 | 1439 |
1440 | 1440 |
1441 void ImageProcessing::ShiftScale(ImageAccessor& target, | 1441 void ImageProcessing::ShiftScale2(ImageAccessor& target, |
1442 const ImageAccessor& source, | 1442 const ImageAccessor& source, |
1443 float offset, | 1443 float offset, |
1444 float scaling, | 1444 float scaling, |
1445 bool useRound) | 1445 bool useRound) |
1446 { | 1446 { |
1447 // Rewrite "(x + offset) * scaling" as "a * x + b" | 1447 // We compute "a * x + b" |
1448 | |
1449 const float a = scaling; | 1448 const float a = scaling; |
1450 const float b = offset * scaling; | 1449 const float b = offset; |
1451 | 1450 |
1452 switch (target.GetFormat()) | 1451 switch (target.GetFormat()) |
1453 { | 1452 { |
1454 case PixelFormat_Grayscale8: | 1453 case PixelFormat_Grayscale8: |
1455 | 1454 |
1474 | 1473 |
1475 default: | 1474 default: |
1476 throw OrthancException(ErrorCode_NotImplemented); | 1475 throw OrthancException(ErrorCode_NotImplemented); |
1477 } | 1476 } |
1478 } | 1477 } |
1478 | |
1479 | |
1480 void ImageProcessing::ShiftScale(ImageAccessor& image, | |
1481 float offset, | |
1482 float scaling, | |
1483 bool useRound) | |
1484 { | |
1485 // Rewrite "(x + offset) * scaling" as "a * x + b" | |
1486 | |
1487 const float a = scaling; | |
1488 const float b = offset * scaling; | |
1489 ShiftScale2(image, b, a, useRound); | |
1490 } | |
1491 | |
1492 | |
1493 void ImageProcessing::ShiftScale(ImageAccessor& target, | |
1494 const ImageAccessor& source, | |
1495 float offset, | |
1496 float scaling, | |
1497 bool useRound) | |
1498 { | |
1499 // Rewrite "(x + offset) * scaling" as "a * x + b" | |
1500 | |
1501 const float a = scaling; | |
1502 const float b = offset * scaling; | |
1503 ShiftScale2(target, source, b, a, useRound); | |
1504 } | |
1505 | |
1479 | 1506 |
1480 | 1507 |
1481 void ImageProcessing::Invert(ImageAccessor& image, int64_t maxValue) | 1508 void ImageProcessing::Invert(ImageAccessor& image, int64_t maxValue) |
1482 { | 1509 { |
1483 const unsigned int width = image.GetWidth(); | 1510 const unsigned int width = image.GetWidth(); |