我需要一些帮助,任务是count these black shapes.
分割算法如下:
val=1
for x=1:no. of column
for y=1:no. of rows
if image(x,y)= 0 /* if a shape point */
segment(image, val, x, y) ;
val=val+1 ;
function segment(image, val, x, y)
image(x,y)=val ;
for i=-1:1
for j=-1:1
if image(x+i,y+j)=0 /* if a shape point */
segment(image,value,x+i,y+j)
end function
/* After the call to the function, all the pixels of the shape are marked by the values val, and by this way it is separated from the other shapes and background. These points are not tested again (they are no longer zero)
我的代码让我错了,代码是:
global image
val=1
image=imread('cell.bmp'); %load picture
%imshow(image)%show image
%size(image) %view the length and with op the picture
for x=1:no. of column
for y=1:no. of rows
if image(x,y)= 0 /* if a shape point */
segment(image, val, x, y) ;
val=val+1 ;
function segment(image, val, x, y)
image(x,y)=val ;
for i=-1:1
for j=-1:1
if image(x+i,y+j)=0 /* if a shape point */
segment(image,value,x+i,y+j)
end function
由于