In our previous study, we found three requirements for digital watermarking. The first is that to prevent watermark information of an image from being diverted to other images, this information must be generated based on the original image. The second is that after the original image is modified/edited, it should still be able to be used the same as the original image. The third is that multiple digital watermarks should be stored and managed without relying on trusted third parties. To meet these requirements, we proposed a digital-copyright-management system based on perceptual hashing and blockchain. However, because we used conventional perceptual hashing in that study, we could not draw sufficient conclusions about the first and second requirements. In this current study, to obtain a stable message digest, we propose a method of improving perceptual hashing based on machine learning. With this method, an image is first modified/edited using various methods to generate an image set. This image set is then input into a convolutional neural network (CNN) to calculate the features of the images, and the data of the CNN intermediate layer are output as machine learning data. Finally, through machine learning, latent stochastic variables are determined that can be used to calculate latent image features, and the perceptual hash value of this image set is calculated using these image features for the blockchain and digital watermarking. The method also records these latent stochastic variables on the blockchain to ensure copyright security by ensuring that these variables cannot be used by those other than the original author.