Binary image connected region labeling algorithm code