The photo was taken from front, close enough for the specimen to occupy significant portion of the frame.
Photograph in RGB format.
- convertRGB image to Lab format
- subtract background from l to correct non-uniform lighting, enhance the resulting image
- apply threshold
- perform morphological opening, remove blobs with area less than 200pixel
- mark the maximum area blob, find its centroid (C1)
- find the maximum hole in maximum area blob, find hole's centroid (C2)
- if C1 has X coordinate less than C2 then it's a right handed crab, otherwise its left handed
Test results :
The following two photos of a fiddler crab I shot near the mangrove area at Rezu Khal, Cox's Bazar was used to test the algorithm. The results are correct as can be seen from the images.
Future work :
To test the algorithm with photos taken at wide range of conditions as well as of many other species.