For Left side Pixel or Cell
if ( ( validCoord ( x1 , y1 - 1 , n , m ) == 1 ) && vis [ x1 ] [ y1 - 1 ] == 0 && data [ x1 ] [ y1 - 1 ] == preColor ) { Pair p = new Pair ( x1 , y1 - 1 ) ; obj . add ( p ) ; vis [ x1 ] [ y1 - 1 ] = 1 ; } }