Hi,
You can count the total number of pixels checked by the sum of lengths of foreground_queue and background_queue. Once the sum is greater than the total number of pixels use “break” statement to break the loop.
Here is the code I have written so far, it can succesfully find the adaptive neighborhood, but I'm having trouble finding a way to make it stop once every possible pixel has been checked. Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!