Added function to output D image