A method comprising: generating a light pattern using a display panel; forming a virtual image from the light pattern utilizing one or more optical components, wherein the virtual image is viewable from a viewing location; receiving, by an optical sensor, external light from a real-world environment incident on the optical sensor, wherein the real-world environment is viewable from the viewing location; obtaining an image of the real-world environment from the received external light; identifying a background feature in the image of the real-world environment over which the virtual image is overlaid; extracting, from the image of the real-world environment, pixel data corresponding to the background feature, the pixel data being indicative of one or more visual characteristics of the background feature, wherein the pixel data relate to an intensity of the background features; comparing the pixel data indicative of the one or more visual characteristics to an upper threshold value and a lower threshold value; converting the extracted pixel data into an image data mask M associated with real values between and including 0 and 1; controlling the generation of the light pattern based on the comparison, comprising increasing the contrast between the virtual image and the background feature if the pixel data is higher than the upper threshold or lower than the lower threshold, wherein increasing the contrast between the virtual image and the background feature includes enhancing the virtual image to obtain an enhanced virtual image using histogram equalization and blending the virtual image with the enhanced virtual image using the image data mask M as a blending factor, wherein a blended image having an intensity I_corrected is obtained according to I_corrected x,y = M x,y * I_original x,y + 1 − M x,y * I_enhanced x,y, wherein I_enhanced(x,y) is the intensity of a pixel of the enhanced virtual image located at (x,y) and I_original(x,y) is the intensity of a pixel located at (x,y) in the virtual image. generating a light pattern using a display panel; forming a virtual image from the light pattern utilizing one or more optical components, wherein the virtual image is viewable from a viewing location; receiving, by an optical sensor, external light from a real-world environment incident on the optical sensor, wherein the real-world environment is viewable from the viewing location; obtaining an image of the real-world environment from the received external light; identifying a background feature in the image of the real-world environment over which the virtual image is overlaid; extracting, from the image of the real-world environment, pixel data corresponding to the background feature, the pixel data being indicative of one or more visual characteristics of the background feature, wherein the pixel data relate to an intensity of the background features; comparing the pixel data indicative of the one or more visual characteristics to an upper threshold value and a lower threshold value; converting the extracted pixel data into an image data mask M associated with real values between and including 0 and 1; controlling the generation of the light pattern based on the comparison, comprising increasing the contrast between the virtual image and the background feature if the pixel data is higher than the upper threshold or lower than the lower threshold, wherein increasing the contrast between the virtual image and the background feature includes enhancing the virtual image to obtain an enhanced virtual image using histogram equalization and blending the virtual image with the enhanced virtual image using the image data mask M as a blending factor, wherein a blended image having an intensity I_corrected is obtained according to I_corrected x,y = M x,y * I_original x,y + 1 − M x,y * I_enhanced x,y, wherein I_enhanced(x,y) is the intensity of a pixel of the enhanced virtual image located at (x,y) and I_original(x,y) is the intensity of a pixel located at (x,y) in the virtual image.