skyprojection.cc
// Warps the input image to lat-lon projection.
Warps the input image to lat-lon projection.
Warps the input image to lat - lon projection .
void SkyProjection::WarpImage(Image *projected_image) const {
  assert(image_ != NULL);
  assert(image_->width() == original_width_);
  assert(image_->height() == original_height_);
  assert(image_->colorspace() == Image::RGBA);
  assert(projected_width_ > 0);
  assert(projected_height_ > 0);
  projected_image->Resize(projected_width_, projected_height_, Image::RGBA);
  double ra_min;
  double ra_max;
  bounding_box_.GetMonotonicRaBounds(&ra_min, &ra_max);
  double dec_min;
  double dec_max;
  bounding_box_.GetDecBounds(&dec_min, &dec_max);
  double xscale = (ra_max - ra_min) /
                  static_cast<double>(projected_image->width() - 1);
  double yscale = (dec_max - dec_min) /
                  static_cast<double>(projected_image->height() - 1);
  double ra_start = ra_min;
  if (!FLAGS_align_with_base_imagery) {
    xscale = -xscale;
    ra_start = ra_max;
  }
  Color pixel(4);
  for (int i = 0; i < projected_image->width(); ++i) {
    double ra = ra_start + i * xscale;
    for (int j = 0; j < projected_image->height(); ++j) {
      double dec = dec_max - j * yscale;
      double x;
      double y;
      bool inside = wcs_->ToPixel(ra, dec, &x, &y);
      x -= 1.0;
      if (input_image_origin_ == LOWER_LEFT) {
        y = image_->height() - y;
      } else {
        y -= 1.0;
      }
      if (!inside) {
        projected_image->SetPixel(i, j, bg_color_);
      } else {
        int m = Round(x);
        if (m >= image_->width()) m = image_->width() - 1;
        int n = Round(y);
        if (n >= image_->height()) n = image_->height() - 1;
        image_->GetPixel(m, n, &pixel);
        projected_image->SetPixel(i, j, pixel);
      }
    }
  }
}
void SkyProjection :: WarpImage ( Image * projected_image ) const { assert ( image_ != NULL ) ; assert ( image_ -> width ( ) == original_width_ ) ; assert ( image_ -> height ( ) == original_height_ ) ; assert ( image_ -> colorspace ( ) == Image :: RGBA ) ; assert ( projected_width_ > 0 ) ; assert ( projected_height_ > 0 ) ; projected_image -> Resize ( projected_width_ , projected_height_ , Image :: RGBA ) ; double ra_min ; double ra_max ; bounding_box_ . GetMonotonicRaBounds ( & ra_min , & ra_max ) ; double dec_min ; double dec_max ; bounding_box_ . GetDecBounds ( & dec_min , & dec_max ) ; double xscale = ( ra_max - ra_min ) / static_cast < double > ( projected_image -> width ( ) - 1 ) ; double yscale = ( dec_max - dec_min ) / static_cast < double > ( projected_image -> height ( ) - 1 ) ; double ra_start = ra_min ; if ( ! FLAGS_align_with_base_imagery ) { xscale = - xscale ; ra_start = ra_max ; } Color pixel ( 4 ) ; for ( int i = 0 ; i < projected_image -> width ( ) ; ++ i ) { double ra = ra_start + i * xscale ; for ( int j = 0 ; j < projected_image -> height ( ) ; ++ j ) { double dec = dec_max - j * yscale ; double x ; double y ; bool inside = wcs_ -> ToPixel ( ra , dec , & x , & y ) ; x -= 1.0 ; if ( input_image_origin_ == LOWER_LEFT ) { y = image_ -> height ( ) - y ; } else { y -= 1.0 ; } if ( ! inside ) { projected_image -> SetPixel ( i , j , bg_color_ ) ; } else { int m = Round ( x ) ; if ( m >= image_ -> width ( ) ) m = image_ -> width ( ) - 1 ; int n = Round ( y ) ; if ( n >= image_ -> height ( ) ) n = image_ -> height ( ) - 1 ; image_ -> GetPixel ( m , n , & pixel ) ; projected_image -> SetPixel ( i , j , pixel ) ; } } } }
Warps the input image to lat-lon projection.
Warps the input image to lat - lon projection .
// Check for object mutation by the caller. // Sanity check on output dimensions. // Scale factors for converting ra, dec to x, y in projected image. // Alter the loop to run from max ra to min ra for <GroundOverlay> elements. // For each pixel in the new image, compute ra, dec then x, y in the original // image and copy the pixel values. // NB: The loop procedes from (ra_min or ra_max, dec_max) to // (ra_max or ra_min, dec_min), i.e. from the upper left corner to the lower // right corner of the projected image.  Hence, i, j properly indexes the // projected image in lat-lon space. // Coordinates in original FITS image start at (1, 1) in the lower left // corner.  Here we convert them so that point (0, 0) is in the upper // left corner if needed. // Draw a pixel of the background color for points that lie outside of // the original image. // Copy the input pixel and preserve its alpha channel.  We use // point sampling because the Earth client applies its own filtering.