Questions tagged [contour]

A contour line for a function of two variables is a curve connecting points where the function has the same particular value.

From wiki,

a contour line for a function of two variables is a curve connecting points where the function has the same particular value. The gradient of the function is always perpendicular to the contour lines. When the lines are close together the magnitude of the gradient is large: the variation is steep. A level set is a generalization of a contour line for functions of any number of variables.

Contour lines are curved or straight lines on a map describing the intersection of a real or hypothetical surface with one or more horizontal planes. The configuration of these contours allows to infer relative gradient of a parameter and estimate that parameter at specific places. Contour lines may be either traced on a visible three-dimensional model of the surface, as when viewing a stereo-model plots elevation contours, or interpolated from estimated surface elevations, as when a computer program threads contours through a network of observation points of area centroids. In the latter case, the method of interpolation affects the reliability of individual isolines and their portrayal of slope, pits and peaks.

2744 questions
88
votes
9 answers

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

I'm writing an opencv program and I found a script on another stackoverflow question: Computer Vision: Masking a human hand When I run the scripted answer, I get the following error: Traceback (most recent call last): File "skinimagecontour.py",…
ahmadux
  • 2,667
  • 3
  • 17
  • 15
64
votes
2 answers
60
votes
4 answers

matplotlib - extracting data from contour lines

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…
dtlussier
  • 3,018
  • 2
  • 26
  • 22
55
votes
2 answers

Find and draw the largest contour in opencv on a specific color (Python)

Im trying to get the largest contour of a red book. I've got a little problem with the code because its getting the contours of the smallest objects (blobs) instead of the largest one and I can't seem to figure out why this is happening The code I…
Zaptimist
  • 553
  • 1
  • 4
  • 5
44
votes
4 answers

How do you create a legend for a contour plot?

I can't seem to find the answer anywhere! I found a discussion here, but trying this I get a TypeError: 'NoneType' object is not iterable: >>> import numpy as np >>> import matplotlib.pyplot as plt >>> x, y =…
user545424
  • 15,713
  • 11
  • 56
  • 70
38
votes
1 answer

Plotting contours on an irregular grid

I have gone through pages and pages of contour plots in R (including many hints on stackoverflow) without success. Here is my data to contour, including adding a map of Rwanda (the data consists of 14 values of longitude, latitude and rain as x,y…
Zilore Mumba
  • 1,346
  • 4
  • 23
  • 33
36
votes
2 answers

Python/Matplotlib - Colorbar Range and Display Values

When using matplotlib with a contour plot, I'm having trouble getting the colorbar to display as I want. I've read through numerous similar examples, but have still not been able to get what I want. In the image below, I want two things changed. …
Scott B
  • 2,542
  • 7
  • 30
  • 44
36
votes
2 answers

Reverse and change limit of axis

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 + …
HAC
  • 391
  • 1
  • 4
  • 5
34
votes
2 answers

What is the algorithm that opencv uses for finding contours?

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?
Milad R
  • 1,854
  • 9
  • 25
  • 36
32
votes
2 answers

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

I have a simple problem in python and matplotlib. I have 3 lists : x, y and rho with rho[i] a density at the point x[i], y[i]. All values of x and y are between -1. and 1. but they are not in a specific order. How to make a contour plot (like with…
Vincent
  • 57,703
  • 61
  • 205
  • 388
32
votes
2 answers

OpenCV - visualize polygonal curve(s) extracted with cv2.approxPolyDP()

I want to visualize polygonal curve(s) extracted with cv2.approxPolyDP(). Here's the image I am using: My code attempts to isolate the main island and define and plot the contour approximation and contour hull. I have plotted the contour found in…
Aidenhjj
  • 1,249
  • 1
  • 14
  • 27
31
votes
3 answers

How to crop the internal area of a contour?

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…
Gaurav Patil
  • 483
  • 2
  • 5
  • 10
31
votes
2 answers

R interpolated polar contour plot

I'm attempting to script a contour polar plot in R from interpolated point data. In other words, I have data in polar coordinates with a magnitude value I would like to plot and show interpolated values. I'd like to mass produce plots similar to…
Nate
  • 768
  • 3
  • 9
  • 17
30
votes
2 answers

Draw axis lines or the origin for Matplotlib contour plot

I want to draw x=0 and y=0 axis in my contour plot, using a white color. If that is too cumbersome, I would like to have a white dot denoting where the origin is. My contour plot looks as follows and the code to create it is given below. xvec =…
nos
  • 19,875
  • 27
  • 98
  • 134
30
votes
3 answers

Make contour of scatter

In python, If I have a set of data x, y, z I can make a scatter with import matplotlib.pyplot as plt plt.scatter(x,y,c=z) How I can get a plt.contourf(x,y,z) of the scatter ?
JuanPablo
  • 23,792
  • 39
  • 118
  • 164
1
2 3
99 100