contour

What is the algorithm that opencv uses for finding contours?

 ̄綄美尐妖づ 提交于 2019-11-27 01:18:47
问题 I need to use cv::FindContours() in a program and I have to know the algorithm behind that. What algorithm does openCV use to find contours? How does it work? 回答1: If you read the documentation it is mentioned this function implements the algorithm of: Suzuki, S. and Abe, K., Topological Structural Analysis of Digitized Binary Images by Border Following. CVGIP 30 1, pp 32-46 (1985) OpenCV is open source if you want to see how this is implemented just need to read the code: https://github.com

matplotlib - extracting data from contour lines

故事扮演 提交于 2019-11-27 00:17:49
I would like to get data from a single contour of evenly spaced 2D data (an image-like data). Based on the example found in a similar question: How can I get the (x,y) values of the line that is ploted by a contour plot (matplotlib)? >>> import matplotlib.pyplot as plt >>> x = [1,2,3,4] >>> y = [1,2,3,4] >>> m = [[15,14,13,12],[14,12,10,8],[13,10,7,4],[12,8,4,0]] >>> cs = plt.contour(x,y,m, [9.5]) >>> cs.collections[0].get_paths() The result of this call into cs.collections[0].get_paths() is: [Path([[ 4. 1.625 ] [ 3.25 2. ] [ 3. 2.16666667] [ 2.16666667 3. ] [ 2. 3.25 ] [ 1.625 4. ]], None)]

Hide contour linestroke on pyplot.contourf to get only fills

*爱你&永不变心* 提交于 2019-11-26 22:46:07
问题 I have a pet project to create images of maps, where I draw the roads and other stuff over a contour plot of the terrain elevation. It is intended to plan mountain bike routes (I have made some vectorial drawings by hand, in the past, and they work great for visualization). Currently, I download Digital Elevation Model, in GeoTIFF, from here: http://www.ecologia.ufrgs.br/labgeo/arquivos/downloads/dados/SRTM/geotiff/rs.rar and then create the plot with GDAL and Matplotlib contourf function:

Increase the speed of redrawing contour plot in matplotlib

筅森魡賤 提交于 2019-11-26 21:25:08
问题 I have a python program that plots the data from a file as a contour plot for each line in that text file. Currently, I have 3 separate contour plots in my interface. It does not matter if I read the data from a file or I load it to the memory before executing the script I can only get ~6fps from the contour plots. I also tried using just one contour and the rest normal plots but the speed only increased to 7fps. I don't believe that it is so computationally taxing to draw few lines. Is there

Reverse and change limit of axis

蓝咒 提交于 2019-11-26 21:07:06
问题 I am trying to create a contour plot. I would like to have depth on the Y-axis and time on the X-axis. Right now this is the code that I am using: par <- ggplot(up_PAR, aes(Time.hour.of.the.day., Depth, z = PAR)) parplot <- par + stat_contour(bins=20, aes(colour=..level..))+ scale_colour_gradient(limits=c(0.000842, 0.00000000195),low="black", high="black") + scale_y_reverse()+ theme_bw()+ theme(panel.grid.major = element_blank(), panel.grid.minor = element_blank())+ xlab("Hour of the Day")+

Why does pyplot.contour() require Z to be a 2D array?

谁都会走 提交于 2019-11-26 20:48:44
The matplotlib.pyplot.contour() function takes 3 input arrays X , Y and Z . The arrays X and Y specify the x- and y-coordinates of points, while Z specifies the corresponding value of the function of interest evaluated at the points. I understand that np.meshgrid() makes it easy to produce arrays which serve as arguments to contour() : X = np.arange(0,5,0.01) Y = np.arange(0,3,0.01) X_grid, Y_grid = np.meshgrid(X,Y) Z_grid = X_grid**2 + Y_grid**2 plt.contour(X_grid, Y_grid, Z_grid) # Works fine This works fine. And conveniently, this works fine too: plt.contour(X, Y, Z_grid) # Works fine too

How to crop the internal area of a contour?

半腔热情 提交于 2019-11-26 18:14:30
问题 I am working on Retinal fundus images.The image consists of a circular retina on a black background. With OpenCV, I have managed to get a contour which surrounds the whole circular Retina. What I need is to crop out the circular retina from the black background. 回答1: It is unclear in your question whether you want to actually crop out the information that is defined within the contour or mask out the information that isn't relevant to the contour chosen. I'll explore what to do in both

R - ggplot - stat_contour not able to generate contour lines

Deadly 提交于 2019-11-26 17:45:20
问题 I am trying to add contour lines via stat_contour() to my ggplot / ggplot2 -plot. Unfortunately, I can not give you the real data from which point values should be evaluated. However, another easily repreducably example behaves the same: testPts <- data.frame(x=rep(seq(7.08, 7.14, by=0.005), 200)) testPts$y <- runif(length(testPts$x), 50.93, 50.96) testPts$z <- sin(testPts$y * 500) ggplot(data=testPts, aes(x=x, y=y, z=z)) + geom_point(aes(colour=z)) + stat_contour() This results in the

OpenCV's Canny Edge Detection in C++

天大地大妈咪最大 提交于 2019-11-26 16:18:48
问题 I want to extract the edges of hand but I get the following result. I've tried adjusting the low and high threshold but I still can't get the desired output. I have included below the code and its output. What seems to be the problem? This is the output image generated by the code below. #include <opencv2/core/core.hpp> #include <opencv2/highgui/highgui.hpp> #include <opencv2/imgproc/imgproc.hpp> int main(){ cv::Mat image= cv::imread("open_1a.jpg"); cv::Mat contours; cv::Mat gray_image;

How to crop away convexity defects?

不问归期 提交于 2019-11-26 12:43:43
问题 I\'m trying to detect and fine-locate some objects in images from contours. The contours that I get often include some noise (maybe form the background, I don\'t know). The objects should look similar to rectangles or squares like: I get very good results with shape matching ( cv::matchShapes ) to detect contours with those objects in them, with and without noise, but I have problems with the fine-location in case of noise. Noise looks like: or for example. My idea was to find convexity