What is the algorithm that opencv uses for finding contours?

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/opencv/opencv/blob/master/modules/imgproc/src/contours.cpp#L1655 … Read more

Contour/imshow plot for irregular X Y Z data

Does plt.tricontourf(x,y,z) satisfy your requirements? It will plot filled contours for irregularly spaced data (non-rectilinear grid). You might also want to look into plt.tripcolor(). import numpy as np import matplotlib.pyplot as plt x = np.random.rand(100) y = np.random.rand(100) z = np.sin(x)+np.cos(y) f, ax = plt.subplots(1,2, sharex=True, sharey=True) ax[0].tripcolor(x,y,z) ax[1].tricontourf(x,y,z, 20) # choose 20 contour levels, … Read more

OpenCV Python: cv2.findContours – ValueError: too many values to unpack

I got the answer from the OpenCV Stack Exchange site. Answer THE ANSWER: I bet you are using the current OpenCV’s master branch: here the return statements have changed, see http://docs.opencv.org/modules/imgproc/doc/structural_analysis_and_shape_descriptors.html?highlight=findcontours. Thus, change the corresponding line to read: _, contours, _= cv2.findContours(skin_ycrcb, cv2.RETR_EXTERNAL, cv2.CHAIN_APPROX_SIMPLE) Or: since the current trunk is still not stable and you … Read more

Python : 2d contour plot from 3 lists : x, y and rho?

You need to interpolate your rho values. There’s no one way to do this, and the “best” method depends entirely on the a-priori information you should be incorporating into the interpolation. Before I go into a rant on “black-box” interpolation methods, though, a radial basis function (e.g. a “thin-plate-spline” is a particular type of radial … Read more

Plotting contours on an irregular grid

Here are some different possibilites using base R graphics and ggplot. Both simple contours plots, and plots on top of maps are generated. Interpolation library(akima) fld <- with(df, interp(x = Lon, y = Lat, z = Rain)) base R plot using filled.contour filled.contour(x = fld$x, y = fld$y, z = fld$z, color.palette = colorRampPalette(c(“white”, “blue”)), … Read more