0

I need some help , the task is to count these black shapes.

The algorithm for segmentation is as follows:

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)

My code make me an error , the code is :

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

Thanks

bla
  • 25,846
  • 10
  • 70
  • 101

0 Answers0