void	ImageSizeTest::testPixels() {
	debug(LOG_DEBUG, DEBUG_LOG, 0, "testPixels() begin");
	CPPUNIT_ASSERT(i1->getPixels() == 77);
	CPPUNIT_ASSERT(i2->getPixels() == 15);
	debug(LOG_DEBUG, DEBUG_LOG, 0, "testPixels() end");
}
예제 #2
0
/**
 * \brief Create a new Viewer
 *
 * This constructor converts the image to an RGB<float> image, and
 * then sets up the image processing pipeline on this image.
 * For the pipeline, some objects have to computed, like the white
 * balance, the background gradients.
 */
Viewer::Viewer(const std::string& filename) {
    debug(LOG_DEBUG, DEBUG_LOG, 0, "create viewer for file %s",
          filename.c_str());
    // read the FITS image
    FITSin	in(filename);
    ImagePtr	rawimage = in.read();

    // image size
    ImageSize	size = rawimage->size();
    _displaysize = size;

    // allocate an image with float pixels
    Image<RGB<float> >	*imagep = new Image<RGB<float> >(size);
    image = ImagePtr(imagep);

    // create an array
    uint32_t	*p = new uint32_t[size.getPixels()];
    _imagedata = imagedataptr(p);

    // copy the data from the image to the imagep
    convert_mono<unsigned char>(*imagep, rawimage);
    convert_mono<unsigned short>(*imagep, rawimage);
    convert_mono<unsigned int>(*imagep, rawimage);
    convert_mono<unsigned long>(*imagep, rawimage);
    convert_mono<float>(*imagep, rawimage);
    convert_mono<double>(*imagep, rawimage);

    // copy the data from the image to the luminanceimagep, *imagep
    convert_rgb<unsigned char>(*imagep, rawimage);
    convert_rgb<unsigned short>(*imagep, rawimage);
    convert_rgb<unsigned int>(*imagep, rawimage);
    convert_rgb<unsigned long>(*imagep, rawimage);
    convert_rgb<float>(*imagep, rawimage);
    convert_rgb<double>(*imagep, rawimage);

    // create the viewer pipeline
    pipeline = new ViewerPipeline(imagep);
    pipelineptr = std::shared_ptr<ViewerPipeline>(pipeline);

    // compute the white balance vector
    filter::WhiteBalance<float>	wb;
    RGB<double>	rgb = wb.filter(*imagep);
    ImagePoint	center = rawimage->center();

    // background stuff
    BackgroundExtractor	be(100);
    Background<float>	bg = be(center, false,
                                BackgroundExtractor::LINEAR, *imagep);
    background(bg);
    backgroundEnabled(true);
    gradientEnabled(true);

    // set parameters
    pipeline->colorcorrection(RGB<float>(rgb.R, rgb.G, rgb.B));
    pipeline->setRange(0, 10000);

    // Histogram
    debug(LOG_DEBUG, DEBUG_LOG, 0, "computing histogram");
    _histograms = HistogramSet(image, 350);

    // set up the preview size
    previewwidth(300);

    // set up the background preview
    debug(LOG_DEBUG, DEBUG_LOG, 0, "computing background size");
    unsigned int	width = 100;
    unsigned int	height = (size.height() * width) / size.width();
    debug(LOG_DEBUG, DEBUG_LOG, 0, "background %u x %u", width, height);
    backgroundsize(ImageSize(width, height));

    // copy the data to the
    update();
    previewupdate();
}