what function contourc returns
2 次查看(过去 30 天)
显示 更早的评论
First of all I have to admit that I am not familiar with Matlab data structure. This is one of the reasons I am having a hard time to figure out the output of this contourc function.
Here is the code.
fm = double(imread('C:\data\01_01.bmp'));
c = contourc(fm,[.8 .8]);
01_01.bmp is a black and white image with an object in it. The returned c is 2X387 matrix. What kind of data does this matrix hold? It does not look like a sequence of pixel coordinates.
I searched the documentation, and it says that contourc is supposed to return a single contour at level 0.8 in this case. This is even more confusing. I am not familiar with this contour-at-level concept. Can someone explain what this contourc returns?
0 个评论
采纳的回答
Patrick Kalita
2011-8-10
The contour matrix that contourc returns is basically a bunch of vertices that define the contour lines. Each vertex is an (x,y) pair and they are stored as columns in the contour matrix:
x1 x2 x3 ...
y1 y2 y3 ...
Except, there are also some columns in the matrix that hold information about how many vertices the contour line has and level (e.g. 0.8) of the contour. So the contour matrix might actually look something like this:
0.8 x1 x2 x3 ...
386 y1 y2 y3
The first column says that the next 386 columns are going to contain coordinates of a line at the contour level 0.8.
This documentation section explains the structure of the matrix in a little more detail.
4 个评论
Patrick Kalita
2011-8-10
Contour lines are most often talked about in the context of functions of two variables (e.g. z = f(x,y)). A contour line is a line connecting points (x and y) on the surface that all have the same value for z.
The function can be applied to images, but it is more general than that and it relies on interpolation. That is why you get double-valued coordinates instead of integers.
More reading: http://en.wikipedia.org/wiki/Contour_line
更多回答(0 个)
另请参阅
类别
在 Help Center 和 File Exchange 中查找有关 Contour Plots 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!