예제 #1
0
    def recompute_selected_version(input_image, layers):
        """
        Do the actual computation. Starting from the original image, for each sharpening layer
        apply a Gaussian filter using the layer's parameters. Store the result in the central
        data object for the selected version.

        :return: -
        """

        # Initialize the new image with the original image.
        new_image = input_image

        # Apply all sharpening layers. If the amount is positive, sharpen the image. A negative
        # amount between -1 and 0 means that the image is to be softened with a Gaussian kernel.
        # In this case If the sign of the amount is reversed and taken as the weight with which the
        # softened image is mixed with the original one.
        for layer in layers:
            if layer.amount > 0.:
                new_image = Miscellaneous.gaussian_sharpen(
                    new_image,
                    layer.amount,
                    layer.radius,
                    luminance_only=layer.luminance_only)
            elif -1. <= layer.amount < 0.:
                new_image = Miscellaneous.gaussian_blur(
                    new_image,
                    -layer.amount,
                    layer.radius,
                    luminance_only=layer.luminance_only)

        # Store the result in the central data object.
        return new_image
예제 #2
0
    def execute_postprocess_image(self):

        if self.configuration.global_parameters_protocol_level > 0:
            Miscellaneous.protocol("+++ Start postprocessing +++",
                                   self.attached_log_file)
        self.my_timer.create_no_check('Conputing image postprocessing')

        # Initialize the new image with the original image.
        self.postprocessed_image = self.postproc_input_image

        # Apply all sharpening layers of the postprocessing version selected last time.
        version_index = self.configuration.postproc_data_object.version_selected
        postproc_layers = self.configuration.postproc_data_object.versions[
            version_index].layers
        for layer in postproc_layers:
            self.postprocessed_image = Miscellaneous.gaussian_sharpen(
                self.postprocessed_image,
                layer.amount,
                layer.radius,
                luminance_only=layer.luminance_only)
        self.my_timer.stop('Conputing image postprocessing')

        self.work_next_task_signal.emit("Save postprocessed image")