test.cxx | test.cxx | |||
---|---|---|---|---|
skipping to change at line 40 | skipping to change at line 40 | |||
/* WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING */ | /* WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING */ | |||
/* FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR */ | /* FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR */ | |||
/* OTHER DEALINGS IN THE SOFTWARE. */ | /* OTHER DEALINGS IN THE SOFTWARE. */ | |||
/* */ | /* */ | |||
/************************************************************************/ | /************************************************************************/ | |||
#include <iostream> | #include <iostream> | |||
#include <functional> | #include <functional> | |||
#include <cmath> | #include <cmath> | |||
#include <time.h> | #include <time.h> | |||
#include <stdio.h> | ||||
#include "unittest.hxx" | #include "unittest.hxx" | |||
#include "vigra/stdimage.hxx" | #include "vigra/stdimage.hxx" | |||
#include "vigra/stdimagefunctions.hxx" | #include "vigra/stdimagefunctions.hxx" | |||
#include "vigra/splineimageview.hxx" | #include "vigra/splineimageview.hxx" | |||
#include "vigra/basicgeometry.hxx" | #include "vigra/basicgeometry.hxx" | |||
#include "vigra/affinegeometry.hxx" | #include "vigra/affinegeometry.hxx" | |||
#include "vigra/impex.hxx" | #include "vigra/impex.hxx" | |||
#include "vigra/meshgrid.hxx" | #include "vigra/meshgrid.hxx" | |||
using namespace vigra; | using namespace vigra; | |||
skipping to change at line 635 | skipping to change at line 636 | |||
RGBValue(0.0, -1.0, -2.0)) ); | RGBValue(0.0, -1.0, -2.0)) ); | |||
shouldEqual(img2(0,0), RGBValue(2.0, 3.0, 4.0)); | shouldEqual(img2(0,0), RGBValue(2.0, 3.0, 4.0)); | |||
} | } | |||
void scalarIntensityTransformTest() | void scalarIntensityTransformTest() | |||
{ | { | |||
Image img1(3,3); | Image img1(3,3); | |||
transformImage(srcImageRange(img), destImage(img1), | transformImage(srcImageRange(img), destImage(img1), | |||
linearIntensityTransform<Image::v alue_type>(3.3)); | linearIntensityTransform<Image::value_type>(3.3)); | |||
Image::ScanOrderIterator i = img.begin(); | Image::ScanOrderIterator i = img.begin(); | |||
Image::ScanOrderIterator i1 = img1.begin(); | Image::ScanOrderIterator i1 = img1.begin(); | |||
Image::Accessor acc = img.accessor(); | Image::Accessor acc = img.accessor(); | |||
for(; i != img.end(); ++i, ++i1) | for(; i != img.end(); ++i, ++i1) | |||
{ | { | |||
shouldEqual(3.3*acc(i), acc(i1)); | shouldEqual(3.3*acc(i), acc(i1)); | |||
} | } | |||
skipping to change at line 687 | skipping to change at line 688 | |||
shouldEqual(2.0*(acc(i) - 1.1), acc(i1)); | shouldEqual(2.0*(acc(i) - 1.1), acc(i1)); | |||
} | } | |||
} | } | |||
void linearRangeMappingTest() | void linearRangeMappingTest() | |||
{ | { | |||
BImage img1(3,3); | BImage img1(3,3); | |||
transformImage(srcImageRange(img), destImage(img1), | transformImage(srcImageRange(img), destImage(img1), | |||
linearRangeMapping(1.0, 10.0, 0, 250)); | linearRangeMapping(1.0, 10.0, 0, 250)); | |||
int res[] = {3, 33, 64, 94, 125, 156, 186, 217, 247 }; | int res[] = {3, 33, 64, 94, 125, 156, 186, 217, 247 }; | |||
shouldEqualSequence(img1.begin(), img1.end(), res); | shouldEqualSequence(img1.begin(), img1.end(), res); | |||
FindMinMax<double> minmax; | ||||
inspectImage(srcImageRange(img), minmax); | ||||
transformImage(srcImageRange(img), destImage(img1), | ||||
linearRangeMapping(minmax, 0, 250)); | ||||
int res1[] = {0, 31, 62, 94, 125, 156, 187, 219, 250 }; | ||||
#if 0 | ||||
for(int i=0; i<9; ++i) | ||||
std::cerr << (int)*(&img1(0,0)+i) << ", "; | ||||
std::cerr << "\n"; | ||||
#endif | ||||
shouldEqualSequence(img1.begin(), img1.end(), res1); | ||||
BRGBImage img2(3,3); | BRGBImage img2(3,3); | |||
transformImage(srcImageRange(rgb), destImage(img2), | transformImage(srcImageRange(rgb), destImage(img2), | |||
linearRangeMapping(RGBValue(1.0, 1.0, 1.0), | linearRangeMapping(RGBValue(1.0, 1.0, 1.0), | |||
RGBValue(3.0, 3.0, 3.0), | RGBValue(3.0, 3.0, 3.0), | |||
BRGBImage::value_type(0, 0, 0), | BRGBImage::value_type(0, 0, 0), | |||
BRGBImage::value_type(255, 255, 2 55))); | BRGBImage::value_type(255, 255, 2 55))); | |||
shouldEqual(img2(0,0), BRGBImage::value_type(0, 128, 255)); | shouldEqual(img2(0,0), BRGBImage::value_type(0, 128, 255)); | |||
} | } | |||
void thresholdTest() | void thresholdTest() | |||
{ | { | |||
vigra::Threshold<Image::value_type, Image::value_type> trans(2.0, 9 .0, 0.0, 1.0); | vigra::Threshold<Image::value_type, Image::value_type> trans(2.0, 9 .0, 0.0, 1.0); | |||
skipping to change at line 1504 | skipping to change at line 1518 | |||
for(int x = 0; x < 10; ++x) | for(int x = 0; x < 10; ++x) | |||
shouldEqual(img(x,y), res2(h-y-1, x)); | shouldEqual(img(x,y), res2(h-y-1, x)); | |||
try | try | |||
{ | { | |||
rotateImage(srcImageRange(img), destImage(res2), 22); | rotateImage(srcImageRange(img), destImage(res2), 22); | |||
failTest("rotateImage() failed to throw exception"); | failTest("rotateImage() failed to throw exception"); | |||
} | } | |||
catch(vigra::PreconditionViolation) {} | catch(vigra::PreconditionViolation) {} | |||
transposeImage(srcImageRange(img), destImage(res2), major); | transposeImage(srcImageRange(img), destImage(res2), vigra::major); | |||
for(int y = 0; y < 10; ++y) | for(int y = 0; y < 10; ++y) | |||
for(int x = 0; x < 10; ++x) | for(int x = 0; x < 10; ++x) | |||
shouldEqual(img(x,y), res2(y, x)); | shouldEqual(img(x,y), res2(y, x)); | |||
transposeImage(srcImageRange(img), destImage(res2), minor); | transposeImage(srcImageRange(img), destImage(res2), vigra::minor); | |||
for(int y = 0; y < 10; ++y) | for(int y = 0; y < 10; ++y) | |||
for(int x = 0; x < 10; ++x) | for(int x = 0; x < 10; ++x) | |||
shouldEqual(img(x,y), res2(h-y-1, w-x-1)); | shouldEqual(img(x,y), res2(h-y-1, w-x-1)); | |||
reflectImage(srcImageRange(img), destImage(res1), horizontal); | reflectImage(srcImageRange(img), destImage(res1), vigra::horizontal ); | |||
for(int y = 0; y < 10; ++y) | for(int y = 0; y < 10; ++y) | |||
for(int x = 0; x < 10; ++x) | for(int x = 0; x < 10; ++x) | |||
shouldEqual(img(x,y), res1(x, h-y-1)); | shouldEqual(img(x,y), res1(x, h-y-1)); | |||
reflectImage(srcImageRange(img), destImage(res1), vertical); | reflectImage(srcImageRange(img), destImage(res1), vigra::vertical); | |||
for(int y = 0; y < 10; ++y) | for(int y = 0; y < 10; ++y) | |||
for(int x = 0; x < 10; ++x) | for(int x = 0; x < 10; ++x) | |||
shouldEqual(img(x,y), res1(w-x-1, y)); | shouldEqual(img(x,y), res1(w-x-1, y)); | |||
reflectImage(srcImageRange(img), destImage(res1), vigra::horizontal | ||||
| vigra::vertical); | ||||
for(int y = 0; y < 10; ++y) | ||||
for(int x = 0; x < 10; ++x) | ||||
shouldEqual(img(x,y), res1(w-x-1, h-y-1)); | ||||
double xfactor = 3.0; | double xfactor = 3.0; | |||
double yfactor = 2.0; | double yfactor = 2.0; | |||
Image res3((int)(w*xfactor), (int)(h*yfactor)); | Image res3((int)(w*xfactor), (int)(h*yfactor)); | |||
resampleImage(srcImageRange(img), destImage(res3), xfactor, yfactor ); | resampleImage(srcImageRange(img), destImage(res3), xfactor, yfactor ); | |||
for(int y = 0; y < 10; ++y) | for(int y = 0; y < 10; ++y) | |||
for(int x = 0; x < 10; ++x) | for(int x = 0; x < 10; ++x) | |||
shouldEqual(img(x,y), res3(int(x*xfactor), int(y*yfactor))) ; | shouldEqual(img(x,y), res3(int(x*xfactor), int(y*yfactor))) ; | |||
} | } | |||
End of changes. 10 change blocks. | ||||
7 lines changed or deleted | 26 lines changed or added | |||
This html diff was produced by rfcdiff 1.41. The latest version is available from http://tools.ietf.org/tools/rfcdiff/ |