Returns an array with the X, Y co-ords of the focal point of the current crop.

The measurement is relative to the original source image.
174828
public function getFocalPoint()
	{
		$scale =  $this->sourceWidth / $this->scaleWidth;

		$focalX = ( ( $this->frameWidth / 2 ) - $this->offsetX ) * $scale;
		$focalY = ( ( $this->frameHeight / 2 ) - $this->offsetY ) * $scale;

		return array( $focalX, $focalY );
	}
1109089
public function cropToFit($width, $height, $focusPointX = 0, $focusPointY = 0)
    {

        $debug = $width == 100 && $height == 100;

        // Check if the image is a valid resource
        if (!is_resource($this->image)) {
            throw new RuntimeException('No image set');
        }

        // Get the width and height of element
        $originalWidth = imagesx( $this->image );
        $originalHeight = imagesy( $this->image );

        // Check if any of the width and height is null, and set it to the $source size
        $width = $width ?: $originalWidth;
        $height = $height ?: $originalHeight;

        // Calculate the aspect ratio of the existing image
        $originalAspectRatio = $originalWidth / $originalHeight;

        // Calculate the aspect ratio of the desired image
        $desiredAspectRatio = $width / $height;

        // Check what value we should use with the aspect ratio
        if ( $originalAspectRatio > $desiredAspectRatio ) {
            $temp_height = $height;
            $temp_width = ( int ) ($height * $originalAspectRatio);
        }
        else {
            $temp_width = $width;
            $temp_height = ( int ) ($width / $originalAspectRatio);
        }

        // Get the center of image based on the focusPoint
        $x0 = ( $temp_width - $width ) * ( ( $focusPointX + 1 ) * .5 );
        $y0 = ( $temp_height - $height ) * ( ( $focusPointY + 1 ) * .5 );

        // If $x0 or $y0 is not a full number increase with one pixel
        // to fill black line and fill canvas
        if ( ! ctype_digit( $x0 ) || ! ctype_digit( $y0 ) ) {
            $temp_width++;
            $temp_height++;
        }

        // Resize the image into the desired image
        $this->resize( $temp_width, $temp_height );

        // Create canvas for the new image
        $canvas = $this->createCanvas( $width, $height );
        // Do the cropping of image
        imagecopy( $canvas, $this->image, 0, 0, $x0, $y0, $width, $height );

        // Replace the image
        $this->replace( $canvas );

        // Return $this for chaining
        return $this;
    }
683541
def _create_and_rotate_coordinate_arrays(self, x, y, p):
        

        if p.aspect_ratio == 0 or p.size == 0:
            x = x * 0.0
            y = y * 0.0
        else:
            x = (x*10.0) / (p.size*p.aspect_ratio)
            y = (y*10.0) / p.size

        offset = np.exp(p.size)
        pattern_x = np.add.outer(np.sin(p.orientation)*y, np.cos(p.orientation)*x) + offset
        pattern_y = np.subtract.outer(np.cos(p.orientation)*y, np.sin(p.orientation)*x) + offset

        np.clip(pattern_x, 0, np.Infinity, out=pattern_x)
        np.clip(pattern_y, 0, np.Infinity, out=pattern_y)

        return pattern_x, pattern_y
669747
private String getCrop() {

        CmsImagePreviewHandler handler = getImagePreviewHandler();
        if (handler != null) {
            CmsCroppingParamBean crop = handler.getCroppingParam();
            if ((crop != null) && crop.isCropped()) {
                return "" + crop.getCropWidth() + " x " + crop.getCropHeight();
            } else {
                return null;
            }
        } else {
            return null;
        }
    }
906443
private int getSourcePixel(int[] srcImage, int x, int y)
    {
        int x1 = Math.max(0, x);
        x1 = Math.min(width - 1, x1);
        int y1 = Math.max(0, y);
        y1 = Math.min(height - 1, y1);

        return srcImage[x1 + y1 * width];
    }
1072158
def crop_to_extents(img1, img2, padding):
    """"""

    beg_coords1, end_coords1 = crop_coords(img1, padding)
    beg_coords2, end_coords2 = crop_coords(img2, padding)

    beg_coords = np.fmin(beg_coords1, beg_coords2)
    end_coords = np.fmax(end_coords1, end_coords2)

    img1 = crop_3dimage(img1, beg_coords, end_coords)
    img2 = crop_3dimage(img2, beg_coords, end_coords)

    return img1, img2
517792
def gnomonicImageToSphere(x, y):
    
    # Convert angle to [-180, 180] interval
    x = x - 360.*(x>180)
    x = np.asarray(x)
    y = np.asarray(y)
    lon = np.degrees(np.arctan2(y, x))
    r_theta = np.sqrt(x**2 + y**2)
    lat = np.degrees(np.arctan(180. / (np.pi * r_theta)))
    return lon, lat
362385
private CmsPoint getCropCenter() {

        CmsCroppingParamBean crop = m_croppingProvider.get();
        CmsImageInfoBean info = m_imageInfoProvider.get();
        if ((crop == null) || !crop.isCropped()) {
            return new CmsPoint(info.getWidth() / 2, info.getHeight() / 2);
        } else {
            return new CmsPoint(
                crop.getCropX() + (crop.getCropWidth() / 2),
                crop.getCropY() + (crop.getCropHeight() / 2));
        }
    }
