hough | Skew detection in scanned images

 by   qu1j0t3 Python Version: Current License: GPL-2.0

kandi X-RAY | hough Summary

kandi X-RAY | hough Summary

hough is a Python library. hough has no bugs, it has no vulnerabilities, it has build file available, it has a Strong Copyleft License and it has low support. You can download it from GitHub.

I developed this to meet my scanning needs, since scanning pages through ADF scanners* leads to unavoidable skew rates (sometimes as much as 2.5). As such it has no real user interface and is oriented to batch processing on Linux or OS X. It can make use of multiple cores, because the analysis and image processing is very CPU intensive. I use it with TIFF page images (one page per file), as this is convenient on the scanning side, and fits all steps of my personal workflow. However, the program should work on various input formats, and both grey scale and RGB images. If you want to see example documents, just about all of these files have been deskewed this way. Please note: This is an inexact process, with many heuristics discovered by trial and error, and this software is still being improved. It has worked on many thousands of pages of my own material, of varied layouts, but may not work well on your material without tuning and modification. (See comment below about debugging output.).
Support
    Quality
      Security
        License
          Reuse

            kandi-support Support

              hough has a low active ecosystem.
              It has 6 star(s) with 2 fork(s). There are 1 watchers for this library.
              OutlinedDot
              It had no major release in the last 6 months.
              hough has no issues reported. There are 2 open pull requests and 0 closed requests.
              It has a neutral sentiment in the developer community.
              The latest version of hough is current.

            kandi-Quality Quality

              hough has 0 bugs and 0 code smells.

            kandi-Security Security

              hough has no vulnerabilities reported, and its dependent libraries have no vulnerabilities reported.
              hough code analysis shows 0 unresolved vulnerabilities.
              There are 0 security hotspots that need review.

            kandi-License License

              hough is licensed under the GPL-2.0 License. This license is Strong Copyleft.
              Strong Copyleft licenses enforce sharing, and you can use them when creating open source projects.

            kandi-Reuse Reuse

              hough releases are not available. You will need to build from source code and install.
              Build file is available. You can build the component from source.
              Installation instructions, examples and code snippets are available.

            Top functions reviewed by kandi - BETA

            kandi has reviewed hough and discovered the below as its top functions. This is intended to give you an instant insight into hough implemented functionality, and help decide if they suit your requirements.
            • r Return a list of hanging lines .
            • Return a list of vline lines .
            • Print to stderr .
            • grey value
            • Convert boolean to 255
            Get all kandi verified functions for this library.

            hough Key Features

            No Key Features are available at this moment for hough.

            hough Examples and Code Snippets

            No Code Snippets are available at this moment for hough.

            Community Discussions

            QUESTION

            Detecting squares in a chessboard OpenCV
            Asked 2022-Apr-15 at 07:30

            I detected a chessboard using OpenCV in python using:

            • Computing the edge of the image
            • Computing the Hough transform
            • Finding the local maxima of Hough transform
            • Extracting the image lines

            Then I used findContours and drawContours functions:

            ...

            ANSWER

            Answered 2022-Apr-15 at 07:30

            An approach is to use contour area filtering + shape approximation. Since a square has 4 corners, we can assume a contour is a square if it has four vertices.

            Detected squares in green

            Isolated squares

            Source https://stackoverflow.com/questions/71879515

            QUESTION

            Yellow Small Circle Detection Using GoCV
            Asked 2022-Apr-02 at 01:41

            I'm trying to detect circle with checkmark with variety of colours. What I want to detect is yellow with white checkmark, and in the future red circle with x mark.

            What I've been trying so far are these codes below. This one using Hough Circles method.

            ...

            ANSWER

            Answered 2022-Apr-02 at 01:41

            So what I did was I installing another library that's called gcv by vcaesar. There was a method called FindAllImg and what I need just provide two image, one is the source image, in my case a screenshot, and the other is a template image that needed to be searched in the screenshot.

            Source https://stackoverflow.com/questions/71631287

            QUESTION

            Multiple template matching with Scikit-image
            Asked 2022-Mar-29 at 11:59

            I want to find the middle of a coin and find the radii. The radii can tell me if the coin is 5 cents of 50 cents. After finding the image, I must be able to detect the middle of the circles so I can give them a color

            I already made a beginning with writing a code for Hough-transform

            Hopefully someone can help me solve this exercise.

            Code for hough transform:

            ...

            ANSWER

            Answered 2022-Mar-29 at 11:59

            You have 2 choices to find matching circles.

            first one: sliding window

            smaller windows is a template that you seek for it in input image, here two images with different radii 19 and 21 respectively. First at all, find edge of template and input image, after that, multiplying cropped part of image with template. each region that is near to template should have higher value.

            Source https://stackoverflow.com/questions/71651920

            QUESTION

            How to draw a rectangle over a circle detected using Hough circle (without contours)?
            Asked 2022-Mar-22 at 12:15

            I want to draw a rectangle over a circle which I obtained using the Hough circle function over a picture of a human eye. To draw a rectangle I need edge-x-coord, edge-y-coord, height and width as per the syntax of cv2.rectange. But Hough circle gives me center-x, center-y, radius as output. Is there a way to draw a rectangle by manipulating Hough circle outputs? Im kinda clueless what to do about it and I cant find any clear explanation on similar requests... Note: I didn't use contours since its not suitable/working well with my inputs

            Thanks in advance!

            Here is the code:

            ...

            ANSWER

            Answered 2022-Mar-22 at 12:15

            Just do the math on your circle to find the rectangle(square) parallel to the photo(you can support rotated rectangles with more math involved).

            X_min_rect = X_circle - R

            Y_min_rect = Y_circle - R

            Where R is the radious of the circle.

            Width and Height is equal to 2*R

            Source https://stackoverflow.com/questions/71571238

            QUESTION

            Houghlines not reaching edge of image
            Asked 2022-Mar-10 at 08:41

            I am trying to detect all the lines in the following image:

            Using the following code I am able to detect almost all lines:

            ...

            ANSWER

            Answered 2022-Mar-10 at 08:41

            The issue stems from the houghpeaks properties being to restrictive to find the smaller lines segments. The approach I used is to:

            1. use your current code to obtain the angle that the detected lines are at (I just did [lines.theta] and found that theta will be equal to -84)

            2. use again your code but only with that angle included, while relaxing the houghpeaks properties to allow many more lines to be detected.

            3. you'll get many more lines detected that overlap, and we'll discard those by setting a similarity threshold based on their coefficients.

            here's the implementation

            Source https://stackoverflow.com/questions/71368930

            QUESTION

            Detecting circles with DIPlib
            Asked 2022-Feb-15 at 15:43

            I'm trying to detect the circles in this image: and then drawing such circles in another blank image using DIPlib in C++.

            Following the advices of Cris Luengo I've changed the code and now looks like this:

            ...

            ANSWER

            Answered 2022-Feb-15 at 15:43

            The documentation for dip::FindHoughCircles reads:

            Finds circles in 2D binary images using the 2-1 Hough transform. First, circle centers are computed using dip::HoughTransformCircleCenters, and then a radius is calculated for each center. Note that only a single radius is returned per center coordinates.

            That is, this function is not able to find concentric circles.

            One workaround could be to run the function twice, with different limits for the circle sizes.

            In DIPlib, all allocated images (either through the dip::Image constructor, though img.Forge(), through img.Similar(), etc.) are not initialized. You need to explicitly set the pixels to zero before you start drawing in it: detec_img.Fill(0). Your output image has some very nice display of previous memory use in the bottom half, I wonder what computations lead to that! :)

            Source https://stackoverflow.com/questions/71020122

            QUESTION

            How can i find area of an object by photo?
            Asked 2022-Feb-03 at 14:25

            I need to find the area of an irregular object, for example, area of this lemon sketch. Here was my algorithm

            1. Put a coin nearby
            2. measure its radius in pixels,
            3. knowing its real radius calculate pixel to mm ratio.
            4. somehow remove bg from the sketch
            5. calculate its area in pixels (just by counting them)
            6. multiply by the known ratio to find its actual area.

            And I fount some problems:

            1. The cv2 houghcircles method didn't work when there were some other objects nearby
            2. Remove.bg API worked with only fully coloured objects, so it removed the blankspaces between the strokes.

            Could you please suggest any other method, or help me with realising this sort of stuff. The example picture and some code which I managed to write will be below.

            Hough Circles

            ...

            ANSWER

            Answered 2022-Feb-03 at 14:25

            To isolate the coin: HoughCircles is a good approach, even though depending on perspective the coin may not be a perfect circle. You can also try the watershed algorithm to segment all objects, then detect which object is a coin by the color or by how circular it is (e.g., which object has the most similar distances between its centroid and different edge points).

            To isolate the drawing: If the drawing is the only object left besides the coin, mask the coin out and threshold (e.g. with Otsu) to convert the image to binary. You will still have holes in the drawing, which you can eliminate using opening.

            Source https://stackoverflow.com/questions/70972670

            QUESTION

            Extract lines from image with python
            Asked 2022-Jan-30 at 00:24

            I need to extract path/lines from an image. I apply laplacian filter to this input. In laplacian filtered image, the lines to be extracted can be seen as low value pixels connected to form a linear object with high value pixels forming its border (defining the thickness of the linear path). The issue is there are many more pixels between these lines which also have similar values. Setting threshold to extract these lines does not work. Applying filters like entropy or gabor filter also did not work. With HoughP or Hough Transformation nothing meaningful comes out, probably arguments are not set properly. I need help extracting these lines/path from the image.

            ...

            ANSWER

            Answered 2022-Jan-30 at 00:24

            The code below uses cv2.HoughLinesP() on the thresholded image to produce this:

            Source https://stackoverflow.com/questions/70881261

            QUESTION

            Finding straight lines from tightly coupled lines and noise curvy lines
            Asked 2022-Jan-17 at 20:48

            I have this image for a treeline crop. I need to find the general direction in which the crop is aligned. I'm trying to get the Hough lines of the image, and then find the mode of distribution of angles.

            I've been following this tutorialon crop lines, however in that one, the crop lines are sparse. Here they are densely pack, and after grayscaling, blurring, and using canny edge detection, this is what i get

            ...

            ANSWER

            Answered 2022-Jan-02 at 14:10

            You can use a 2D FFT to find the general direction in which the crop is aligned (as proposed by mozway in the comments). The idea is that the general direction can be easily extracted from centred beaming rays appearing in the magnitude spectrum when the input contains many lines in the same direction. You can find more information about how it works in this previous post. It works directly with the input image, but it is better to apply the Gaussian + Canny filters.

            Here is the interesting part of the magnitude spectrum of the filtered gray image:

            The main beaming ray can be easily seen. You can extract its angle by iterating over many lines with an increasing angle and sum the magnitude values on each line as in the following figure:

            Here is the magnitude sum of each line plotted against the angle (in radian) of the line:

            Based on that, you just need to find the angle that maximize the computed sum.

            Here is the resulting code:

            Source https://stackoverflow.com/questions/70545797

            QUESTION

            How to detect a curve in a B&W image with a background grid?
            Asked 2022-Jan-17 at 13:32

            I am struggling to extract the curve from this image:

            It represents scientific data which I don't want to touch, to avoid introducing errors, so I cannot just manually redraw the line in a plot digitizer: I want to automatically extract the curve, which then I will feed into a plot digitizer.

            I tried programmatically drawing a white grid over the image, trying to exactly overlap the grid and delete it; but unfortunately this is the scanning of a paper sheet, so the grid is not perfect, hence spacing between lines is not always the same.

            Code used for grid:

            ...

            ANSWER

            Answered 2022-Jan-17 at 13:32

            After several experiments (based on these examples) and tests, I ended up with this code:

            Source https://stackoverflow.com/questions/70738777

            Community Discussions, Code Snippets contain sources that include Stack Exchange Network

            Vulnerabilities

            No vulnerabilities reported

            Install hough

            If you see error: invalid command 'bdist_wheel', try (from this page):.
            If you want to actually fix rotations, you will need GraphicsMagick: sudo apt-get install graphicsmagick
            Check out this repository and change working directory to the top level project directory
            Create a Python virtual environment python3 -m venv .venv (On Ubuntu you may need to do this first: sudo apt-get install python3-venv)
            Activate it: source .venv/bin/activate
            Install Python dependencies: pip3 install -r requirements.txt
            If you see error: invalid command 'bdist_wheel', try (from this page): pip install wheel pip install -r requirements.txt
            If you see ModuleNotFoundError: No module named 'imageio', make sure you have activated the venv created during setup: source .venv/bin/activate

            Support

            For any new features, suggestions and bugs create an issue on GitHub. If you have any questions check and ask questions on community page Stack Overflow .
            Find more information at:

            Find, review, and download reusable Libraries, Code Snippets, Cloud APIs from over 650 million Knowledge Items

            Find more libraries
            CLONE
          • HTTPS

            https://github.com/qu1j0t3/hough.git

          • CLI

            gh repo clone qu1j0t3/hough

          • sshUrl

            git@github.com:qu1j0t3/hough.git

          • Stay Updated

            Subscribe to our newsletter for trending solutions and developer bootcamps

            Agree to Sign up and Terms & Conditions

            Share this Page

            share link