hough-transform

How can I correctly classify the number of positive (bright color) circles and negative (dark color) circles in the image

拥有回忆 提交于 2019-12-02 10:20:40
Long post - please bear with me. For a better understanding of what the goal is and what I have done so far, I have posted the code. Please let me know if any further information is required. I have an image (as shown) and the goal is to correctly classify the number of positive (blue) and negative (purple) circles . I do not care about the semi-circles in the image . As shown in the image, there are 29 circles (excluding the semi circles) in which there 7 positive ones. But my code detects only 1 positive. Here is what I have done so far: import cv2 import numpy as np from matplotlib import

OpenCV : Hough Circle Transform - how to sort the output

China☆狼群 提交于 2019-12-02 09:03:53
I wrote a code that can find the center of mass like below: I have 6 circles, everyone with his center mass I need to group two by two and find the half of the distance between centers of mass In this phase I have three points Making the average oh this three points i determine a center of mass I don't understand how to sort the vector where are stored the date of the circles. Example 1 Here the indices are fine Example 2 Here they don't have an order And here is my code int loadMyFrameWithHough (string framePath){ Mat myFrame1,myFrameGray,myFrameEdge; myFrame1 = imread(framePath,CV_LOAD_IMAGE

Improve HoughLines for horizontal lines detect (Python, OpenCV)

久未见 提交于 2019-12-02 05:21:10
I have this source image: My goal is to remove the bottom line while keep the letters/numbers untouched. This is the code I use: import cv2 import numpy as np img = cv2.imread('src.png') gray = cv2.cvtColor(img,cv2.COLOR_BGR2GRAY) edges = cv2.Canny(gray,100,200,apertureSize = 5) minLineLength = 0 maxLineGap = 19 lines = cv2.HoughLinesP(edges,1,np.pi/180,15,minLineLength,maxLineGap) for x in range(0, len(lines)): for x1,y1,x2,y2 in lines[x]: cv2.line(img,(x1,y1),(x2,y2),(255,255,255),2) cv2.imshow('hough',img) cv2.waitKey(0) The best result I achieved by now is this: How can I improve it more,

Identifying green circles from this image

谁都会走 提交于 2019-12-02 00:56:54
问题 I have currently made an image that consists of black and green dots..... I made a print of it and then clicked it with my camera..... After that i made a program to scan this image in opencv. Here is the image: This is the code image = imread("ImageTryse.jpg", 1); // Read the image cv::resize(image, image, Size(800, 800), 0, 0, cv::INTER_CUBIC); Mat image_gray = IncreaseContrast(image); cvtColor(image_gray, image_gray, CV_BGR2GRAY); vector<vec3f> circles1; HoughCircles(image_gray, circles1,

How to filter only the longest line after Hough Transform

淺唱寂寞╮ 提交于 2019-12-01 22:58:57
问题 I'm currently using the Hough Transform to get the straight lines. But there are a lot of lines detected. Can I know how to filter and only get the longest line from the output? HoughLinesP(dst, lines, 1, CV_PI/180, 50, 20, 10 ); //left lane for( size_t i = 0; i < lines.size(); i++ ) { Vec4i l = lines[i]; double theta1,theta2, hyp, result; theta1 = (l[3]-l[1]); theta2 = (l[2]-l[0]); hyp = hypot(theta1,theta2); line( cdst, Point(l[0], l[1]), Point(l[2], l[3]), Scalar(255,0,0), 3, CV_AA); }

How to find the location of barcode in an image

a 夏天 提交于 2019-12-01 20:53:48
问题 How can I find the location of barcode in an image? Original Image 回答1: To find the location of barcode, normally differences of gradient method is taken. If we take contrast gradient across a barcode, we get high gradient in horizontal direction while low gradient in vertical direction. So where their difference (ie horizontal gradient-vertical gradient) is maximum, we take position of barcode. Please refer to these paper: Reading Barcodes Following links also deals with this : Link 1, Link

How to filter only the longest line after Hough Transform

此生再无相见时 提交于 2019-12-01 20:18:16
I'm currently using the Hough Transform to get the straight lines. But there are a lot of lines detected. Can I know how to filter and only get the longest line from the output? HoughLinesP(dst, lines, 1, CV_PI/180, 50, 20, 10 ); //left lane for( size_t i = 0; i < lines.size(); i++ ) { Vec4i l = lines[i]; double theta1,theta2, hyp, result; theta1 = (l[3]-l[1]); theta2 = (l[2]-l[0]); hyp = hypot(theta1,theta2); line( cdst, Point(l[0], l[1]), Point(l[2], l[3]), Scalar(255,0,0), 3, CV_AA); } imshow("detected lines", cdst); } As far as I can see, you're literally a step away: The hypot function

Understanding Hough Transform [closed]

微笑、不失礼 提交于 2019-12-01 11:19:18
I am trying to understand MATLAB's code for the Hough Transform. Some items are clear to me in this picture, binary_image is the monochrome version of input_image . hough_lines is a vector containing detected lines in the image. I see that, four lines have been detected. T contain the thetas in the (ϴ, ρ) space of the image. R contain the rhos in the (ϴ, ρ) space of the image. I have the following questions, Why is the image rotated before applying Hough Transform? What do the entries in H represent? Why is H (Hough Matrix) of size 45x180? Where does this size come from? Why is T of size 1x180

how to use hough circles in cv2 with python?

时光总嘲笑我的痴心妄想 提交于 2019-12-01 03:23:56
I have the following code and I want to detect the circle. img = cv2.imread("act_circle.png") gray = cv2.cvtColor(img,cv2.COLOR_BGR2GRAY) circles = cv2.HoughCircles(gray,cv2.CV_HOUGH_GRADIENT) it looks like it does not have the attribute and the error is the following 'module' object has no attribute 'CV_HOUGH_GRADIENT' Does anybody know where this hidden parameters is? Thanks CV_HOUGH_GRADIENT belongs to the cv module, so you'll need to import that: import cv2.cv as cv and change your function call to circles = cv2.HoughCircles(gray,cv.CV_HOUGH_GRADIENT) Saurav In my case, I am using opencv 3

Hough Transform for finding curve segments

故事扮演 提交于 2019-11-30 20:21:15
Hough Transform can be used to extract lines from images. It can also be used to extract curves - this is a little harder though because higher dimensional Hough transforms are resource consuming. I was wondering whether how one restricts the Hough transform to 2D voting space for a curve of order 3 i.e. x^{3}+ax^{2}+bx+c ? Anyone know any good sites explaining this (can't seem to find any). Or an explanation here if there isn't one :). The essence of the Generalised Hough Transform that the "sides" of the accumulator is the answer you are looking for. If you are trying to match ellipses or