This paper studies the possibility of classifying coffee beans by using their features of color, shape and size. The process of acquiring the images were done in controlled lighting conditions. Based on segmented images, color, shape and size provide information about the physical alteration in green coffee beans, during the growing and drying process that affect the flavor and taste of the drink by Developing a computer program to sort coffee beans by types In the case of color images are analyzed in RGB space, which were preprocessor in order to reduce noise and separate from the background and enhance its features. The location was used for an algorithm for identifying and setting contours ellipse, an algorithm Mahalanobis distance classifier, an algorithm called Flood of growth, for the segmentation of those defective grains. The emergence of methods that take advantage of technological advances is an option whose benefits encourage the study of new possibilities. The classification of coffee beans throughout the analysis of images is a very promising because it is a minimally invasive method and the exposure of the grains are not visible to look deteriorates significantly. Many farmers sort their coffee beans by hand but only a few thousand dollars invested in a automatic sorting optical machine such us Sortex or Xeltron. In this paper we develop algorithms based on image processing techniques for the classification of defective beans.