Machine vision-based food quality evaluation systems have achieved great attention in industry and academia in recent years because of their high-throughput and non-invasive properties. In practice, the environmental illumination conditions variations would cause visual evaluation bias for both human and machine perceptions. Compared to other existing studies which take sample images and human visual grading under fixed illumination conditions, this study first investigated the environmental illumination effects on the performance of visual-based food grading for both humans and machines. Taking lettuce samples as an example, an image dataset that considered the environmental illumination variations was first established. This dataset encompasses human visual grading scores obtained from sensory panels as well. In contrast to current studies that utilize a single grader or L*a*b* color features to assess sample freshness, our study reveals a substantial impact of environmental illumination on both human perception (p<0.0001) and L*a*b* color features (p<0.0001). In order to enhance the performance of machine vision-based freshness prediction, multitask learning protocols were incorporated into the proposed new network architectures. This allowed the simultaneous prediction of both sample freshness and illumination conditions. In comparison to commonly used generic convolutional neural network models and vision transformer models, the newly proposed model exhibited superior freshness prediction performance. It minimized the prediction error by 20.36%, outperforming the generic ResNet model. This research represents the first quantitative study addressing human and machine perceptions under varied illumination conditions for food quality evaluation. The findings are anticipated to play a pivotal role in expediting the integration of machine vision applications into food engineering practices.