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
18
votes
1 answer

Mapping a height map to a grid-based contour format

I have a 2D height map in the following format 06 36 39 42 43 55 ... 37 40 43 43 45 46 ... 40 43 44 45 46 48 ... 44 44 46 47 48 50 ... 41 44 45 47 48 48 ... ... And I need to remap it into a grin based contour format (so it can further be mapped…
Sash
  • 4,448
  • 1
  • 17
  • 31
18
votes
2 answers

Draw Perpendicular line to a line in opencv

I better explain my problem with an Image I have a contour and a line which is passing through that contour. At the intersection point of contour and line I want to draw a perpendicular line at the intersection point of a line and contour up to a…
Wazy
  • 8,822
  • 10
  • 53
  • 98
18
votes
2 answers

How to connect the ends of edges in order to close the holes between them?

My task is to detect the cracks on the soil surface and calculate crack's total area. I used Canny edge detection for this purpose. Input image Result My next step is to convert canny edges to contours since I want to filtrate the cracks using…
18
votes
7 answers

OpenCV Assertion failed: (-215:Assertion failed) npoints >= 0 && (depth == CV_32F || depth == CV_32S)

I have found the following code on this website: import os import os.path import cv2 import glob import imutils CAPTCHA_IMAGE_FOLDER = "generated_captcha_images" OUTPUT_FOLDER = "extracted_letter_images" # Get a list of all the captcha images we…
Nazim Kerimbekov
  • 4,712
  • 8
  • 34
  • 58
18
votes
1 answer

How to check if point is placed inside contour?

I have drawn a contour around extreme points. Inside polygon figure I have others points. How to check if they are inside contour?
POV
  • 11,293
  • 34
  • 107
  • 201
18
votes
2 answers

Do contours returned by cv::findContours have a consistent orientation?

I am using OpenCV's cv::findContours function to extract contours in a binary image, in particular, I'm extracting a hierarchy of contours (using the CV_RETR_CCOMP flag). At some point in my further processing of those contours I need to rely on a…
Christian Rau
  • 45,360
  • 10
  • 108
  • 185
18
votes
1 answer

Plot dashed line interrupted with data (similar to contour plot)

I am stuck with a (hopefully) simple problem. My aim is to plot a dashed line interrupted with data (not only text). As I only found out to create a dashed line via linestyle = 'dashed', any help is appreciated to put the data between the…
Matthias
  • 183
  • 5
18
votes
2 answers

Get area within contours Opencv Python?

I have used an adaptive thresholding technique to create a picture like the one below: The code I used was: image = cv2.adaptiveThreshold(image, 255, cv2.ADAPTIVE_THRESH_GAUSSIAN_C, cv2.THRESH_BINARY_INV, 45, 0) Then, I use this code to get…
user1835351
  • 1,491
  • 7
  • 21
  • 30
17
votes
1 answer

Opencv match contour image

I'd like to know what would be the best strategy to compare a group of contours, in fact are edges resulting of a canny edges detection, from two pictures, in order to know which pair is more alike. I have this…
out_sid3r
  • 1,018
  • 2
  • 20
  • 42
17
votes
5 answers

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

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…
dhrumeel
  • 574
  • 1
  • 6
  • 15
17
votes
2 answers

Scatterplot Contours In Matplotlib

I have a massive scatterplot (~100,000 points) that I'm generating in matplotlib. Each point has a location in this x/y space, and I'd like to generate contours containing certain percentiles of the total number of points. Is there a function in…
astromax
  • 6,001
  • 10
  • 36
  • 47
16
votes
2 answers

Improve contour detection with OpenCV (Python)

I am trying to identify cards from a photo. I managed to do what I wanted on ideal photos, but I am now having hard time applying the same procedure with slightly different lighting, etc. So the question is about making the following contour…
anderstood
  • 342
  • 1
  • 2
  • 13
16
votes
2 answers

How to fill in the contour fully using stat_contour

I am looking for ways to fully fill in the contour generated by ggplot2's stat_contour. The current result is like this: # Generate data library(ggplot2) library(reshape2) # for melt volcano3d <- melt(volcano) names(volcano3d) <- c("x", "y", "z") v…
chengvt
  • 543
  • 3
  • 17
15
votes
1 answer

Contour graph in python

How would I make a countour grid in python using matplotlib.pyplot, where the grid is one colour where the z variable is below zero and another when z is equal to or larger than zero? I'm not very familiar with matplotlib so if anyone can give me a…
ajor
  • 1,592
  • 7
  • 22
  • 40
14
votes
1 answer

Fill the outside of contours OpenCV

I am trying to color in black the outside region of a contours using openCV and python language. Here is my code : contours, hierarchy = cv2.findContours(copy.deepcopy(img_copy),cv2.RETR_TREE,cv2.CHAIN_APPROX_SIMPLE) areas = [cv2.contourArea(c) for…
Bill
  • 143
  • 1
  • 1
  • 5