Joseph : Yes. You can look at the Euler Number of the object. This is returned from regionprops() in the image processing toolbox. Basically the process is this (for almost all image processing applications: 1. threshold image to binarize it 2. connected components labeling, using bwlabel() or bwconncomp() 3. regionprops(), to make the measurements
Here is the definition of Euler Number: 'EulerNumber' ? Scalar that specifies the number of objects in the region minus the number of holes in those objects. This property is supported only for 2-D input label matrices. regionprops uses 8- connectivity to compute the EulerNumber measurement.