Ask Your Question

Linke Seitentasche's profile - activity

2020-04-12 06:07:40 -0600 received badge  Popular Question (source)
2019-07-09 23:59:22 -0600 received badge  Famous Question (source)
2017-08-23 12:45:05 -0600 received badge  Notable Question (source)
2017-03-01 05:29:17 -0600 received badge  Popular Question (source)
2013-12-23 18:43:06 -0600 answered a question Trying to run OpenCV samples on Samsung Galaxy S4: dark screen
2013-12-23 03:58:38 -0600 received badge  Self-Learner (source)
2013-12-22 16:08:06 -0600 answered a question Color curve operation with OpenCV: Increase contrast

The following code calculates the appropriate measures:

    int xdist = indentRight - indentLeft; // indent as index from 0 to 256, for the above picture: indentRight: 235, indentLeft: 15
    double alpha = 256.0 / xdist;
    int beta = (int) -(indentLeft* alpha);
2013-12-16 10:32:38 -0600 asked a question Color curve operation with OpenCV: Increase contrast

Hi

With the Gimp image manipulation program, I frequently increase contrast by using the color curve tool. From this:

image description

to this:

image description

There is a small tutorial that talks about increasing contrast here: http://docs.opencv.org/doc/tutorials/core/basic_linear_transform/basic_linear_transform.html

Therefore, I assume this operation would give the desired effect:

image.convertTo(alpha: 1.3, beta: -20)

I would have to calculate the exact alpha and beta values in order to exactly represent the above color curve. Maybe anybody can comment on these assumptions or has suggestions?

Thank you very much.

2013-11-28 23:16:07 -0600 received badge  Nice Answer (source)
2013-11-28 15:43:56 -0600 received badge  Teacher (source)
2013-11-28 11:04:03 -0600 received badge  Self-Learner (source)
2013-11-28 10:59:45 -0600 received badge  Scholar (source)
2013-11-28 10:57:49 -0600 answered a question Select only gray pixels in color image

It can be done and here are my results. This routine is a combination of thresholding and my custom color-component dependant threshold (Java-Code):

Code

// initialization
Mat colorsub = ...
byte[] data = new byte[4];
byte[] black = new byte[] { 0, 0, 0, -1 };
byte[] white = new byte[] { -1, -1, -1, -1 };

// iterate over the image
for (int y = 0; y < colorsub.height(); y++) {
    for (int x = 0; x < colorsub.width(); x++) {

        // extract color component values as unsigned integers (byte is a signed type in java)
        colorsub.get(y, x, data);
        int r = data[0] & 0xff;
        int g = data[1] & 0xff;
        int b = data[2] & 0xff;

         // do simple threshold first
        int thresh = 100;
        if (r > thresh || g > thresh || b > thresh)
        {
            colorsub.put(y, x, white);
            continue;
        }

        // adjust the blue component
        b = (int)(b * 1.3);

        // quantification of color component's values distribution  
        int mean = (r + g + b) / 3;
        int diffr = Math.abs(mean - r);
        int diffg = Math.abs(mean - g);
        int diffb = Math.abs(mean - b);

        int maxdev = 80;

        if ((diffr + diffg + diffb) > maxdev)
            colorsub.put(y, x, white);
        else
        colorsub.put(y, x, black);
    }
}
  1. On my camera I have noticed that in darkgray text the blue channel is too low so I amateurishly increase it a little. This could be improved by a real histogram correction.

  2. Also, the first threshold operation is not really based on pixel intensity, but I think the effect is negligible for this demonstration.

Results

  • First image is the regular image caught by the classifier, in a green border.
  • Second image is the grayscale image by OpenCV, for reference
  • Third image is OpenCVs binary threshold
  • Fourth image is the output from my custom threshold function above.

On a regular desk. This doesn't look too bad:

image description

On a sofa in low light condition. Here the threshold performs better. I had to correct the values for my custom threshold after this one:

image description

On a stack of paper, reduced artifacts:

image description

On the kitchen bar. Since the metal is gray, wen cannot filter it out, obviously:

image description

I think this is the most interesting image. Much less and smaller segments: image description

Conclusion

As with every thresholding algorithm, fine tuning is paramount. Given a thresholded image with finely tuned parameters, a color-coded threshold can still further improve the picture.

It looks to be useful to remove inlined emblems and pictures from the text, e.g. smileys or colored bullet points.

Maybe the information in this post can be of use for someone else.

2013-11-27 13:12:58 -0600 commented answer Galaxy S4 (Android 4.3) UnsatisfiedLinkError - Where are the libraries?

Thanks a lot!

2013-11-27 11:09:50 -0600 received badge  Student (source)
2013-11-27 09:36:05 -0600 received badge  Editor (source)
2013-11-27 09:33:54 -0600 asked a question Galaxy S4 (Android 4.3) UnsatisfiedLinkError - Where are the libraries?

Hi

I got my new Samsung Galaxy S4 with Android 4.3. When I try to run my OpenCV app, I get this error on instantiating a Mat():

11-27 16:25:37.298: W/dalvikvm(26236): No implementation found for native Lorg/opencv/core/Mat;.n_Mat:()J

This is how I initialize OpenCV:

boolean ret = OpenCVLoader.initAsync(OpenCVLoader.OPENCV_VERSION_2_4_6, this,
            mLoaderCallback);

Ret value is true. The mLoaderCallback is never called!

This is what OpenCV manager looks like:

image description

There are no installed packages, I think this is not correct. I tried installing a package I found on the Play store but it did not show up under installed packages.

Any suggestions?

2013-11-26 15:33:46 -0600 received badge  Supporter (source)
2013-11-26 09:17:57 -0600 commented answer Select only gray pixels in color image

I have looked at per-channel thresholding before but unfortunately it's not the same thing I'm trying to achieve.

2013-11-26 06:08:27 -0600 asked a question Select only gray pixels in color image

Hi

To aid my OCR component in recognizinig text I'd like to binary threshold my image first.

I'd like to try a new method of thresholding where I do not only define a threshold value, but als define that the R-G-B component values must be very close to each other.

This way I hope to separate dark-grey text from dark-blue background, where the pixels fall into the same intensity range, but a human could easily distinguish them because of their color.

Example:

  • RGB(9, 9, 9) => becomes black
  • RGB(1, 1, 10) => becomes white

Now I can figure out how to iterate over every pixel and do just that. The question is, do you know if this type of thresholding algorithm is already implemented or if there already exists a name for it?

Thank you very much!