Detecting and identifying objects of similar color is a challenging task in computer vision. Green peppers in a natural environment can be found using the abundant information provided by a hyperspectral camera in the spectral domain, but the hyperspectral camera is an expensive device. Therefore, we propose a novel framework called Optical Filter Net, which enables the design of an optical filter that improves the performance of green pepper segmentation by a specific red-green-blue (RGB) camera system. When installed with the optical filter, the system can efficiently utilize the spectral information in the visible wavelength to distinguish green pepper and foliage without requiring an expensive hyperspectral camera. A main finding is the similarity between the transmission curve of the optical filter and the depth-wise convolution kernel without bias. Accordingly, we can treat the transmission curve of the optical filter as one layer of a deep neural network. The whole structure can be trained in an end-to-end manner. To comply with the physical requirement of the optical filter, we further constrain the training process to achieve a non-negative and smooth transmission curve. In an experimental evaluation on our dataset, our proposed spectral-aware RGB camera system outperformed the RGB camera system without an optical filter.INDEX TERMS Optical filter, transmission curve, green pepper segmentation, deep neural network