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
14
votes
4 answers

How to crop away convexity defects?

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…
Micka
  • 19,585
  • 4
  • 56
  • 74
14
votes
3 answers

Draw single Contour in OpenCV on image

What is the best way to draw a single contour in OpenCV? As far as i can see drawContours can only handle multiple contours. Background: I want to change my code to a for each loop. The old code: //vector > contours = result of…
Sebastian Schmitz
  • 1,884
  • 3
  • 21
  • 41
14
votes
2 answers

Create contour map

Given a set of (x, y, z) coordinates, how would I go about creating a contour map? Would be nice to know how to implement in d3 but wouldn't mind trying to implement it myself if I had some direction. For d3 users, can I create a contour map using…
Wex
  • 15,539
  • 10
  • 64
  • 107
14
votes
8 answers

OpenCV, how to use arrays of points for smoothing and sampling contours?

I have a problem to get my head around smoothing and sampling contours in OpenCV (C++ API). Lets say I have got sequence of points retrieved from cv::findContours (for instance applied on this this image: Ultimately, I want To smooth a sequence…
Quentin Geissmann
  • 2,240
  • 1
  • 21
  • 36
13
votes
2 answers

Extract contours from ContourPlot in Mathematica

I have a function f(x,y) of two variables, of which I need to know the location of the curves at which it crosses zero. ContourPlot does that very efficiently (that is: it uses clever multi-grid methods, not just a brute force fine-grained scan) but…
Kasper Peeters
  • 1,580
  • 2
  • 18
  • 37
13
votes
2 answers

Python matplotlib contour plot logarithmic color scale

I have problems with a contour-plot using logarithmic color scaling. I want to specify the levels by hand. Matplotlib, however, draws the color bar in a strange fashion -- the labels are not placed well and only one color appears. The idea is based…
7asd23hasd
  • 303
  • 2
  • 5
  • 11
13
votes
2 answers

Convert contour paths to svg paths

I am using openCV with python to extract contours from an image. Now I need to export these contour paths (list) as an svg paths. How can I achieve this ? code: ret,thresh = cv2.threshold(imgray,27,25,0) contours, hierarchy =…
Laxman
  • 1,149
  • 2
  • 11
  • 17
13
votes
2 answers

Drawing labels on flat section of contour lines in ggplot2

In a previous question, I reproduced a contour plot generated with the fields package, in ggplot2 instead (full example below). The only trouble is, I would like to replicate the placement of the contour labels in contour(), which by default are at…
rebeccmeister
  • 300
  • 2
  • 12
13
votes
1 answer

How can I draw inline line labels in matplotlib?

I have the following graph, consisting of several lines: Now, I would like to label all the lines in the plot. However, using legend() crams all the labels together in a box, which makes the plot somewhat difficult to interpret. What I'd like to to…
Daniel
  • 695
  • 7
  • 20
13
votes
2 answers

Closing a contour curve in OpenCV

I'm using OpenCV (Canny + findCountours) to find external contours of objects. The curve drawn is typically almost, but not entirely, closed. I'd like to close it - to find the region it bounds. How do I do this? Things considered: Dilation - the…
SRobertJames
  • 8,210
  • 14
  • 60
  • 107
13
votes
2 answers

Stop pyplot.contour from drawing a contour along a discontinuity

I have a 2d map of a coordinate transform. The data at each point is the aximuthal angle in the original coordinate system, which goes from 0 to 360. I'm trying to use pyplot.contour to plot lines of constant angle, e.g. 45 degrees. The contour…
GJP
  • 415
  • 4
  • 13
13
votes
2 answers

How can i convert images from scikit-image to opencv2 and other libraries?

I tried to find contour with cv2 python library in a skeletonized image created with scikit-image and i got this error: contours, hierarchy = cv2.findContours(skel,cv2.RETR_TREE,cv2.CHAIN_APPROX_SIMPLE) TypeError: data type = 0 is not…
improc
  • 415
  • 2
  • 9
  • 17
13
votes
2 answers

OpenCV C++: Sorting contours by their contourArea

How can I sort contours by the size of their contour areas? And how can I get the biggest/smallest one?
dom
  • 11,894
  • 10
  • 51
  • 74
13
votes
1 answer

OpenCV sub-image from a Mat image

Possible Duplicate: Understanding region of interest in openCV 2.4 i want to get a sub-image (the one bounded by the red box below) from an image (Mat format). how do i do this? here's my progress so far: include #include…
Og Namdik
  • 823
  • 4
  • 14
  • 22
13
votes
1 answer

OpenCV closing a shape and filling it

I want to output a blue-filled hand but get the incorrect output. I've included the input picture, incorrect output picture and code below. i think the code below does not fill the whole image because the image isn't closed yet at the right…
Og Namdik
  • 823
  • 4
  • 14
  • 22