def get_scaled_cutout_wdht(self, x1, y1, x2, y2, new_wd, new_ht, method='basic'): """Extract a region of the image defined by corners (x1, y1) and (x2, y2) and resample it to fit dimensions (new_wd, new_ht). `method` describes the method of interpolation used, where the default "basic" is nearest neighbor. """ if method in ('basic', 'view'): shp = self.shape (view, (scale_x, scale_y)) = \ trcalc.get_scaled_cutout_wdht_view(shp, x1, y1, x2, y2, new_wd, new_ht) newdata = self._slice(view) else: data_np = self._get_data() (newdata, (scale_x, scale_y)) = \ trcalc.get_scaled_cutout_wdht(data_np, x1, y1, x2, y2, new_wd, new_ht, interpolation=method, logger=self.logger) res = Bunch.Bunch(data=newdata, scale_x=scale_x, scale_y=scale_y) return res
def get_scaled_cutout_wdht(self, x1, y1, x2, y2, new_wd, new_ht, method="bicubic"): newdata, (scale_x, scale_y) = trcalc.get_scaled_cutout_wdht( self._get_data(), x1, y1, x2, y2, new_wd, new_ht, interpolation=method ) res = Bunch.Bunch(data=newdata, scale_x=scale_x, scale_y=scale_y) return res
def get_scaled_cutout_wdht(self, x1, y1, x2, y2, new_wd, new_ht, method='basic'): newdata, (scale_x, scale_y) = trcalc.get_scaled_cutout_wdht( self._get_data(), x1, y1, x2, y2, new_wd, new_ht, interpolation=method, logger=self.logger) res = Bunch.Bunch(data=newdata, scale_x=scale_x, scale_y=scale_y) return res
def get_scaled_cutout_wdht(self, x1, y1, x2, y2, new_wd, new_ht): data = self.get_data() (newdata, (scale_x, scale_y)) = trcalc.get_scaled_cutout_wdht(data, x1, y1, x2, y2, new_wd, new_ht) res = Bunch.Bunch(data=newdata, scale_x=scale_x, scale_y=scale_y) return res
def get_scaled_cutout_by_dims(self, x1, y1, x2, y2, dst_wd, dst_ht, method='basic'): if method == 'basic': return self.get_scaled_cutout_wdht(x1, y1, x2, y2, dst_wd, dst_ht) data = self._get_data() newdata, (scale_x, scale_y) = trcalc.get_scaled_cutout_wdht( data, x1, y1, x2, y2, dst_wd, dst_ht, interpolation=method) res = Bunch.Bunch(data=newdata, scale_x=scale_x, scale_y=scale_y) return res