canny | Canny edge detection on grayscale and RGB color images | Computer Vision library
kandi X-RAY | canny Summary
kandi X-RAY | canny Summary
Canny edge detection on grayscale and RGB color images, in Python.
Support
Quality
Security
License
Reuse
Top functions reviewed by kandi - BETA
- Gradient of an image
- Compute the gradient of each channel
- Calculates the maximum gradient of an image
- Calculate the gray gradient of the image
- Compute the gradient of an image
canny Key Features
canny Examples and Code Snippets
Community Discussions
Trending Discussions on canny
QUESTION
I'm trying to use Skimage to segment an image with watershed, but I always get this error. Do you have a solution please?
AttributeError: module 'skimage.morphology' has no attribute 'watershed'
Source code : https://scikit-image.org/docs/0.12.x/auto_examples/xx_applications/plot_coins_segmentation.html
...ANSWER
Answered 2022-Mar-14 at 01:01You are for some reason looking at the old documentation for scikit-image, version 0.12. (See the 0.12.x in the URL that you shared.) You can look at the examples for the latest released version at:
https://scikit-image.org/docs/stable/auto_examples/
Concretely for your code, you need to update the import to from skimage.segmentation import watershed
.
QUESTION
ANSWER
Answered 2022-Mar-10 at 08:41The issue stems from the houghpeaks properties being to restrictive to find the smaller lines segments. The approach I used is to:
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
)use again your code but only with that angle included, while relaxing the
houghpeaks
properties to allow many more lines to be detected.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
QUESTION
I have a set of black and white images as shown below like Figure 1 and I want to have them with much smaller lines like Figure 2, even though no lines are missing as much as possible. I also tried morphological methods and algorithms like Canny with Python, but I did not get the result I wanted.
...ANSWER
Answered 2022-Mar-09 at 05:29I think you are looking for skeletonization, see skimage.skeletonize
, example here :
QUESTION
I want to recognize the tray is empty or not in the given image using OpenCV in python.
below is what I have tried
- detect the biggest rectangle and cropped by using the below code
ANSWER
Answered 2022-Mar-01 at 20:33I recommend you to:
- do camera calibration to make the lines in your image straight, and
- align your camera well to your production line so you can simplify the image processing and make it more robust, and
- use better illumination conditions if possible.
Given the images above, here is a brute force solution:
- you can first extract the region of interest (ROI) through: HSV segmentation followed by contour detection, then you can extract the rectangular shape of the tray using this SO answer.
QUESTION
I am newbie to OpenCV. I'm trying to find the contours of the captcha image. It does not work only when my captcha image contains the dotted text.
I have done following code for that:
...ANSWER
Answered 2022-Feb-28 at 09:23Here is my code and output
QUESTION
My purpose is to check whether these cubes are in one column or not. Having problem with detecting objects properly. not sure why numbers are placed there like that. My main questions:
- How to compare two point of two objects to check if they are fit well or not?
- How can I improve detecting objects?
Thanks in advance.
...ANSWER
Answered 2022-Feb-02 at 12:05Since the boxes are touching each other, watershed algorithm works well in this cases to extract the box contours. Then the x coordinates position of the rectangle contours can be used to say whether they are aligned or not.
Steps:
- Watershed algorithm to get markers.
- Filter out boxes(rectangles)
- To see if its aligned or not using standard deviation of all the boxes x coordinates. (the threshold can be set accordingly)
Code:
QUESTION
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:10You 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:
QUESTION
I want to remove the background, and draw the outline of the box shown in the image(there are multiple such images with a similar background) . I tried multiple methods in OpenCV, however I am unable to determine the combination of features which can help remove background for this image. Some of the approaches tried out were:
- Edge Detection - Since the background itself has edges of its own, using edge detection on its own(such as Canny and Sobel) didnt seem to give good results.
- Channel Filtering / Thresholding - Both the background and foreground have a similar white color, so I was unable to find a correct threshold to filter the foreground.
- Contour Detection - Since the background itself has a lot of contours, just using the largest contour area, as is often used for background removal, also didnt work.
I would be open to tools in Computer Vision or of Deep Learning (in Python) to solve this particular problem.
...ANSWER
Answered 2022-Jan-07 at 01:57This is one of the cases where it is really useful to fine-tune the kernels of which you are using to dilate and erode the canny edges detected from the images. Here is an example, where the dilation kernel is np.ones((4, 2))
and the erosion kernel is np.ones((13, 7))
:
QUESTION
I am trying to digitize the kid's drawing into SVG or transparent png file format so that they can be used in Scratch. The white paper should be replaced by transparent background and all the drawing part should be preserved.
My plan is to get the outest contour of the drawing and generate a mask, then use the mask to get the drawing part without paper background.
The problem is the drawing may not consecutive which means there may have some small holes leading to break the entire drawing contour to many many small contours.
Now I want to concatenate the near outest contours to form a big outest contour for masking.
The original drawing and the processed result is attached.
Code:
...ANSWER
Answered 2021-Dec-04 at 02:08import cv2, numpy as np
# Read Image
img = cv2.imread('/home/stephen/Desktop/test_img.png')
img =cv2.resize(img, (750,1000))
QUESTION
I have this image (sorry for the size):
Edit: this is just a simple wall corner of my room, nothing special...
I'm trying to detect the exactly corner, but so far failed to do so.
I try to use gray and bilateral, mask and canny and of course combinations of some openCV corner algorithms like Harris, EigenValsAndVecs, MinEigenVal and more...
So far, I found a lot of points, or none.
Any idea please?
Thanks
...ANSWER
Answered 2021-Oct-15 at 05:09This seems rather straightforward. First you compute the gradient magnitude, which will find the lines in between the three mostly uniform regions (b
in the image below), and then you apply something like the Harris corner detector (or any other variety will work too) to find the intersection point between the straight lines (c
in the image below). I used a sigma of 4 for both the Gaussian gradient magnitude and the smoothing in the Harris detector.
I did this test quickly in MATLAB, because it was open, but you have access to the same DIPlib algorithms I used (disclosure: I'm an author of DIPlib). It would look something like this:
Community Discussions, Code Snippets contain sources that include Stack Exchange Network
Vulnerabilities
No vulnerabilities reported
Install canny
You can use canny like any standard Python library. You will need to make sure that you have a development environment consisting of a Python distribution including header files, a compiler, pip, and git installed. Make sure that your pip, setuptools, and wheel are up to date. When using pip it is generally recommended to install packages in a virtual environment to avoid changes to the system.
Support
Reuse Trending Solutions
Find, review, and download reusable Libraries, Code Snippets, Cloud APIs from over 650 million Knowledge Items
Find more librariesStay Updated
Subscribe to our newsletter for trending solutions and developer bootcamps
Share this Page