1. A non-statutory computer-readable medium comprising executable instructions which cause a histogram stretching apparatus to perform following functions of: receiving an input image to calculate a minimum image level and a maximum image level; generating a histogram of frequencies of image levels in a first section ranging from the minimum image level to a first image level and a second section ranging from a second image level to the maximum image level; comparing the frequencies of the image levels in the first section and the second section with a reference frequency to set an extension level; and correcting the image levels of the input image according to the extension level, wherein a reference image level is added to the minimum image level to calculate the first image level and subtracted from the maximum image level to calculate the second image level, wherein each of the first section and the second section is only a portion of a total section which ranges from the minimum image level to the maximum image level.