Ask Your Question

IBalic's profile - activity

2018-11-16 17:10:40 -0600 received badge  Popular Question (source)
2014-04-01 08:57:01 -0600 asked a question Opencv-Java append image to existing image

I am trying to add an image below an original image. Then the new image will overwrite the old one. This method is run multiple times.

public void appendImage(Mat matToAppend){
        Mat orgMat = Highgui.imread("test.tiff");
        Mat newMat = new Mat();
        if(orgMat.total()==0){ // if no image exists
            orgMat = matToAppend;
            Highgui.imwrite("test.tiff", orgMat);
        }
        else{
            int width = 0;
            if(matToAppend.width() > orgMat.width()) // selects the biggest width
                width = matToAppend.width();
            else
                width = orgMat.width();
            int height = orgMat.height()+matToAppend.height(); // total height is the two images added together
            newMat = new Mat(new Size(width, height), orgMat.type(), new Scalar(255, 255, 255));

            Mat orgTarget = newMat.submat(new Rect(new Point(0, 0), new Point(orgMat.width(), orgMat.height())));
            orgMat.copyTo(orgTarget); //copy old image to upper area

            Mat newTarget = newMat.submat(new Rect(new Point(0, orgMat.height()), new Point(matToAppend.width(), newMat.height())));
            matToAppend.copyTo(newTarget); // copy new image to bottom area
            Highgui.imwrite("test.tiff", newMat);
        }
    }

What happening is that only the first image is placed at the top whereas the images appended afterwards are not seen. Running this method 4 times will result in a final image with the height of all images, but only the first image is placed at top, and the rest of the final image is white.

Why aren't the other images showing?

2014-03-11 09:01:20 -0600 received badge  Scholar (source)
2014-03-11 09:01:16 -0600 commented answer Isolate digits/characters, get bounding boxes

Thanks! I imlemented find contours now, and it worked right away :)

2014-03-11 08:23:03 -0600 received badge  Editor (source)
2014-03-11 08:22:32 -0600 asked a question Isolate digits/characters, get bounding boxes

I am trying to do OCR on some digits. I am able to build up a list with image moments for each character and achieve pretty decent results. However, I am currently isolating each digits almost manually right know, because I am not able to get a bounding box around each digit.

I am using the Java API for openCV, and I was hoping someone could point me in the right direction of how I could isolate the digits, and calculate image moments for each digits.