A new theory is presented about subjective images. The subjective image is generated by the visual system, and is the reflection of the objective image in the brain. First, the relation between the objective grayscale and the subjective grayscale is built by visual experiment, and thus a representation of the subjective image is found. Next, a histogram matching algorithm is developed to optimize the subjective image. If it has a uniform histogram, the subjective image is assumed to be optimal. This histogram is used to derive the optimal histogram of the objective image. The objective image is then transformed such that its histogram has the optimal form. This algorithm is shown to have better visual effect than the histogram equalization.