An Algorithm for Detecting Handedness of Fiddler Crabs

Aug 7, 2016

This came out of some experiments I did around 2011 on image processing.

Members of the genus Uca are generally known as Fiddler crabs for the overgrown claw of the males. The following algorithm detects a male fiddler crabs handedness from a photograph. The algorithm was implemented using Matlab R2009a.


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
  • dilate
  • erode
  • 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 above 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

  • Test the algorithm with photos taken at wide range of conditions and environments
  • Test with other species in the Uca genus