def save(self, path, extension): if self._cb_data is not None and self._cr_data is not None: self._cb_data = sr_image_util.resize(self._cb_data, self._size) self._cr_data = sr_image_util.resize(self._cr_data, self._size) image = sr_image_util.compose(self._y_data, self._cb_data, self._cr_data) image.save(path, extension)
def _downgrade(self, ratio, kernel): """Downgrade the original SR image with the given ratio and blur kernel. @param ratio: downgrade ratio @type ratio: float @param kernel: blur kernel @type kernel: L{numpy.array} @return: downgraded image with same size as original image @rtype: L{sr_image.SRImage} """ size = sr_image_util.create_size(self.size, 1.0 / ratio) blurred_image = sr_image_util.filter(self._y_data, kernel) downgraded_image = sr_image_util.resize(blurred_image, size) downgraded_image = sr_image_util.resize(downgraded_image, self._size) return SRImage(downgraded_image, self._cb_data, self._cr_data)
def _downgrade(self, ratio, kernel): """Downgrade the original SR image with the given ratio and blur kernel. @param ratio: downgrade ratio @type ratio: float @param kernel: blur kernel @type kernel: L{numpy.array} @return: downgraded image with same size as original image @rtype: L{sr_image.SRImage} """ size = sr_image_util.create_size(self.size, 1.0/ratio) blurred_image = sr_image_util.filter(self._y_data, kernel) downgraded_image = sr_image_util.resize(blurred_image, size) downgraded_image = sr_image_util.resize(downgraded_image, self._size) return SRImage(downgraded_image, self._cb_data, self._cr_data)
def downgrade(self, size, kernel): """Downgraded the image to given size and blurred with given kernel. @param size: target downgrade size @param kernel: blur kernel @return: downgraded image @rtype: L{SRImage} """ blurred_image = sr_image_util.filter(self._y_data, kernel) downgraded_image = sr_image_util.resize(blurred_image, size) return SRImage(downgraded_image, self._cb_data, self._cr_data)
def upgrade(self, size, kernel): """Upgrade the image to the given size and blurred with given kernel. @param size: target upgrade size @param kernel: blur kernel @return: upgraded image @rtype: L{SRImage} """ upgraded_image = sr_image_util.resize(self._y_data, size) blurred_image = sr_image_util.filter(upgraded_image, kernel) return SRImage(blurred_image, self._cb_data, self._cr_data)
def resize(self, ratio): """Return a resized copy of the original SRImage by the given resize ratio. @param ratio: resize ratio @type ratio: float @return: a resized copy of the original SRImage @rtype: L{sr_image.SRImage} """ size = sr_image_util.create_size(self.size, ratio) resized_image = sr_image_util.resize(self._y_data, size) return SRImage(resized_image, self._cb_data, self._cr_data)
def downgrade(self, size, kernel): """Downgraded the image to given size and blurred with given kernel. @param size: target downgrade size @param kernel: blur kernel @return: downgraded image @rtype: L{SRImage} """ blurred_image = sr_image_util.filter(self._y_data, kernel) downgraded_image = sr_image_util.resize(blurred_image, size) return SRImage(downgraded_image, self._cb_data, self._cr_data)
def upgrade(self, size, kernel): """Upgrade the image to the given size and blurred with given kernel. @param size: target upgrade size @param kernel: blur kernel @return: upgraded image @rtype: L{SRImage} """ upgraded_image = sr_image_util.resize(self._y_data, size) blurred_image = sr_image_util.filter(upgraded_image, kernel) return SRImage(blurred_image, self._cb_data, self._cr_data)
def resize(self, ratio): """Return a resized copy of the original SRImage by the given resize ratio. @param ratio: resize ratio @type ratio: float @return: a resized copy of the original SRImage @rtype: L{sr_image.SRImage} """ size = sr_image_util.create_size(self.size, ratio) resized_image = sr_image_util.resize(self._y_data, size) return SRImage(resized_image, self._cb_data, self._cr_data)
def save(self, path, extension): if self._cb_data is not None and self._cr_data is not None: self._cb_data = sr_image_util.resize(self._cb_data, self._size) self._cr_data = sr_image_util.resize(self._cr_data, self._size) image = sr_image_util.compose(self._y_data, self._cb_data, self._cr_data) image.save(path, extension)