Skip to content

Commit 0c64e32

Browse files
author
ersts
committed
-Updated Contrast Enhancement test
git-svn-id: http://svn.osgeo.org/qgis/trunk/qgis@9238 c8812cc2-4d05-0410-92ff-de0c093fc19c
1 parent 89d03eb commit 0c64e32

File tree

1 file changed

+30
-6
lines changed

1 file changed

+30
-6
lines changed

tests/src/core/testcontrastenhancements.cpp

+30-6
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@
2323
#include <qgscliptominmaxenhancement.h>
2424
#include <qgscontrastenhancement.h>
2525
#include <qgslinearminmaxenhancement.h>
26+
#include <qgslinearminmaxenhancementwithclip.h>
2627

2728
/** \ingroup UnitTests
2829
* This is a unit test for the ContrastEnhancements contrast enhancement classes.
@@ -36,7 +37,8 @@ class TestContrastEnhancements: public QObject
3637
void init() {};// will be called before each testfunction is executed.
3738
void cleanup() {};// will be called after every testfunction.
3839

39-
void minMaxEnhancementTest();
40+
void clipMinMaxEnhancementTest();
41+
void linearMinMaxEnhancementWithClipTest();
4042
void linearMinMaxEnhancementTest();
4143
private:
4244
QString mReport;
@@ -63,20 +65,42 @@ void TestContrastEnhancements::cleanupTestCase()
6365
}
6466

6567

66-
void TestContrastEnhancements::minMaxEnhancementTest()
68+
void TestContrastEnhancements::clipMinMaxEnhancementTest()
6769
{
70+
//Clips 0 < x < 10, 240 < X < 256
71+
//Stretch no stretch is applied
6872
QgsClipToMinMaxEnhancement myEnhancement(QgsContrastEnhancement::QGS_Byte, 10.0, 240.0);
73+
// Original pixel value 0.0 Should be out of range thus clipped
6974
QVERIFY(!myEnhancement.isValueInDisplayableRange(0.0));
70-
QVERIFY(10.0 == myEnhancement.enhanceValue(0.0)) ;
71-
QVERIFY(250.0 == myEnhancement.enhanceValue(240.0)) ;
75+
//Original pixel value of 10.0 should be scaled to 10.0
76+
QVERIFY(10.0 == myEnhancement.enhanceValue(10.0)) ;
77+
//Original pixel value of 240 should be scaled to 240
78+
QVERIFY(240.0 == myEnhancement.enhanceValue(240.0)) ;
7279
}
80+
81+
void TestContrastEnhancements::linearMinMaxEnhancementWithClipTest()
82+
{
83+
//First clips 0 < x < 10, 240 < X < 256
84+
//Then stretch 10 = 0, 240 = 255 linearly distribute values 10 -> 240 between 0 -> 255
85+
QgsLinearMinMaxEnhancementWithClip myEnhancement(QgsContrastEnhancement::QGS_Byte, 10.0, 240.0);
86+
// Original pixel value 0.0 Should be out of range thus clipped
87+
QVERIFY(!myEnhancement.isValueInDisplayableRange(0.0));
88+
//Original pixel value of 10.0 should be scaled to 0.0
89+
QVERIFY(0.0 == myEnhancement.enhanceValue(10.0)) ;
90+
//Original pixel value of 240 should be scaled to 255
91+
QVERIFY(255.0 == myEnhancement.enhanceValue(240.0)) ;
92+
}
93+
7394
void TestContrastEnhancements::linearMinMaxEnhancementTest()
7495
{
96+
//Stretch 10 = 0, 240 = 255 linearly distribute values 10 -> 240 between 0 -> 255
7597
QgsLinearMinMaxEnhancement myEnhancement(QgsContrastEnhancement::QGS_Byte, 10.0, 240.0);
7698
//0 should be scaled to 10 and not clipped
7799
QVERIFY(myEnhancement.isValueInDisplayableRange(0.0));
78-
QVERIFY(10.0 == myEnhancement.enhanceValue(0.0)) ;
79-
QVERIFY(250.0 == myEnhancement.enhanceValue(240.0)) ;
100+
//Original pixel value of 10.0 should be scaled to 0.0
101+
QVERIFY(0.0 == myEnhancement.enhanceValue(10.0)) ;
102+
//Original pixel value of 240 should be scaled to 255
103+
QVERIFY(255.0 == myEnhancement.enhanceValue(240.0)) ;
80104
}
81105
QTEST_MAIN( TestContrastEnhancements )
82106
#include "moc_testcontrastenhancements.cxx"

0 commit comments

Comments
 (0)