This paper presents a secure image encryption algorithm utilizing a 6D chaotic logistic map based on image density to encrypt gray and color images. The proposed encryption method involves calculating image density, utilizing chaos theory for key generation, and applying an XOR operation for encryption, resulting in high performance metrics such as a peak signal-to-noise ratio (PSNR) of 7.7268 and a pixel change rate (NPCR) of 100%. The method demonstrates significant advancements in secure image transmission, particularly against various cryptanalytic attacks.