The identification and extraction (i.e., segmentation) of geometrical features is crucial in many tasks requiring image analysis. We present a method for the optical segmentation of features of interest from an edge enhanced image. The proposed method is based on the nonlinear filtering (implemented by the use of a spatial light modulator) of the generalized optical Hough transform and is capable of discriminating features by shape and by size. The robustness of the method against noise in the input, low contrast, or overlapping of geometrical features is assessed, and experimental validation of the working principle is presented.