Ask Your Question

Revision history [back]

Since I am not a favorite of providing of the shelf solutions but rather insights on how to tackle this problem, I will try to explain how I would go ahead with this problem.

  1. Perform a grayscaling and histogram equilization of the input image.
  2. Perform a thresholding on the image, based on the background color range to retrieve a binary blob image.
  3. Since the binary image will also contain the lines on the paper (no way of avoiding lines but keeping black pills) I would perform a erosion operator on the image then a dilation to grow the pill regions back.
  4. You will now have blobs that perfectly describe regions of pills.
  5. You are now able to perform a contours finding function, resulting in the amount of pills inside the image.
  6. If preferred you could set a region of interest to the seperate pills and use a classifier to decide which kind of pill you are dealing with.