Added code for region growing algorithm