Ask Your Question

Revision history [back]

click to hide/show revision 1
initial version

AlignMTB process is blanking a picture

Having loaded a set of images into the (List<mat>) images and calling the following code, the image that corresponds to images.size() / 2 in the aligned list is always blank.

AlignMTB align = Photo.createAlignMTB(6, 4, false);
align.process(images, aligned);

I rewrote AlignMTB in java based on the operations performed in C++ code and calling "calculateShift" and "shiftMat" this appears to work as intended.

public void process(List<Mat> src, List<Mat> dest) {
        int pivot = src.size() / 2;
        Mat gray_base = new Mat();
        Imgproc.cvtColor(src.get(pivot), gray_base, Imgproc.COLOR_RGB2GRAY);
        //AlignMTB align = Photo.createAlignMTB(6, 4, true);
        AlignMTB align = Photo.createAlignMTB(2, 2, false);

        ArrayList<Point> shifts = new ArrayList<>();

        for(int i=0; i<src.size(); i++) {
            if(i == pivot) {
                shifts.add(new Point(0,0));
                dest.set(i, src.get(i));
                continue;
            }
            Mat gray = new Mat();
            Imgproc.cvtColor(src.get(i), gray, Imgproc.COLOR_RGB2GRAY);
            Point shift = align.calculateShift(gray_base, gray);
            System.out.println(shift);
            shifts.add(shift);
            align.shiftMat(src.get(i), dest.get(i), shift);
        }
    }

AlignMTB process is blanking a picture

Having loaded a set of images into the (List<mat>) images and calling the following code, the image that corresponds to images.size() / 2 in the aligned list is always blank.

AlignMTB align = Photo.createAlignMTB(6, 4, Photo.createAlignMTB(2, 2, false);
align.process(images, aligned);

I rewrote AlignMTB in java based on the operations performed in C++ code and calling "calculateShift" and "shiftMat" this appears to work as intended.

public void process(List<Mat> src, List<Mat> dest) {
        int pivot = src.size() / 2;
        Mat gray_base = new Mat();
        Imgproc.cvtColor(src.get(pivot), gray_base, Imgproc.COLOR_RGB2GRAY);
        //AlignMTB align = Photo.createAlignMTB(6, 4, true);
        AlignMTB align = Photo.createAlignMTB(2, 2, false);

        ArrayList<Point> shifts = new ArrayList<>();

        for(int i=0; i<src.size(); i++) {
            if(i == pivot) {
                shifts.add(new Point(0,0));
                dest.set(i, src.get(i));
                continue;
            }
            Mat gray = new Mat();
            Imgproc.cvtColor(src.get(i), gray, Imgproc.COLOR_RGB2GRAY);
            Point shift = align.calculateShift(gray_base, gray);
            System.out.println(shift);
            shifts.add(shift);
            align.shiftMat(src.get(i), dest.get(i), shift);
        }
    }

AlignMTB process is blanking a picture

Having loaded a set of images into the (List<mat>) images and calling the following code, the image that corresponds to images.size() / 2 in the aligned list is always blank.

AlignMTB align = Photo.createAlignMTB(2, 2, false);
align.process(images, aligned);

I rewrote AlignMTB in java based on the operations performed in C++ code and calling "calculateShift" and "shiftMat" this appears to work as intended.

public void process(List<Mat> src, List<Mat> dest) {
        int pivot = src.size() / 2;
        Mat gray_base = new Mat();
        Imgproc.cvtColor(src.get(pivot), gray_base, Imgproc.COLOR_RGB2GRAY);
        //AlignMTB align = Photo.createAlignMTB(6, 4, true);
        AlignMTB align = Photo.createAlignMTB(2, 2, false);

        ArrayList<Point> shifts = new ArrayList<>();

        for(int i=0; i<src.size(); i++) {
            if(i == pivot) {
                shifts.add(new Point(0,0));
                dest.set(i, src.get(i));
                continue;
            }
            Mat gray = new Mat();
            Imgproc.cvtColor(src.get(i), gray, Imgproc.COLOR_RGB2GRAY);
            Point shift = align.calculateShift(gray_base, gray);
            System.out.println(shift);
            shifts.add(shift);
            align.shiftMat(src.get(i), dest.get(i), shift);
        }
    }