Ask Your Question

VishalNair's profile - activity

2017-03-27 11:33:00 -0600 commented answer Sauvola Thresholding for Android

Awesome answer !

2017-03-02 11:43:39 -0600 received badge  Editor (source)
2017-03-02 11:30:09 -0600 asked a question How To Parse a Binary Image Pixel by Pixel in Java Open CV

I am trying to get the following C++ Code into Java

    Mat dif = bg - gr;
        // threshold the difference image so we get dark letters
        threshold(dif, bw, 0, 255, CV_THRESH_BINARY_INV | CV_THRESH_OTSU);
        // threshold the background image so we get dark region
        threshold(bg, dark, 0, 255, CV_THRESH_BINARY_INV | CV_THRESH_OTSU);

        // extract pixels in the dark region 
        vector<unsigned char> darkpix(countNonZero(dark)); // <---- HOW TO REPLACE THIS WITH JAVA
        int index = 0;
        for (int r = 0; r < dark.rows; r++)
        {
            for (int c = 0; c < dark.cols; c++)
            {
//---------------------HOW TO REPLACE THIS SECTION WITH JAVA  ---------------
                if (dark.at<unsigned char>(r, c)) // ***dark is binary image mat***
                {
                    darkpix[index++] = gr.at<unsigned char>(r, c);  //***gr is grayscaled image mat***
                }                  
//------------------------------------------------------------------------------------------
            }
        } 
    threshold(darkpix, darkpix, 0, 255, CV_THRESH_BINARY | CV_THRESH_OTSU);

I am able to convert this till the threshold code but confused how to achieve it from the section where they start to parse the Binary Image Mat dark. Following is my Java Code

    Mat dif = new Mat();
            Core.subtract(bg,gr,dif);

            // threshold the difference image so we get dark letters
            Imgproc.threshold(dif, bw, 0, 255, Imgproc.THRESH_BINARY_INV | Imgproc.THRESH_OTSU);
            // threshold the background image so we get dark region
            Imgproc.threshold(bg, dark, 0, 255, Imgproc.THRESH_BINARY_INV | Imgproc.THRESH_OTSU);

            // extract pixels in the dark region
            Double[] darkpix = new Double[Core.countNonZero(dark)];

            int index = 0;
            for (int r = 0; r < dark.rows(); r++)
            {
                for (int c = 0; c < dark.cols(); c++)
                {
                    if (dark.get(r, c)[0] == 1.0)
                    {
                        // --->dont know what to put here <---
                    }
                }
            }
Mat darkPixMat = new Mat();
Imgproc.threshold(darkpixMat, darkpixMat, 0, 255, Imgproc.THRESH_BINARY | Imgproc.THRESH_OTSU);

I searched a couple of other answers but couldn't find solution for this code.

2016-11-29 13:47:22 -0600 commented question How to get different blocks from the borders in image using OpenCV

@theodore - Very helpful links !!! :)

2016-11-29 13:43:30 -0600 commented answer How to slice image with respect to horizontal line pattern

@Tetragramm - O Sorry.My Mistake I missed the third point you mentioned in the answer .

2016-11-29 13:24:16 -0600 commented answer How to slice image with respect to horizontal line pattern

@Tetragramm - Great explanation thanks a lot !!! .Plus just would like to mention a graphical representation of what you explained --> www.stackoverflow.com/questions/18782873/houghlines-transform-in-opencv

2016-11-29 13:22:15 -0600 received badge  Scholar (source)
2016-11-29 12:59:02 -0600 received badge  Supporter (source)
2016-11-29 12:58:37 -0600 commented answer How to slice image with respect to horizontal line pattern

thanks pretty better results !! Can you explain a bit and also sometimes one extra line is getting added on the same line.

2016-11-29 12:26:56 -0600 received badge  Organizer (source)
2016-11-29 12:25:58 -0600 asked a question How to slice image with respect to horizontal line pattern

I am new to opencv and trying out segmenting operations. I have this processed image as follows --> image description

I want to slice the image into separate blocks only if the line covers about 70% of the total width as shown in below image -->

image description

I tried HoughLine Transform as given in this link but the results were completely wrong and not even close. Please explain how to solve this problem with code.

2016-11-19 01:59:52 -0600 received badge  Enthusiast
2016-09-30 01:54:32 -0600 received badge  Student (source)
2016-09-29 17:04:12 -0600 asked a question How to get different blocks from the borders in image using OpenCV

I am using OpenCV with C++.

I have the following image

enter image description here

I want to replicate the cell structure in this image into an excel sheet.I have managed to OCR the texts but not getting exactly how we can replicate the structure to excel. I was thinking of cropping out the blocks and so I tried few techniques like using HoughLinesP() for seperating each cell but its just not working and also tried line pattern matching with minMaxLoc() but that's also not giving a good result.

I am not looking to totally replicate the exact cells in the image but to atleast acheive to replicate the simpler cells .

Is there any reliable technique to do this in OpenCV ?