I'm using HSV histogram bins to find the overlap between two images, one which has a hand holding an object, the other of a hand not holding an object. With the bins, I end up with a list (after using logical AND) something like this:
[False, False, False, True, True, True, True,..., True, True, False, True, False, False, False,... False, True, False, True, False,..., False]
With this I can find the saturation of the hand. The long sequence of "True" refers to the saturation bins in which the hand skin color exists. However, there is noise towards the end and trailing parts of this list.
I want to find the first and last index of the long list of "True" in the middle. The noise should be avoided. Is there any way to do this built in to numpy or python lists, or do I need to write an algo myself?