Recovery image with DFT

asked 2019-04-22 03:58:56 -0600

vasilev gravatar image

updated 2019-04-22 13:47:10 -0600

berak gravatar image

Hello, I need recovery absence part of image via DFT. Example: http://jre.cplire.ru/jre/jul16/4/text... But, I dont know how get 0 component of specter(simply Mat[]) and how keep N components of spector and image(From N components of spector) insert to original image.

package sample;

import javafx.event.ActionEvent;
import javafx.fxml.FXML;
import javafx.fxml.FXMLLoader;
import javafx.scene.Parent;
import javafx.scene.Scene;
import javafx.scene.control.Button;
import javafx.scene.control.Label;
import javafx.scene.image.Image;
import javafx.scene.image.ImageView;
import javafx.stage.FileChooser;
import javafx.stage.Stage;
import org.opencv.core.*;
import org.opencv.imgcodecs.Imgcodecs;
import org.opencv.imgproc.Imgproc;

import java.io.File;
import java.io.IOException;
import java.util.ArrayList;
import java.util.List;

public class Controller {
    @FXML
    private ImageView originalImage;
    @FXML
    private ImageView transformedImage;
    @FXML
    private ImageView antitransformedImage;
    // a FXML button for performing the transformation
    @FXML
    private Button transformButton;
    // a FXML button for performing the antitransformation
    @FXML
    private Button antitransformButton;

    // the main stage
    private Stage stage;
    // the JavaFX file chooser
    private FileChooser fileChooser;
    // support variables
    private Mat image;
    private List<Mat> planes;
    // the final complex image
    private Mat complexImage;

    private Mat imR;
    private Mat imG;
    private Mat imB;
    private boolean checkChannels;
int i = 1;

    /**
     * Init the needed variables
     */
    protected void init() {
        this.fileChooser = new FileChooser();
        this.image = new Mat();
        this.imR = new Mat();
        this.imG = new Mat();
        this.imB = new Mat();
        this.checkChannels = false;
        this.planes = new ArrayList<>();
        this.complexImage = new Mat();
    }

    /**
     * Load an image from disk
     */
    @FXML
    protected void loadImage() throws InterruptedException {
        // show the open dialog window

        File file = this.fileChooser.showOpenDialog(this.stage);
        if (file != null) {
            // read the image in gray scale
            double r = 0;
            double g = 0;
            double b = 0;
            this.image = Imgcodecs.imread(file.getAbsolutePath());
            Imgproc.rectangle(this.image, new Point((this.image.cols() / 2 - 10), (this.image.rows() / 2 - 2)), new Point((this.image.cols() / 2) + 20, (this.image.rows() / 2 + 2)), new Scalar(0, 0, 0, 0), -1);
            this.checkChannels = image.channels() == 1 ? true : false;
            for (int i = 0; i < 150; i++) {
                for (int j = 0; j < 150; j++) {
                    if (this.image.get(i, j)[0] != 0 && this.image.get(i, j)[1] != 0 && this.image.get(i, j)[2] != 0) {
                        r += this.image.get(i, j)[0];
                        g += this.image.get(i, j)[1];
                        b += this.image.get(i, j)[2];
                    }
                }
            }
            r = r / (150 * 150);
            g = g / (150 * 150);
            b = b / (150 * 150);
            for (int i = 73; i < 78; i++) {
                for (int j = 65; j < 96; j++) {

                    image.put(i, j, r, g, b);

                }
            }
            //  this.image = Imgcodecs.imread(file.getAbsolutePath(), Imgcodecs.IMREAD_GRAYSCALE);
            // show the image
            this.updateImageView(originalImage, Utils.mat2Image(this.image));
            // set a fixed width
            this.originalImage.setFitWidth(250);
            // preserve image ratio
            this.originalImage.setPreserveRatio(true);
            // update the UI
            this.transformButton.setDisable(false);

            // empty the image planes and the image views if it is not the first
            // loaded image
            if (!this.planes.isEmpty()) {
                this.planes.clear();
                this.transformedImage.setImage(null);
                this ...
(more)
edit retag flag offensive close merge delete

Comments

show, what you've tried so far, please.

(and try to find an englishversion of that article, else noone will read it....)

berak gravatar imageberak ( 2019-04-22 05:08:46 -0600 )edit
1

Sorry, but only abstract written in english, in the evening i attach my attempts

vasilev gravatar imagevasilev ( 2019-04-22 05:14:16 -0600 )edit