【发布时间】:2012-10-04 15:00:07
【问题描述】:
在我目前正在进行的一个项目中,我必须计算图像轮廓的 5 个矩。例如,我可以使用它来获取质心。为此,我使用了 matlab:
f = imread(Is);
%Edge detection with prewitt
contourImage = edge(f,'prewitt');
% Morphological operation to close the open spaces
se = strel('disk',2);
closecontourImage = imclose(contourImage,se);
imshow(closecontourImage);
%Find the x y positions of all the nonzero elements of the edge
[row,col] = find(closecontourImage);
% 3 moments
m10= 0;
m00= 0;
m01= 0;
mu00 =0;
% Calculate the 3 moments based on the given paper
for r=1:length(row)
for c=1:length(col)
m10 = m10 + ((row(r)^1)*(col(c)^0));
m00 = m00 + ((row(r)^0)*(col(c)^0));
m01 = m01 + ((row(r)^0)*(col(c)^1));
end
end
% Calculate centroid (zwaartepunt) based on the given formulas
x = m10/m00;
y= m01/m00;
原图(png,我在matlab中使用pgm):
边缘(我假设是轮廓):
带有图像和质心的图
当我将它与内置质心计算的 matlabs 进行比较时,它非常接近。
虽然我的问题是关于面积计算。我读到第 0 时刻 = 面积。虽然我的m00和地区不一样。这是合乎逻辑的,因为第 0 时刻是所有白色像素的总和......它们仅代表图像的边缘,因此这不会导致该区域。我现在的问题是,整个图像上的轮廓矩和矩有区别吗?是否可以根据此表示中的轮廓获得区域?
在我的作业中,他们明确表示应该计算轮廓的矩,并且第一个矩等于质心(在我的算法中也不是这种情况)。但我读到的here 是一阶中心矩 = 质心。 这是否意味着轮廓矩与中心矩相同?还有一个更普遍的问题,我可以用这条边作为轮廓吗?
我觉得这些时刻非常令人困惑
【问题讨论】: