Info
此问题已关闭。 请重新打开它进行编辑或回答。
How to smoothen a curve so I can separate 2 objects?
1 次查看(过去 30 天)
显示 更早的评论
Greetings to all.
I wish to smoothen a curve drawn in an image, so I can separate it into 2 objects.
Here is the code used to produce the curve:
THETA=linspace(0,pi,cirP);
Radii = abs( drawPoint(1,2) - cenDraw(1,2) );
[cirCoorX cirCoorY] = pol2cart(THETA,Radii);
cirCoorY = cirCoorY + cenDraw(1,1);
cirCoorX = cirCoorX + cenDraw(1,2);
cirCoor = zeros( cirP, 2 );
cirCoor(:,1) = cirCoorY;
cirCoor(:,2) = cirCoorX;
% round up the decimal to integer
cirCoor2 = cirCoor;
for i = 1 : cirP
yCoor = cirCoor2(i,1);
xCoor = cirCoor2(i,2);
yCoorUp = ceil(yCoor);
xCoorUp = ceil(xCoor);
if yCoorUp ~= yCoor
yDiff = yCoorUp - yCoor;
if yDiff >= 0.5
yCoor = ceil(yCoor);
else
yCoor = floor(yCoor);
end
end
if xCoorUp ~= xCoor
xDiff = xCoorUp - xCoor;
if xDiff >= 0.5
xCoor = ceil(xCoor);
else
xCoor = floor(xCoor);
end
end
cirCoor2(i,1) = yCoor;
cirCoor2(i,2) = xCoor;
end
%%Draw the arc
bwFil2 = bwFil;
for i = 1 : cirP
yBlack = cirCoor2(i,1);
xBlack = cirCoor2(i,2);
bwFil2(yBlack,xBlack) = 0;
% figure; imshow(bwFil2); title('bwFil2')
end
Here is the image before the curve is drawn: http://www.imgplace.com/viewimg543/1755/94beforecurve.png
As you can notice, the curve is not smooth and the bwlabel may not be able to recognise 2 separate objects properly.
Any guide is welcomed! Thanks.
0 个评论
回答(0 个)
此问题已关闭。
另请参阅
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!