In recent years, image processing has attracted a lot of attention due to its high accuracy to detect and classify objects in images. Therefore, based on the encryption algorithm, this paper adds deep learning to construct an algorithm that uses a hyperchaotic system for the region of interest image encryption and explores its security. First, we design a novel two-dimensional hyperchaotic map, and for the first time, we use a coding architecture called Bagua coding. We combine the above two points to enhance the effect of the permutation process, and consequently, the complexity of our encryption scheme. The algorithm also uses the features extraction on the plaintext and SHA-256 to generate secret key, coupled with the advanced exclusive-or operation and bit shift calculation to encrypt the plaintext. Next, we import YoloV3 and UNet for object detection and selection. Users can automatically select the region of interest on the image and use an encryption algorithm to encrypt the selected part of the irregular region. Finally, we perform security analysis on ciphertext image. The security analysis results on the generated ciphertext image validate our proposed encryption framework against statistical and differential attack.