1160836
def focus0(self):
        '''
        

        '''
        f = Point(self.center)

        if self.xAxisIsMajor:
            f.x -= self.linearEccentricity
        else:
            f.y -= self.linearEccentricity
        return f
639171
def Crop(self, x1, x2, copy=False):
        
        numPoints = self.GetN()
        if copy:
            cropGraph = self.Clone()
            copyGraph = self
        else:
            cropGraph = self
            copyGraph = self.Clone()
        cropGraph.Set(0)
        X = copyGraph.GetX()
        EXlow = copyGraph.GetEXlow()
        EXhigh = copyGraph.GetEXhigh()
        Y = copyGraph.GetY()
        EYlow = copyGraph.GetEYlow()
        EYhigh = copyGraph.GetEYhigh()
        xmin = copyGraph.GetXmin()
        if x1 < xmin-EXlow[0]:
            cropGraph.Set(numPoints + 1)
        xmax = copyGraph.GetXmax()
        if x2 > xmax+EXhigh[numPoints-1]:
            cropGraph.Set(numPoints + 1)
        index = 0
        for i in range(numPoints):
            if i == 0 and x1 < xmin:
                cropGraph.SetPoint(0, x1, copyGraph.Eval(x1))
                index += 1
            elif i == numPoints-1 and x2 > xmax+EXhigh[i]:
                cropGraph.SetPoint(i, x2, copyGraph.Eval(x2))
            if x1<=X[i]-EXlow[i] and X[i]+EXhigh[i]<=x2:
                cropGraph.SetPoint(index, X[i], Y[i])
                cropGraph.SetPointError(
                    index,
                    EXlow[i], EXhigh[i],
                    EYlow[i], EYhigh[i])
                index += 1
        return cropGraph
1209516
def get_pixel(x,y)
      index = (y*@width + x)
      pointindex = index*3
      Color.from_rgba(
        @array[pointindex+2].ord,
        @array[pointindex+1].ord,
        @array[pointindex].ord,
        @alpha ? @alpha[index].ord : 255
        )

    end
970409
def _central_crop(image, crop_height, crop_width):
  
  shape = tf.shape(image)
  height, width = shape[0], shape[1]

  mlperf_log.resnet_print(key=mlperf_log.INPUT_CENTRAL_CROP,
                          value=[crop_height, crop_width])

  amount_to_be_cropped_h = (height - crop_height)
  crop_top = amount_to_be_cropped_h // 2
  amount_to_be_cropped_w = (width - crop_width)
  crop_left = amount_to_be_cropped_w // 2
  return tf.slice(
      image, [crop_top, crop_left, 0], [crop_height, crop_width, -1])
88104
def crop_with_focuspoint(width = nil, height = nil)
      if self.respond_to? "resize_to_limit"
        begin
          x = model.focus_x || 0
          y = -(model.focus_y || 0)

          manipulate! do |img|
            orig_w = img['width']
            orig_h = img['height']

            ratio = width.to_f / height
            orig_ratio = orig_w.to_f / orig_h

            x_offset = 0
            y_offset = 0
            w = orig_w
            h = orig_h
            if ratio < orig_ratio
              w = orig_h * ratio

              half_w = w / 2.0
              half_orig_w = orig_w / 2.0

              x_offset = x * half_orig_w

              x_offset = (x <=> 0.0) * (half_orig_w - half_w) if x != 0 && x_offset.abs > half_orig_w - half_w
            elsif ratio > orig_ratio
              h = orig_w / ratio

              half_h = h / 2.0
              half_orig_h = orig_h / 2.0

              y_offset = y * half_orig_h

              y_offset = (y <=> 0.0) * (half_orig_h - half_h) if y != 0 && y_offset.abs > half_orig_h - half_h
            end

            img.combine_options do |op|
              op.crop "#{w.to_i}x#{h.to_i}#{'%+d' % x_offset.round}#{'%+d' % y_offset.round}"
              op.gravity 'Center'
            end
            img.resize("#{width}x#{height}")
            img
          end

        rescue Exception => e
          raise "Failed to crop - #{e.message}"
        end

      else
        raise "Failed to crop #{attachment}. Add mini_magick."
      end
    end
848936
def getdict(self, crop=True):
        

        global mp_D_Y0
        D = mp_D_Y0
        if crop:
            D = cr.bcrop(D, self.dstep.cri.dsz, self.dstep.cri.dimN)
        return D
276572
def center_crop(im, min_sz=None):
    
    r,c,*_ = im.shape
    if min_sz is None: min_sz = min(r,c)
    start_r = math.ceil((r-min_sz)/2)
    start_c = math.ceil((c-min_sz)/2)
    return crop(im, start_r, start_c, min_sz)
1027489
def point_source_list(self, kwargs_ps, kwargs_lens, k=None):
        
        ra_list, dec_list = self.image_position(kwargs_ps, kwargs_lens, k=k)
        amp_list = self.image_amplitude(kwargs_ps, kwargs_lens)
        ra_array, dec_array, amp_array = [], [], []
        for i, ra in enumerate(ra_list):
            for j in range(len(ra)):
                ra_array.append(ra_list[i][j])
                dec_array.append(dec_list[i][j])
                amp_array.append(amp_list[i][j])
        return ra_array, dec_array, amp_array
425819
def getdict(self, crop=True):
        

        D = self.Y
        if crop:
            D = cr.bcrop(D, self.cri.dsz, self.cri.dimN)
        return D