what function contourc returns

조회 수: 9 (최근 30일)
Xiaolei Hu
Xiaolei Hu 2011년 8월 10일
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?

채택된 답변

Patrick Kalita
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
Xiaolei Hu
Xiaolei Hu 2011년 8월 10일
Another question that might relate the above one is How those coordinates are double instead of integers?
Patrick Kalita
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 CenterFile Exchange에서 Contour Plots에 대해 자세히 알아보기

태그

Community Treasure Hunt

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

Start Hunting!

Translated by