contour

How to set as default matplotlib contour plot to always label contours

岁酱吖の 提交于 2019-12-06 15:41:20
Perhaps I'm missing something obvious in the documentation, http://matplotlib.org/examples/pylab_examples/contour_demo.html but when I first create a contour plot, there are labels for each contour line. However, matplotlib does not do this by default. Using the plot given in the demo, I generate more contour lines between 0.00 and 3.00 : import numpy as np import matplotlib.mlab as mlab import matplotlib.pyplot as plt delta = 0.025 x = np.arange(-3.0, 3.0, delta) y = np.arange(-2.0, 2.0, delta) X, Y = np.meshgrid(x, y) Z1 = mlab.bivariate_normal(X, Y, 1.0, 1.0, 0.0, 0.0) Z2 = mlab.bivariate

Trying to segment characters and save it in order to image files. But contours are being drawn in a different order?

时光总嘲笑我的痴心妄想 提交于 2019-12-06 15:32:26
问题 This is the image input. Using python opencv. I did some pre-processing and found contours using contours,hierarchy = cv2.findContours(thresh,cv2.RETR_LIST,cv2.CHAIN_APPROX_SIMPLE) then i did the following to save each character img1 = cv2.imread("test26.png") nu = 1 fin = "final" for cnt in contours: x,y,w,h = cv2.boundingRect(cnt) img2 = img1[y:y+h, x:x+w] img3 = Image.fromarray(img2) filename = fin + str(nu) + ".png" nu = nu + 1 img3.save(filename) But characters are saved in a tree like

Calculate contour area with opencv for contours created by matplotlib

大城市里の小女人 提交于 2019-12-06 14:56:18
问题 I need to calculate the area limited by a contour line. I use matplotlib to get the vertices of the contour line, but I am not able to convert them into a valid input for contourArea method in openCV: Z = z_func(X, Y, Ql, k[i,j], B) cs = plt.contour(X, Y, Z,[IncT]) v = cs.collections[0].get_paths()[0].vertices xy = [] for vv in v: xy.append(vv[0]) cnt = np.array(xy) area = cv2.contourArea(cnt) I get this error: ......\opencv-2.4.9.1\modules\imgproc\src\contours.cpp:1904: error: (-215) contour

matplotlib: preventing a few very large (or small) values to affect my contour

蹲街弑〆低调 提交于 2019-12-06 14:02:09
in plotting the data some times there are a few very large (or very small) numbers which, if not taken care of, will affect the contour in a bad way. a solution is to take out the 10% highest and lowest data out of the contour color grading and considering them as less than and more than. the following figure shows the idea: the two arrow shapes on the top and the bottom of the bar support this idea. any value above 14 will be shown in white and any value below -2 will be shown in black color. how is it possible in matplotlib? How can I define: - to put the 5% of highest values and 5% of

OpenCV draw rectangle from webcam with 2 largest objects

喜你入骨 提交于 2019-12-06 13:02:30
问题 I need to draw rectangle with 2 largest object from webcam. I already got to draw contours with 2 largest object from webcam but now i confuse in how to draw 2 largest Rectangle. Someone can show me the code Please~ //find and draw contours void showconvex(Mat &thresh,Mat &frame) { int largestIndex = 0; int largestContour = 0; int secondLargestIndex = 0; int secondLargestContour = 0; vector<vector<Point> > contours; vector<Vec4i> hierarchy; //find contours findContours(thresh, contours,

How to draw a rectangle around the contours?

故事扮演 提交于 2019-12-06 12:57:10
I am just starting out with opencv and I am trying to make a program that puts squares around a picture of rocks on some sand. The documentation for the function here includes an example of how to use it. findContours( src, contours, hierarchy, CV_RETR_CCOMP, CV_CHAIN_APPROX_SIMPLE ); The prototype of findContours is void findContours(InputOutputArray image, OutputArrayOfArrays contours, OutputArray hierarchy, int mode, int method, Point offset=Point()) ; I have two questions. 1. The third argument in the example hierarchy is a vector<Vec4i> does not match the type findContours expects. Why is

contour plot with date-time strings as x values

三世轮回 提交于 2019-12-06 12:09:51
I am trying to produce a color contour plot showing time along the x axis, depth along the y and temperature as the z values. Time is given as: "2011-01-01 00:01" i.e. "%Y-%m-%d %H:%M" Is there a method for producing the color contour plot from these, and using filled.contour(Time,Depth,temp) example: time <- c("2011-01-01 01:00", "2011-01-01 02:00", "2011-01-01 03:00", "2011-01-01 04:00") depth <- seq(1,10,by = 1) seq1 <- seq(1:40) temp <- matrix(seq1, 10) Every column of temp represents a different time and every row represents a different depth. This works for me: time2 <- as.POSIXct(time)

Overlapping polar countourf and scatter plot

走远了吗. 提交于 2019-12-06 12:03:48
Thanks to this very helpful post , I finally figured out how to make a polar filled-contour plot. However, when I moved to the next step and tried to add a scatter point to the same plot, I ran in some problems. Here is the original script: import numpy as np import matplotlib.pyplot as plt #-- Generate Data ----------------------------------------- # Using linspace so that the endpoint of 360 is included... azimuths = np.radians(np.linspace(0, 360, 20)) zeniths = np.arange(0, 70, 10) r, theta = np.meshgrid(zeniths, azimuths) values = np.random.random((azimuths.size, zeniths.size)) #-- Plot...

Line intersecting contour in openCv

戏子无情 提交于 2019-12-06 03:47:18
问题 I have a contour of object ..and a line .. Object is moving..but line is constant.. I want to know the points at which contour intersects the line.. For example :- Take example of Car Race in which their is finish line.. I have a contour of Car and finish line. I want to know the points on contour which intersects the finish line. 回答1: Intersect the object contour with the line contour (use numpy.logical_and( object_mask, line_mask ) ) and all points where the resulting image is non-zero are

How to filter small segments from image in OpenCV?

╄→尐↘猪︶ㄣ 提交于 2019-12-06 02:03:15
I am printing the Contours in the following way: std::vector<std::vector<cv::Point> > contours; std::vector<cv::Vec4i> hierarchy; cv::findContours( mask, contours, hierarchy, cv::RETR_CCOMP, cv::CHAIN_APPROX_TC89_KCOS); for ( size_t i=0; i<contours.size(); ++i ) { cv::drawContours( img, contours, i, Scalar(200,0,0), 1, 8, hierarchy, 0, Point() ); cv::Rect brect = cv::boundingRect(contours[i]); cv::rectangle(img, brect, Scalar(255,0,0)); } Once I have a binnary image, I want to eliminate the smaller contours. Any suggestions on how to do so? MY INPUT PICTURE: WHAT I WANT TO ACHIEVE: EDIT: I am