What are Contour Levels

Hello, I have been trying to understand what the contour levels are.
Matlab docs state that the contourc function takes an argument that determines the levels of which the contours are computed upon, and I have been playing around with the parameter in hope of recognising what they really represent but I honestly cannot get a grip on that.
I will be so grateful if someone could clue me in.
Thank you all,

Answers (1)

John D'Errico
John D'Errico on 11 Oct 2018

0 votes

A contour of the function z(x,y) is a set of points in the (x,y) plane, such that z(x,y) is fixed at some constant value. That constant value is the contour "level". That set of points in the (x,y) plane is often called a level set.
contour (as well as contourc) allow you to supply specific levels if you are interested in some specific value for z, or you can just tell it a number n (an integer). In that case, contour generates n levels between the min and max of the function over the domain of interest.

2 Comments

Thank you, that was helpful.
I wanted to try that out, so I constructed a picture with 10 rectangles, each of which has a distinct depth starting from 0.1 ending up at 1.0, and I ran the contour function to see the highlighted contours according to the specified levels in the input, but the results weren't expected.
For instance, I ran the code on 0.1 contour level and the contour function produces all the contours in the picture, not only the ones with 0.1 level.
Code:
pic = zeros(500, 500);
val = 0.1;
shift = 40;
for j = 1:10
for i= 50:450
pic(shift*j,i) = val;
end
for i= 50:450
pic(shift*j+25,i) = val;
end
for i = shift*j: shift*j+25
pic(i, 50) = val;
pic(i,450) = val;
end
val = val + 0.1;
end
imshow(pic);
figure(2);
contour(pic, [0.1 0.1]);
Did I not get what you meant or am I doing something wrong here?
Thanks in advance,

Sign in to comment.

Categories

Products

Release

R2018a

Asked:

on 11 Oct 2018

Edited:

on 12 Oct 2018

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!