void EuclideanDisplacementTest::testInterpolate() { debug(LOG_DEBUG, DEBUG_LOG, 0, "testInterpolate() begin"); // read testimages/sun.fits std::string name("testimages/sun.fits"); FITSinfile<RGB<unsigned char> > infile(name); Image<RGB<unsigned char> > *i = infile.read(); ImagePtr image(i); // apply the transformation Point translation(1024 * (1 - sqrt(2)) / 2, 1024 / 2); transform::EuclideanDisplacement d(M_PI / 4, translation); // create an image from the transform transform::InterpolatingEuclideanDisplacementAdapter<RGB<unsigned char> > ta(*i, d); Image<RGB<unsigned char> > *t = new Image<RGB<unsigned char> >(ta); ImagePtr transformed(t); // write the transformed image back to tmp/sun-displace.fits std::string outname("tmp/sun-interpolate.fits"); FITSoutfile<RGB<unsigned char> > *outfile = new FITSoutfile<RGB<unsigned char> >(outname); outfile->setPrecious(false); outfile->write(*t); delete outfile; debug(LOG_DEBUG, DEBUG_LOG, 0, "testInterpolate() end"); }
void EuclideanDisplacementTest::testConvolve() { debug(LOG_DEBUG, DEBUG_LOG, 0, "testConvolve() begin"); // read testimages/sun.fits std::string name("testimages/orion1.fits"); FITSinfile<unsigned short> infile(name); Image<unsigned short> *i = infile.read(); ImagePtr image(i); // create an adapter so that we see double values adapter::TypeConversionAdapter<unsigned short> tconv(*i); // apply the convolution simpleconvolution f; // create an image from the transform transform::EuclideanDisplacementConvolve<double> ta(f, 1000); Image<double> *result = ta(tconv); ImagePtr r(result); // write the transformed image back to tmp/sun-displace.fits std::string outname("tmp/orion-convolve.fits"); FITSoutfile<double> *outfile = new FITSoutfile<double>(outname); outfile->setPrecious(false); outfile->write(*result); delete outfile; debug(LOG_DEBUG, DEBUG_LOG, 0, "testConvolve() end"); }
void MosaicTest::testMosaic(MosaicType::mosaic_type mosaic) { debug(LOG_DEBUG, DEBUG_LOG, 0, "testMosaic() begin"); Image<RGB<unsigned char> > image(44, 62); for (int x = 0; x < image.size().width(); x++) { for (int y = 0; y < image.size().height(); y++) { image.pixel(x, y).R = 'R'; image.pixel(x, y).G = 'G'; image.pixel(x, y).B = 'B'; } } Mosaic<unsigned char> mosaicer(mosaic); Image<unsigned char> *mosaiced = mosaicer(image); std::string filename = stringprintf("tmp/mosaic%d.fits", mosaic); unlink(filename.c_str()); FITSoutfile<unsigned char> *outfile = new FITSoutfile<unsigned char>(filename.c_str()); outfile->write(*mosaiced); delete outfile; for (int x = 0; x < image.size().width(); x++) { for (int y = 0; y < image.size().height(); y++) { if (mosaiced->getMosaicType().isR(x, y)) { CPPUNIT_ASSERT(mosaiced->pixel(x, y) == 'R'); } if (mosaiced->getMosaicType().isG(x, y)) { CPPUNIT_ASSERT(mosaiced->pixel(x, y) == 'G'); } if (mosaiced->getMosaicType().isB(x, y)) { CPPUNIT_ASSERT(mosaiced->pixel(x, y) == 'B'); } } } delete mosaiced; debug(LOG_DEBUG, DEBUG_LOG, 0, "testMosaic() end"); }