edge-detection

Get angle from OpenCV Canny edge detector

旧时模样 提交于 2019-12-06 01:51:00
I want to use OpenCV's Canny edge detector, such as is outlined in this question . For example: cv::Canny(image,contours,10,350); However, I wish to not only get the final thresholded image out, but I also wish to get the detected edge angle at each pixel. Is this possible in OpenCV? canny doesn't give you this directly. However, you can calculate the angle from the Sobel transform, which is used internally in canny() . Pseudo code: cv::Canny(image,contours,10,350); cv::Sobel(image, dx, CV_64F, 1, 0, 3, 1, 0, cv::BORDER_REPLICATE); cv::Sobel(image, dy, CV_64F, 0, 1, 3, 1, 0, cv::BORDER

Having difficulties detecting small objects in noisy background. Any ways to fix this?

Deadly 提交于 2019-12-06 00:26:38
问题 I am trying to make a computer vision program in which it would detect litter and random trash in a noisy background such as the beach (noisy due to sand). Original Image: Canny Edge detection without any image processing: I realize that a certain combination of image processing technique will help me accomplish my goal of ignoring the noisy sandy background and detect all trash and objects on the ground. I tried to preform median blurring, play around and tune the parameters, and it gave me

Differences between 'imfilter' and 'conv2' [MATLAB]

风流意气都作罢 提交于 2019-12-05 15:32:58
I use this both function to find edges on a scale. You have a input image, you apply a mask (for ex. prewitt) to the input image, and get the resultant pic. mypic = imread('examplepic.jpg') hy = fspecial('prewitt') yimfilter = imfilter(mypic,hy) % Using imfilter yconv2 = conv2(mypic,hy) % Using conv2 Which is the theorical difference between these two? I know I got different outputs, but which is the difference? Thanks conv2 outputs the entire 2-D convolution, which means that yconv2 will be bigger than mypic. imfilter, on the other hand, by default trims the edges of the convolution so that

How to do canny edge detection in javacv/opencv?

烂漫一生 提交于 2019-12-05 05:06:35
问题 I'm currently working on image processing project and I need to detect edges from image. I thought to use canny edge detection for detect lines of the image, So i searched about canny edge detection using javacv on internet and I found some tutorials which gives the basic idea about canny edge detection technique but I could not be able to find any sample code regarding this. Please can someone provide simple sample edge detection code ? It’s really appreciate if you can provide code example

opencv matching edge images

生来就可爱ヽ(ⅴ<●) 提交于 2019-12-05 02:09:04
问题 I am working on the project and part of it is to recognize objects recorded on camera. So to be more specofic: I am using OpenCV I have correctly setup camera and am able to retrieve pictures from it I have compiled and experimented with number of demos from OpenCV I need a scale- AND rotation- invariant algorithm for detection Pictures of original objects are ONLY available as edge-images All feature detection/extraction/matching algorithms I have seen so far are working reasonably well with

OpenCV Android Create New Image Using the Edges of the Largest Contour

依然范特西╮ 提交于 2019-12-05 01:04:36
问题 I am able to detect the largest square/rectangle (in green) in an image. However, I want to convert the largest square/rectangle detected in the image into a new image (to be stored in a new Mat). Here's the return image of this function that has the largest rectangle/square on it: http://img153.imageshack.us/img153/9308/nn4w.png Here is my code so far: private Mat findLargestRectangle(Mat original_image) { Mat imgSource = original_image; //convert the image to black and white Imgproc

drawContours around detected document using opencv for android gives strange bug

爱⌒轻易说出口 提交于 2019-12-04 19:19:05
I am new to OpenCv4Android. I am trying to auto detect document using OpenCv4Android sdk. Initially i have gone through issue of landscape opencv camera . Somehow i managed to change the orientation of opencv JavaCameraview to portrait. I made following changes in default classes of opencv sdk to orient opencv camera in portrait : 1) In CameraBridgeViewBase class Matrix matrix = new Matrix(); matrix.setRotate(90f); Bitmap bitmap = Bitmap.createBitmap(mCacheBitmap, 0, 0, mCacheBitmap.getWidth(), mCacheBitmap.getHeight(), matrix, true); 2) now in drawbitmap method replace above bitmap with

2D numpy array- check to see if all adjacent terms are equal

故事扮演 提交于 2019-12-04 15:50:54
I am starting with a nxm boolean array, that defines regions- true if it is in the region, false if not. For example: r = np.array([[ 0, 0, 1, 1, 1], [ 0, 1, 1, 0, 0], [ 0, 1, 1, 1, 0], [ 1, 1, 1, 0, 0], [ 1, 1, 0, 0, 0]]) The line between regions can be defined as an n-1 x m-1 array, which would represent a 'point' in between each set of four values. If all 4 surrounding values are the same, you are not on the edge between regions. If any of the 4 values are different, you are. For r above: l = np.array([[ 1, 1, 1, 1], [ 1, 0, 1, 1], [ 1, 0, 1, 1], [ 0, 1, 1, 0]]) Any thoughts on how this can

Fastest Sobel Edge Detection C#

不想你离开。 提交于 2019-12-04 15:44:44
问题 I want to make a program that implements sobel edge detection. This is my code : private Bitmap SobelEdgeDetect(Bitmap ori) { Bitmap b = original; Bitmap bb = original; int width = b.Width; int height = b.Height; int[,] gx = new int[,] { { -1, 0, 1 }, { -2, 0, 2 }, { -1, 0, 1 } }; int[,] gy = new int[,] { { 1, 2, 1 }, { 0, 0, 0 }, { -1, -2, -1 } }; int[,] allPixR = new int[width, height]; int[,] allPixG = new int[width, height]; int[,] allPixB = new int[width, height]; int limit = 128 * 128;

Corner detection in Image processing Opencv Python

余生长醉 提交于 2019-12-04 13:41:24
问题 I have an image of the box. I am trying to detect corners and mark those corner from circles. I am using the following code for this: import cv2 import numpy as np img_file = 'Image.jpg' img = cv2.imread(img_file, cv2.IMREAD_COLOR) imgDim = img.shape dimA = imgDim[0] dimB = imgDim[1] # RGB to Gray scale conversion img_gray = cv2.cvtColor(img,cv2.COLOR_RGB2GRAY) # Noise removal with iterative bilateral filter(removes noise while preserving edges) noise_removal = cv2.bilateralFilter(img_gray,9