0
Flood fill Operation in Scilab

Tried to implement floodfill algorithm using scilab but all the efforts went in vain. Also tried to find some references regarding this in various sites but none gives the right direction,since I am very new with scilab,is there an equivalent scilab function for imfill().


Scilab 20-01-16, 10:30 a.m. saraths
0
Unfortunately, the image processing toolboxes available in Scilab do not have imfill.
20-01-16, 10:53 a.m. shamika
Is there any way to implement floodfill operation in scilab

20-01-16, 10:56 a.m. saraths
I'm sure it can be implemented. Please show the code you have developed so far. If the code is too long, please use pastebin and share the link here.

20-01-16, 11:08 a.m. shamika
gr=rgb2gray(im);// im is an image whose path is not specified here
filter=fspecial('sobel');
imf = imfilter(gr, filter); // filtered image
filled=imf;
filled= flood(imf,1,1,0,255);//function call
imshow(filled);

// function for flood fill
function[filled]=flood(imf,x,y,fill_col,old_col)
if(imf(y,x)=old_col)
filled(y,x)=fill_col;
end
flood(imf,x+1,y,fill_col,old_col);
flood(imf,x-1,y,fill_col,old_col);
flood(imf,x,y+1,fill_col,old_col);
flood(imf,x,y-1,fill_col,old_col);
endfunction



20-01-16, 2:12 p.m. saraths
The lines

if(imf(y,x)=old_col)
filled(y,x)=fill_col;
end

should be

if(imf(x,y)=old_col)
filled(x,y)=fill_col;
end

Please let me know if it works.

22-01-16, 11:21 a.m. shamika
Its showing this error
!--error 21 
Invalid index.
at line       2 of function flood called by :  
at line       5 of function flood called by :

22-01-16, 2:56 p.m. saraths
Your syntax is wrong. Please look up the correct syntax for if statement. You are getting this error as the code is trying to access an index value that is larger or smaller than the matrix size.

27-01-16, 3:11 p.m. shamika

Login to add comment


Log-in to answer to this question.