I have pictures from a microscope and I am trying to count the total number of crystal as well as those with specific colors (red, blue or yellow). In principle it looks possible to do it just by looking at the picture but considering I have to do it for over 200, I believe a script would be more effective.
My first approach was to follow the suggestions of a very similar problem (Finding number of colored shapes from picture using Python )however, my issue is that the crystal color and the background color (an alcohol solution) are almost the same (transparent), and therefore it has been impossible to get any successful result so far.
I have also checked the "skimage" module (http://scikit-image.org/) but I got the same issues with the crystal/background.
With the following code I can got something that start making sense, but it is still far from my objective:
import scipy
from scipy import ndimage
sand = scipy.misc.imread(img) # gray-scale image
sandf = ndimage.gaussian_filter(sand, 16)
T = 160 # set threshold by hand to avoid installing `mahotas`
# find connected components
#labeled, nr_objects = ndimage.label(sandf> T) #black-white
labeled, nr_objects = ndimage.label(sandf[:,:,0] > T) #colour
print ("Number of objects is %d " % nr_objects)
import matplotlib.pyplot as plt
plt.imshow(labeled)
plt.show()
I will really appreciate if anyone can give me a hand with this. I have tried even modifying the way I take the pictures but nothing. Again, I have two objectives: count the total number of particles and then count those particles that have a tint (red, blue or yellow)
Please find below one typical picture: