计算二进制图片中的数字对象

时间:2018-03-20 20:48:47

标签: matlab image-processing

我需要一些帮助,任务是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

由于

0 个答案:

没有答案