A medical image encryption algorithm based on a region of interest
Patent Information
- Application Number
- CN202310653201.0
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2023-06-05
- Publication Date
- 2026-09-04
- Estimated Expiration
- 2043-06-05
AI Technical Summary
图像分割算法通过最优分割阈值选择医学图像中的感兴趣区域,图像加密算法选取了两个四维的超混沌系统,它们能够提供随机且均匀分布的混沌序列,综合了以上算法的医学图像处理方法,降低了医学图像分割和加密过程中的计算复杂度和时间开销,增强了图像中隐私信息的安全性,以解决现有医学图像感兴趣区域的分割和加密技术不够成熟的技术问题
[0084]1.本发明针对所需要选择的医学图像,为了获取感兴趣区域,选择使用结合大津阈值分割法改进的遗传算法分割出感兴趣区域和非感兴趣区域;
Smart Images

Figure CN116680712B_ABST
Abstract
Description
Technical Field
[0001] This invention belongs to the field of digital image encryption technology, and relates to a medical image encryption algorithm based on region of interest. Background Technology
[0002] With the development of computer networks and the emergence of digital medical equipment, medical images have become an important method of diagnosis and treatment in hospitals and clinics. Medical images can clearly reflect the detailed composition of the human body's internal structures. However, medical images often carry some patient privacy and medical information, such as personal identification information and images of body parts. Furthermore, with the development of telemedicine technology, the probability of digitized medical images being stored and transmitted through public networks is increasing. Therefore, the security of medical images has become a concern.
[0003] Traditional image encryption algorithms mainly fall into two categories: full-image encryption, which encrypts the entire image, and selective image encryption, which encrypts only a portion of the image. Typically, only a portion of an image is meaningful; this portion is called the region of interest (ROI), and the privacy information within this region needs to be encrypted and protected by the algorithm. Compared to full-image encryption, ROI-based image encryption can better conserve computational resources and improve encryption / decryption speed.
[0004] Although encryption of medical images targeting regions of interest can improve efficiency, there are still some problems to be solved: (1) Image segmentation technology is very mature, but segmentation technology for medical images is still lacking, especially for region of interest image segmentation technology with privacy information in medical images; (2) Hyperchaotic systems are increasingly being used in image encryption algorithms due to their good randomness and simplicity, but how to select a suitable hyperchaotic system for encrypting regions of interest and design a corresponding image encryption algorithm is still a pain point. Summary of the Invention
[0005] To address the aforementioned problems, this invention provides a medical image processing method that combines a medical image segmentation algorithm based on Otsu's thresholding method and a medical image encryption algorithm based on hyperchaotic systems. The image segmentation algorithm selects the region of interest (ROI) in the medical image using an optimal segmentation threshold, while the image encryption algorithm selects two four-dimensional hyperchaotic systems that can provide random and uniformly distributed chaotic sequences. This combined approach reduces the computational complexity and time overhead in both medical image segmentation and encryption processes, while enhancing the security of privacy information in the image. This addresses the technical problem of the immaturity of existing medical image ROI segmentation and encryption technologies.
[0006] Therefore, the present invention adopts the following technical solution:
[0007] A medical image encryption algorithm based on region of interest includes performing the following steps sequentially: (1) image segmentation, (2) coordinate extraction of the region of interest, and (3) image encryption using a hyperchaotic system, wherein:
[0008] Step (1) image segmentation uses a genetic algorithm optimized based on the Otsu thresholding method to determine the optimal segmentation threshold for image segmentation, thereby performing binary segmentation of the image and marking the regions of interest and non-interest regions in the image, including the following steps:
[0009] Step 1a: Input a plaintext image P0 of size M×N, convert the plaintext image P0 into a grayscale image P1 of size M×N, and convert the pixel value corresponding to each pixel in the grayscale image P1 into an 8-bit binary value.
[0010] Step 1b: Set the generation counter t=0, set the maximum generation T, and randomly generate the initial population G(t), that is, randomly select G different binary values from the grayscale image P1 in step 1a to form the population G(t);
[0011] Step 1c: Calculate the fitness s of each individual in the population G(t) using the Otsu thresholding method. i 2 , i∈[1,G];
[0012] Step 1d: Calculate the fitness s of each individual based on the fitness s obtained in Step 1c. i 2 Then, the selection, crossover, and mutation operations are performed sequentially to obtain the next generation population G(t+1);
[0013] Step 1e: To find the optimal individual g, repeat steps 1c and 1d until t = T, then terminate the loop and select the individual with the highest fitness in the population G(t) during the evolution process as the optimal individual g for output.
[0014] Step 1f: Take the binary value corresponding to the best individual g obtained in step 1e as the optimal segmentation threshold T'. Following the method in step 1c, starting from the binary value corresponding to the first pixel in the grayscale image P1, compare it with the optimal segmentation threshold T' in turn until the last binary value in the grayscale image P1 is compared.
[0015] If the binary value corresponding to a pixel is greater than or equal to the optimal segmentation threshold T', it is considered a region of interest, and the pixel value is marked as 255; if the binary value corresponding to a pixel is less than the optimal segmentation threshold T', it is considered a region of non-interest, and the pixel value is marked as 0. The final output segmentation result is a binary image P' of size M×N. The conversion formula for the binary image P' is as follows:
[0016]
[0017] Where P1(x,y) represents the pixel value at coordinates (x,y) in the grayscale image P1, and P'(x,y) represents the pixel value at coordinates (x,y) in the binary image P'.
[0018] Furthermore, step (2) of extracting the region of interest by coordinates includes the following steps:
[0019] Step 2a: Input a plaintext image P0 of size M×N and a binary image P' of size M×N. Starting from the first pixel of the binary image P', scan the first row of pixels from left to right along the x-axis, with the y-axis as the main axis. Then, starting from the second row, continue scanning until the first pixel A with a pixel value of 255 is found, and its coordinates are recorded as (xa, ya).
[0020] Step 2b: Starting from the first pixel of the binary image P', scan the first column of pixels from top to bottom along the y-axis, with the x-axis as the main axis. Then scan from the second column onwards until the first pixel B with a pixel value of 255 is found, and its coordinates are recorded as (xb, yb).
[0021] Step 2c: Starting from the last pixel of the binary image P', scan the last row of pixels from right to left along the x-axis, with the y-axis as the main axis. Then, starting from the second to last row, scan sequentially until the first pixel C with a value of 255 is found, and its coordinates are recorded as (xc, yc).
[0022] Step 2d: Starting from the last pixel of the binary image P', scan the last column of pixels from bottom to top along the y-axis, with the x-axis as the main axis. Then, starting from the second to last column, scan sequentially until the first pixel D with a pixel value of 255 is found, and record its coordinates as (xd, yd).
[0023] Step 2e: Map the four coordinate points A, B, C, D = {(xb, ya), (xd, ya), (xb, yc), (xd, yc)} to the plaintext image P0. Segment the rectangular image obtained by connecting the coordinates of the four points A, B, C, and D in the plaintext image P0, and output it as the final region of interest image P0'. The image remaining after removing the region of interest image P0' from the plaintext image P0 is output as the non-region of interest image P1'.
[0024] Furthermore, step (3) of image encryption using a hyperchaotic system includes the following steps:
[0025] Step 3a: Input the region of interest image P0' and the non-region of interest image P1' obtained in step 2e, input a randomly selected external key K of length 256 bits, and calculate the total number of pixels L in the region of interest image P0'. The calculation formula is as follows:
[0026] L=(ya-yc)×(xd-xb)
[0027] Step 3b: Use two four-dimensional hyperchaotic systems to generate eight chaotic sequences for image encryption;
[0028] The first equation for a four-dimensional hyperchaotic system is as follows:
[0029]
[0030] The equation for the second four-dimensional hyperchaotic system is as follows:
[0031]
[0032] The equation is solved using the fourth-order Runge-Kutta method. The solution process is as follows:
[0033] Step 3b1. Determine the parameter values of the equation system: By calculating the Lyapunov exponents of the equation system, determine the parameter values of the above two equation systems: a = 36, b = 3, c = 28, d = -16, k = 0.2, p = 35, q = 8 / 3, r = 55, s = 1.3;
[0034] Step 3b2. Determine the initial values for the fourth-order Runge-Kutta method: Divide the 256-bit external key K into a 32-bit session key K. i , i∈[1,8], then for each session key K i Then divide it into 4-byte block keys K ij j∈[1,4], each block key K ij The length is 8 bits, according to K ij Calculate sequence Q i , i∈[1,8]:
[0035] K s =mod(∑K) ij ,256)
[0036] Q i1 =K i1 ⊕K (9-i)4 ⊕K s
[0037] Q i2 =K i2 ⊕K (9-i)3 ⊕K s
[0038] Q i3 =K i3 ⊕K (9-i)2 ⊕K s
[0039] Q i4 =K i4 ⊕K (9-i)1 ⊕K s
[0040] Q i =bi2de(Q i1 )×10 9 +bi2de(Q i2 )×10 6 +bi2de(Q i3 )×10 3 +bi2de(Q i4 )
[0041] The function bi2de(x) converts the binary value x to a decimal value.
[0042] Finally, solve the initial condition x of the system of equations. i0 The calculation results are as follows:
[0043]
[0044] Step 3b3. Calculate the chaotic sequence: Set the initial condition x i0 In the fourth-order Runge-Kutta method, the step size Step = 0.001 and the number of iterations L are set. The number of iterations L is the total number of pixels in the region of interest image P0'. After the iterations, eight floating-point chaotic sequences x of length L' are obtained. ij ', i∈[1,8], j∈[1,L'], the length L' is the same as the number of iterations L;
[0045] Step 3b4. Integerize the floating-point chaotic sequence x ij ': The floating-point chaotic sequence x in step 3b3 ij The chaotic sequence x, which is of integer type, is obtained by calculating and transforming it using the following formula. ij :
[0046] x ij =floor(mod(x) i ' j ×10 14 ,256))
[0047] Here, floor(x) means returning a value less than or equal to x;
[0048] Step 3b3 yields eight integer chaotic sequences {x} of length L'. 1j x2j x 3j x 4j x 5j x 6j x 7j x 8j The output is an integer chaotic sequence x. ij , i∈[1,8], j∈[1,L'];
[0049] Step 3c: Convert the matrices R, G, and B for each color channel of the region of interest image into one-dimensional vectors:
[0050] R = {r1, r2, ..., r} L’}
[0051] G = {g1, g2, ..., g} L’}
[0052] B = {b1, b2, ..., b} L’}
[0053] And calculate the sum of the matrix pixels of all color channels, sum.image, according to the following formula:
[0054]
[0055] Where L is the total number of pixels in the region of interest image P0' in step 3a;
[0056] Step 3d: Define the three color channel matrices of the encrypted image C' of the region of interest as CR = {cr1, cr2, ..., cr2}. L}, CG={cg1,cg2,...,cg L}, CB={cb1,cb2,...,cb L} Calculate auxiliary encrypted pixels cr0, cg0, and cb0 to aid in calculating the value of the first encrypted pixel:
[0057] a = sum.image - (r1 + g1 + b1)
[0058]
[0059] Step 3e: Because step 3b generated a total of 8 integer chaotic sequences {x} of length L. 1j x 2j x 3j x 4j x 5j x 6j x 7j x 8jDuring the encryption process, only six chaotic sequences need to be selected to encrypt the three matrices R, G, and B. Therefore, different combinations will occur depending on the chaotic sequences used. Eight different combinations were defined and labeled with sequence numbers 0 to 7. The calculation is performed using the following steps:
[0060] sum.image = sum.image - (r i +g i +b i )
[0061]
[0062] in, when If the sequence number is equal to the combination method, then the six chaotic sequence values corresponding to that combination are used to encrypt the current pixel to be encrypted.
[0063] Step 3f: Set i = 1, and start from the i-th pixel (r) to be encrypted in the region of interest image P0'. i g i b i Begin by calculating the serial number according to step 3e. Obtain the corresponding chaotic sequence combination method, and extract the i-th chaotic sequence value {Key1_r} from the 6 chaotic sequences. i Key2_r i Key1_g i Key2_g i Key1_b i Key2_b i} as the pixel to be encrypted (r i g i b i The key stream of ) is introduced, and the (i-1)th encrypted pixel (cr) is also introduced. i-1 ,cg i-1 cb i-1 Perform an XOR operation to obtain the i-th encrypted pixel (cr). i ,cg i cb i The calculation formula is as follows:
[0064] cr i =bitxor(r) i ,bitxor(mod(cr i-1 +Key1_r i ,256)Key2_r i ))
[0065] cg i=bitxor(g i bitxor(mod(cg) i-1 +Key1_g i ,256)Key2_g i ))
[0066] cb i =bitxor(b i bitxor(mod(cb) i-1 +Key1_b i ,256)Key2_b i ))
[0067] When i = 1, the (i-1)th encrypted pixel is the initial value (cr0, cg0, cb0) in step 3d;
[0068] Step 3g: Let i = i + 1, and repeat steps 3e, 3f, and 3g until i = L, to obtain the complete one-dimensional encrypted array CR = {cr1, cr2, ..., cr L}, CG={cg1, cg2,..., cg L}, CB={cb1,cb2,...,cb L Finally, the encrypted image of the region of interest is obtained as C' = reshape(CR, CG, CB). The function reshape(x, y, z) transforms the specified matrices x, y, z into an image matrix of a specific dimension to output the complete image.
[0069] Step 3h: Merge the encrypted region of interest image C' and the non-region of interest image P1' to obtain and output the complete encrypted region of interest image C.
[0070] Furthermore, in step 1c, the fitness s i 2 The calculation process includes:
[0071] Input grayscale image P1 and the binary value g corresponding to the currently selected individual. i Let i∈[1,G], and let g be... i As the segmentation threshold, starting from the binary value corresponding to the first pixel in the grayscale image P1, it is sequentially compared with the segmentation threshold g. i The comparison continues until the last binary value in the grayscale image P1 has been compared. If the binary value corresponding to a pixel is greater than or equal to the segmentation threshold g, then... i If the binary value corresponding to a pixel is less than the segmentation threshold g, then it belongs to the region of interest. i If the region is not of interest, then it is recorded as a region of non-interest.
[0072] Count the number of pixels belonging to the region of interest (ROI) N0 and the number of pixels not belonging to the ROI N1. Calculate the proportion ω0 of the ROI N0 to the total number of pixels N2 in the image, the proportion ω1 of the ROI N1 to the total number of pixels N2 in the image, the average gray value μ0 of the ROI, the average gray value μ1 of the ROI, the overall average gray value μ, and the inter-class variance s. 2 Inter-class variances 2 In a genetic algorithm, this is the binary value g corresponding to the currently selected individual. i The fitness of;
[0073] The number of pixels in the region of interest (N0), the number of pixels in the non-region of interest (N1), and the total number of pixels in the image (N2) satisfy the following calculation formula:
[0074] N2 = N0 + N1 = M × N
[0075] Where M is the length of the input grayscale image P1 and N is the width of the input grayscale image P1;
[0076] ω0, ω1, μ0, μ1, μ, s 2 The calculation formula is as follows:
[0077]
[0078]
[0079] ω0+ω1=1
[0080] μ=ω0*μ0+ω1*μ1
[0081] s 2 =ω0ω1(μ0-μ1) 2
[0082] The inter-class variance of each individual in population G, i.e., the fitness of each individual, is calculated using the Otsu threshold segmentation method described above, and is denoted as s. i 2 , i∈[1,G].
[0083] The beneficial effects of this invention are as follows:
[0084] 1. In order to obtain the region of interest from the medical image to be selected, this invention uses a genetic algorithm that combines the Otsu thresholding method to segment the region of interest and the non-region of interest.
[0085] 2. In order to achieve a solution with high performance, high speed and high security for the encryption part, this invention determines to use two four-dimensional hyperchaotic systems to generate chaotic sequences, reduce the number of rounds of scrambling and diffusion, and introduce an external key to generate the initial value for solving the hyperchaotic system, thereby increasing the randomness of the generation of chaotic sequences;
[0086] 3. This invention designs eight combination tables for the use of chaotic sequences, calculates the chaotic sequence usage scheme corresponding to different pixels, and introduces the pixel value of the original input image and the encrypted value of the previous pixel for XOR calculation to enhance the degree of scrambling and diffusion. Attached Figure Description
[0087] Figure 1 This is a schematic diagram of the structural framework of the present invention;
[0088] Figure 2 This is the original CT image of the lungs in Embodiment 1 of the present invention;
[0089] Figure 3 This is a diagram of the genetic algorithm framework optimized using the Otsu threshold segmentation method in this invention.
[0090] Figure 4 This is a binary image obtained after image segmentation of a lung CT image in Embodiment 1 of the present invention;
[0091] Figure 5 This is a coordinate map of the region of interest in a lung CT image in Embodiment 1 of the present invention;
[0092] Figure 6 This is a combination table of encryption schemes selected during the scrambling and diffusion process of the present invention;
[0093] Figure 7 This is a region-of-interest (ROI) image from a lung CT scan in Embodiment 1 of the present invention.
[0094] Figure 8 This is a comparison chart of the PSNR values of the lung CT scan in Embodiment 1 of the present invention with those of five other sets of images;
[0095] Figure 9 This is a comparison chart of the NPGR and UACI values of lung CT scans in Embodiment 1 of the present invention with those of five other sets of images. Detailed Implementation
[0096] The technical solution of the present invention will be described below with reference to the accompanying drawings and implementation methods.
[0097] like Figure 1 As shown, a medical image encryption algorithm based on region of interest includes performing the following steps sequentially: (1) image segmentation, (2) coordinate extraction of the region of interest, and (3) image encryption using a hyperchaotic system, wherein:
[0098] The image segmentation step uses a genetic algorithm optimized based on Otsu's thresholding method to determine the optimal segmentation threshold, thereby performing binary segmentation of the image and marking regions of interest and non-regions of interest. The steps include:
[0099] Step 1a: As Figure 2 As shown, a plain text lung CT image P0 is obtained, with a size of 424×355 pixels. Image P0 is converted into a grayscale image P1 with a size of 424×355 pixels. The pixel value corresponding to each pixel in the grayscale image P1 is converted into an 8-bit binary value, where 00000000 represents black, 11111111 represents white, and other binary values represent different grayscale values.
[0100] Step 1b: Set the generation counter t = 0, set the maximum generation T = 100, and randomly select G = 10 different binary values from the grayscale image P1 in Step 1a to form the initial population G(t) = {11000011, 01010101, 11110001, 01101001, 10000101, 11011010, 1000100, 01010011, 01101000, 10111111};
[0101] Step 1c: As Figure 3 As shown, the Otsu thresholding method is used to optimize the genetic algorithm. The optimized genetic algorithm uses the Otsu thresholding method to calculate the fitness of individuals when determining the optimal splitting threshold; specifically, the Otsu thresholding method is used to calculate the fitness s of each individual in the population G(t). i 2 The calculation steps are as follows: i∈[1,10]
[0102] Input grayscale image P1 and the binary value g corresponding to the currently selected individual. i Let i∈[1, 10], and let g i As the segmentation threshold, starting from the binary value corresponding to the first pixel in the grayscale image P1, it is sequentially compared with the segmentation threshold g. i The comparison continues until the last binary value in the grayscale image P1 has been compared. If the binary value corresponding to a pixel is greater than or equal to the segmentation threshold g, then... i If the binary value corresponding to a pixel is less than the segmentation threshold g, then it belongs to the region of interest. i If the region is not of interest, then it is recorded as a region of non-interest.
[0103] Count the number of pixels belonging to the region of interest (ROI) N0 and the number of pixels not belonging to the ROI N1. Calculate the proportion ω0 of the ROI N0 to the total number of pixels N2 in the image, the proportion ω1 of the ROI N1 to the total number of pixels N2 in the image, the average gray value μ0 of the ROI, the average gray value μ1 of the ROI, the overall average gray value μ, and the inter-class variance s. 2 Inter-class variances 2 In a genetic algorithm, this is the binary value g corresponding to the currently selected individual. i The fitness of;
[0104] The number of pixels in the region of interest (N0), the number of pixels in the non-region of interest (N1), and the total number of pixels in the image (N2) satisfy the following calculation formula:
[0105] N2 = N0 + N1 = M × N
[0106] Where M is the length of the input grayscale image P1 (424) and N is the width of the input grayscale image P1 (355), we can obtain ω0, ω1, μ0, μ1, μ, s 2 The calculation formula is as follows:
[0107]
[0108]
[0109] ω0+ω1=1
[0110] μ=ω0*μ0+ω1*μ1
[0111] s 2 =ω0ω1(μ0-μ1) 2
[0112] The inter-class variance of each individual in population G, i.e., the fitness of each individual, is calculated using the Otsu threshold segmentation method described above, and is denoted as s. i 2 , i∈[1,10];
[0113] Step 1d: Calculate the fitness s of each individual based on the fitness s obtained in Step 1c. i 2 The selection, crossover, and mutation operations are performed sequentially to obtain the next generation population G(t+1), specifically:
[0114] Selection operation: Set the retention rate r1 = 0.2, the random selection probability r2 = 0.5, and the calculated fitness value s i 2Sort the chromosomes from largest to smallest and select those with high fitness. The percentage of such chromosomes is selected as the survival rate r1. Then, random selection is performed to select individuals with low fitness who have survived. The random selection probability is r2.
[0115] Crossover: Due to the disappearance of surviving chromosomes, the total population decreases. To ensure the total population remains unchanged, the required number of offspring needs to be calculated, and then a crossover point is randomly selected for reproduction. Offspring will inherit the genes from the father before the crossover point and the genes from the mother after the crossover point (including the crossover point). The newly born offspring will eventually be added to the surviving parents to form a new generation of the population.
[0116] Mutation operation: Set the gene mutation probability r3 = 0.1. For the new generation population generated by the crossbreeding operation, randomly select individuals with a proportion of r3 in the population and change the second, fourth and eighth bit values of the selected individuals.
[0117] Since selection, crossover, and mutation operations are common steps in genetic algorithms for those skilled in the art, they will not be described in detail here.
[0118] Step 1e: Perform multiple iterations, repeating steps 1c and 1d until t = 100, then terminate the loop and select the individual with the highest fitness in the population G(t) during the evolution process as the optimal individual g for output.
[0119] Step 1f: Take the binary value corresponding to the best individual g obtained in step 1e as the optimal segmentation threshold T' = 72. Following the method in step 1c, starting from the binary value corresponding to the first pixel in the grayscale image P1, compare it with the optimal segmentation threshold T' in turn until the last binary value in the grayscale image P1 is compared.
[0120] If the binary value corresponding to a pixel is greater than or equal to the optimal segmentation threshold T', it is considered a region of interest, and the pixel value is marked as 255; if the binary value corresponding to a pixel is less than the optimal segmentation threshold T', it is considered a region of non-interest, and the pixel value is marked as 0. Figure 4 As shown, the final output segmentation result is a binary image P' with a size of 424×355 pixels;
[0121] The formula for transforming a binary image P' is as follows:
[0122]
[0123] Where P1(x,y) represents the pixel value at coordinates (x,y) in the grayscale image P1, and P'(x,y) represents the pixel value at coordinates (x,y) in the binary image P'.
[0124] Step 2: Extract the region of interest using coordinates. Specifically, use the XY-axis scanning method to extract the position of the smallest rectangular image containing the region of interest in the plain text lung CT image P0. That is, it is necessary to determine the coordinates of the four vertices of the rectangular region, including the following steps:
[0125] Step 2a: Input a plaintext image P0 with a size of 424×355 pixels and a binary image P' with a size of M×N. Starting from the first pixel of the binary image P', scan the first row of pixels from left to right along the x-axis, with the y-axis as the main axis. Then, starting from the second row, continue scanning until the first pixel A with a pixel value of 255 is found, and its coordinates are recorded as (xa, ya) = (46, 267).
[0126] Step 2b: Starting from the first pixel of the binary image P', scan the first column of pixels from top to bottom along the y-axis, with the x-axis as the main axis. Then scan from the second column onwards until the first pixel B with a pixel value of 255 is found, and its coordinates are recorded as (xb, yb) = (168, 15).
[0127] Step 2c: Starting from the last pixel of the binary image P', scan the last row of pixels from right to left along the x-axis, with the y-axis as the main axis. Then, starting from the second to last row, scan sequentially until the first pixel C with a pixel value of 255 is found, and record its coordinates as (xc, yc) = (283, 182).
[0128] Step 2d: Starting from the last pixel of the binary image P', scan the last column of pixels from bottom to top along the y-axis, with the x-axis as the main axis. Then, starting from the second to last column, scan sequentially until the first pixel D with a pixel value of 255 is found, and record its coordinates as (xd, yd) = (157, 398).
[0129] Step 2e: Map the four coordinate points A, B, C, D = {(xb, ya), (xd, ya), (xb, yc), (xd, yc)} to the plaintext lung CT image P0. Segment the rectangular image obtained by connecting the coordinates of points A, B, C, and D in the plaintext lung CT image P0, and output it as the final region of interest image P0', as shown. Figure 5 As shown, the image of the lung CT image P0 after removing the region of interest image P0' is output as the non-region of interest image P1'.
[0130] Step 3: Encrypt the region of interest using a hyperchaotic system, specifically including the following steps:
[0131] Step 3a: Input the region of interest image P0' and the non-region of interest image P1' obtained in step 2e, and input a randomly selected external key K = {1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32} of length 256. Calculate the total number of pixels L in the region of interest image P0' using the following formula:
[0132] L=(ya-yc)×(xd-xb)
[0133] The calculation here yields L = 91392;
[0134] Step 3b: Use two four-dimensional hyperchaotic systems to generate eight chaotic sequences for image encryption.
[0135] The first equation for a four-dimensional hyperchaotic system is as follows:
[0136]
[0137] The equation for the second four-dimensional hyperchaotic system is as follows:
[0138]
[0139] The equations are solved using the fourth-order Runge-Kutta method. The solution process is as follows:
[0140] Step 3b1: Determine the parameter values of the equation system: By calculating the Lyapunov exponents of the equation system, determine the parameter values of the above two equation systems: a = 36, b = 3, c = 28, d = -16, k = 0.2, p = 35, q = 8 / 3, r = 55, s = 1.3;
[0141] Step 3b2: Determine the initial values for the fourth-order Runge-Kutta method: Divide the 256-bit external key K into a 32-bit session key K. i , i∈[1,8], then for each session key K i Then divide it into 4-byte block keys K ij j∈[1,4], each block key K ij The length is 8 bits, according to K ij Calculate sequence Q i , i∈[1,8]:
[0142] K s =mod(∑K) ij ,256)
[0143] Q i1 =K i1⊕K (9-i)4 ⊕K s
[0144] Q i2 =K i2 ⊕K (9-i)3 ⊕K s
[0145] Q i3 =K i3 ⊕K (9-i)2 ⊕K s
[0146] Q i4 =K i4 ⊕K (9-i)1 ⊕K s
[0147] Q i =bi2de(Q i1 )×10 9 +bi2de(Q i2 )×10 6 +bi2de(Q i3 )×10 3 +bi2de(Q i4 )
[0148] Q is calculated here. i ={4.9013×10 10 0.9013×10 10 0.1013×10 10 0.9013×10 10 1.7013×10 10 0.9013×10 10 0.1013×10 10 0.9013×10 10};
[0149] The function bi2de(x) converts the binary value x to a decimal value.
[0150] Finally, solve the initial condition x of the system of equations. i0 The calculation results are as follows:
[0151]
[0152] Substitute Q i Using the value of L from step 3a, x is calculated. i0 ={5.8681, 1.0791, 0.1213, 1.0791, 2.0369, 1.0791, 0.1213, 1.0791};
[0153] Step 3b3: Calculate the chaotic sequence: Set the initial condition x i0 In the fourth-order Runge-Kutta method, the step size Step = 0.001 and the number of iterations L = 91392 are set to the total number of pixels in the region of interest image P0'. After the iterations, eight floating-point chaotic sequences x of length L' are obtained. ij ', i∈[1,8], j∈[1,L'], the length L' is the same as the number of iterations L;
[0154] Step 3b4: Integerize the floating-point chaotic sequence x ij ': The floating-point chaotic sequence x in step 3b3 ij The chaotic sequence x, which is of integer type, is obtained by calculating and transforming it using the following formula. ij :
[0155] x ij =floor(mod(x) i ' j ×10 14 ,256))
[0156] Here, floor(x) means returning a value less than or equal to x;
[0157] Based on the eight integer chaotic sequences {x} of length L' obtained in step 3b3 1j x 2j x 3j x 4j x 5j x 6j x 7j x 8j The output is an integer chaotic sequence x. ij , i∈[1,8], j∈[1,L'];
[0158] Step 3c: Convert the matrices R, G, and B for each color channel of the region of interest image into one-dimensional vectors:
[0159] R = {r1, r2, ..., r} L’}
[0160] G = {g1, g2, ..., g} L’}
[0161] B = {b1, b2, ..., b} L’}
[0162] And calculate the sum of the matrix pixels of all color channels, sum.image, according to the following formula:
[0163]
[0164] Where L = 91392, the calculated sum.image = 79707;
[0165] Step 3d: Define the three color channel matrices of the encrypted image C' of the region of interest as CR = {cr1, cr2, ..., cr2}. L}, CG={cg1,cg2,...,cg L}, CB={cb1,cb2,...,cb L} Calculate auxiliary encrypted pixels cr0, cg0, and cb0 to aid in calculating the value of the first encrypted pixel:
[0166] a = sum.image - (r1 + g1 + b1)
[0167]
[0168] The calculation here yields cr0 = cg0 = cb0 = 212;
[0169] Step 3e: Because step 3b generated a total of 8 integer chaotic sequences {x} of length L. 1j x 2j x 3j x 4j x 5j x 6j x 7j x 8j During the encryption process, only six chaotic sequences need to be selected to encrypt the three matrices R, G, and B. Therefore, different combinations will be generated based on the different chaotic sequences used. Eight different combination methods have been defined, such as... Figure 6 As shown, these 8 methods are labeled with serial numbers 0 to 7 respectively, and the serial numbers are set. Calculated using the following steps:
[0170] sum.image = sum.image - (r i +g i +b i )
[0171]
[0172] in, when If the sequence number is equal to the combination method, then the six chaotic sequence values corresponding to that combination are used to encrypt the current pixel to be encrypted.
[0173] Step 3f: Set i = 1, and start from the i-th pixel (r) to be encrypted in the region of interest image P0'. i g i b iBegin by calculating the serial number according to step 3e. Obtain the corresponding chaotic sequence combination method, and extract the i-th chaotic sequence value {Key1_r} from the 6 chaotic sequences. i Key2_r i Key1_g i Key2_g i Key1_b i Key2_b i} as the pixel to be encrypted (r i g i b i The key stream of ) is introduced, and the (i-1)th encrypted pixel (cr) is also introduced. i-1 ,cg i-1 cb i-1 Perform an XOR operation to obtain the i-th encrypted pixel (cr). i ,cg i cb i The calculation formula is as follows:
[0174] cr i =bitxor(r) i ,bitxor(mod(cr i-1 +Key1_r i ,256)Key2_r i ))
[0175] cg i =bitxor(g i bitxor(mod(cg) i-1 +Key1_g i ,256)Key2_g i ))
[0176] cb i =bitxor(b i bitxor(mod(cb) i-1 +Key1_b i ,256)Key2_b i ))
[0177] When i = 1, the (i-1)th encrypted pixel is the initial value (cr0, cg0, cb0) = (212, 212, 212) in step 3d;
[0178] Step 3g: Let i = i + 1, and repeat steps 3e, 3f, and 3g until i = L, to obtain the complete one-dimensional encrypted array CR = {cr1, cr2, ..., cr L}, CG={cg1, cg2,..., cgL}, CB={cb1,cb2,...,cb L Finally, the encrypted image of the region of interest is obtained as C' = reshape(CR, CG, CB). The function reshape(x, y, z) transforms the specified matrices x, y, z into an image matrix of a specific dimension to output the complete image.
[0179] Step 3h: As Figure 7 As shown, the encrypted image C' of the region of interest and the non-region of interest image P1' are merged to obtain and output the complete encrypted image C of the region of interest.
[0180] To perform statistical attack analysis and differential attack analysis on the encryption results, six sets of lung CT images were randomly selected for encryption. The encrypted and plaintext images were then compared. The higher the PSNR value of the encryption result, the better the imperceptibility of the encrypted image and the better the image quality. The theoretical values of NPCR and UACI of the encryption result were calculated to be 99.6094% and 33.4635%, respectively. The calculation results of these three indicators are shown below. Figure 8 , 9 As shown in the figure, in the encrypted image, the ideal value of PSNR is 8.1717, the ideal value of NPGR is 99.80%, and the ideal value of UACI is 33.56%. It can be seen from the figure that the experimental results of the three indicators are all slightly different from the theoretical values, showing good performance. The above experimental results fully demonstrate that the present invention can effectively resist statistical attacks and differential attacks.
Claims
1. A medical image encryption algorithm based on region of interest, characterized in that, This includes performing the following steps sequentially: (1) image segmentation, (2) coordinate extraction of the region of interest, and (3) image encryption using a hyperchaotic system. The image segmentation in step (1) uses a genetic algorithm optimized based on the Otsu threshold segmentation method to determine the optimal segmentation threshold for image segmentation, thereby performing binary segmentation on the image and marking the regions of interest and non-regions of interest in the image; Step (3) uses a hyperchaotic system to encrypt the image, including the following steps: Step 3a: Input the region of interest image Images of regions of interest and non-interest Given a randomly selected external key K of length 256 bits, calculate the region of interest image. The total number of pixels L; Step 3b: Generate 8 chaotic sequences for image encryption using two four-dimensional hyperchaotic systems; where: The first equation for a four-dimensional hyperchaotic system is as follows: ; The equation for the second four-dimensional hyperchaotic system is as follows: ; Step 3c: Convert the matrices R, G, and B of each color channel of the region of interest image into one-dimensional vectors, and calculate the sum of the matrix pixels of all color channels; specifically: R={r1,r2,...,r L’ };G={g1,g2,...,g L’ };B={b1,b2,...,b L’ }; And calculate the sum of the matrix pixels of all color channels, sum.image, according to the following formula: ; Wherein, L is the region of interest image from step 3a. The total number of pixels; Step 3d: Define the three color channel matrices of the encrypted image C' of the region of interest as CR = {cr1, cr2, ..., cr2}. L }、CG={cg1,cg2,...,cg L }、CB={cb1,cb2,...,cb L } Calculate auxiliary encrypted pixels cr0, cg0, and cb0 to aid in calculating the value of the first encrypted pixel: ; ; Step 3e: Because step 3b generated a total of 8 integer chaotic sequences {x} of length L. 1j x 2j x 3j x 4j x 5j x 6j x 7j x 8j During the encryption process, only six chaotic sequences need to be selected to encrypt the three matrices R, G, and B. Therefore, different combinations will be generated based on the different chaotic sequences used. Eight different combination methods were defined and labeled as sequence numbers 0 to 7. The calculation is performed using the following steps: ; ; in, ∈[0, 7], when If the sequence number is equal to the combination method, then the six chaotic sequence values corresponding to that combination are used to encrypt the current pixel to be encrypted. Step 3f: Set i=1, from the region of interest image The i-th pixel to be encrypted (r) i g i b i Begin by calculating the serial number according to step 3e. Obtain the corresponding chaotic sequence combination method, and extract the i-th chaotic sequence value {Key1_r} from the 6 chaotic sequences. i Key2_r i Key1_g i Key2_g i Key1_b i Key2_b i } as the pixel to be encrypted (r i g i b i The key stream of ) is introduced, and the (i-1)th encrypted pixel (cr) is also introduced. i-1 ,cg i-1 cb i-1 Perform an XOR operation to obtain the i-th encrypted pixel (cr). i ,cg i cb i The calculation formula is as follows: ; ; ; When i=1, the (i-1)th encrypted pixel is the initial value (cr0, cg0, cb0) in step 3d. Step 3g: Let i = i + 1, and repeat steps 3e, 3f, and 3g until i = L, to obtain the complete one-dimensional encrypted array CR = {cr1, cr2, ..., cr L }、CG={cg1,cg2,...,cg L }、CB={cb1,cb2,...,cb L Finally, the encrypted image of the region of interest is obtained as C'=reshape(CR, CG, CB). The function reshape(x, y, z) transforms the specified matrices x, y, z into an image matrix of a specific dimension to output the complete image. Step 3h: Merge the encrypted region of interest image C' and the non-region of interest images. , obtain and output the complete encrypted image C of the region of interest.
2. The medical image encryption algorithm based on region of interest according to claim 1, characterized in that, Step (1) includes: Step 1a: Input a plaintext image P0 of size M×N, convert the plaintext image P0 into a grayscale image P1 of size M×N, and convert the pixel value corresponding to each pixel in the grayscale image P1 into an 8-bit binary value. Step 1b: Set the generation counter t=0, set the maximum generation T, and randomly generate the initial population G(t), that is, randomly select G different binary values from the grayscale image P1 in step 1a to form the population G(t); Step 1c: Calculate the fitness s of each individual in the population G(t) using the Otsu thresholding method. i 2 , i∈[1,G]; Step 1d: Calculate the fitness s of each individual based on the fitness s obtained in Step 1c. i 2 Then, the selection, crossover, and mutation operations are performed sequentially to obtain the next generation population G(t+1); Step 1e: To find the optimal individual g, repeat steps 1c and 1d until t=T, then terminate the loop and select the individual with the highest fitness in the population G(t) during the evolution process as the optimal individual g for output. Step 1f: Take the binary value corresponding to the best individual g obtained in step 1e as the optimal segmentation threshold T'. Following the method in step 1c, starting from the binary value corresponding to the first pixel in the grayscale image P1, compare it with the optimal segmentation threshold T' in turn until the last binary value in the grayscale image P1 is compared. If the binary value corresponding to a pixel is greater than or equal to the optimal segmentation threshold T', it is considered a region of interest, and the pixel value is marked as 255; if the binary value corresponding to a pixel is less than the optimal segmentation threshold T', it is considered a region of non-interest, and the pixel value is marked as 0. The final output segmentation result is a binary image P' of size M×N. The conversion formula for the binary image P' is as follows: ; in, This represents the pixel value at coordinates (x, y) in the grayscale image P1. This represents the pixel value at coordinates (x, y) in the binary image P'.
3. The medical image encryption algorithm based on region of interest according to claim 2, characterized in that, In step 1c, fitness s i 2 The calculation process includes: Input grayscale image P1 and the binary value g corresponding to the currently selected individual. i Let i∈[1,G], and let g be... i As the segmentation threshold, starting from the binary value corresponding to the first pixel in the grayscale image P1, it is sequentially compared with the segmentation threshold g. i The comparison continues until the last binary value in the grayscale image P1 has been compared. If the binary value corresponding to a pixel is greater than or equal to the segmentation threshold g, then... i If the binary value corresponding to a pixel is less than the segmentation threshold g, then it belongs to the region of interest. i If the region is not of interest, then it is recorded as a region of non-interest. Count the number of pixels belonging to the region of interest (ROI) N0 and the number of pixels not belonging to the ROI N1. Calculate the proportion ω0 of the ROI N0 to the total number of pixels N2 in the image, the proportion ω1 of the ROI N1 to the total number of pixels N2 in the image, the average gray value μ0 of the ROI, the average gray value μ1 of the ROI, the overall average gray value μ, and the inter-class variance s. 2 Inter-class variances 2 In genetic algorithms, this is the fitness of the currently selected individual; The number of pixels in the region of interest (N0), the number of pixels in the non-region of interest (N1), and the total number of pixels in the image (N2) satisfy the following calculation formula: N2 = N0 + N1 = M × N; Where M is the length of the input grayscale image P1 and N is the width of the input grayscale image P1; ω0, ω1, μ0, μ1, μ, s 2 The calculation formula is as follows: ; The inter-class variance of each individual in population G, i.e., the fitness of each individual, is calculated using the Otsu threshold segmentation method described above, and is denoted as s. i 2 , i∈[1,G].
4. The medical image encryption algorithm based on region of interest according to claim 1, characterized in that, Step (2) of extracting the region of interest by coordinates includes the following steps: Step 2a: Input a plaintext image P0 of size M×N and a binary image P' of size M×N. Starting from the first pixel of the binary image P', scan the first row of pixels from left to right along the x-axis, with the y-axis as the main axis. Then, starting from the second row, continue scanning until the first pixel A with a pixel value of 255 is found, and its coordinates are recorded as (xa, ya). Step 2b: Starting from the first pixel of the binary image P', scan the first column of pixels from top to bottom along the y-axis, with the x-axis as the main axis. Then, starting from the second column, scan sequentially until the first pixel B with a pixel value of 255 is found, and its coordinates are recorded as (xb, yb). Step 2c: Starting from the last pixel of the binary image P', scan the last row of pixels from right to left along the x-axis, with the y-axis as the main axis. Then, starting from the second to last row, scan sequentially until the first pixel C with a value of 255 is found, and its coordinates are recorded as (xc, yc). Step 2d: Starting from the last pixel of the binary image P', scan the last column of pixels from bottom to top along the y-axis, with the x-axis as the main axis. Then, starting from the second to last column, scan sequentially until the first pixel D with a value of 255 is found, and record its coordinates as (xd, yd). Step 2e: Map the four coordinate points A, B, C, D = {(xb, ya), (xd, ya), (xb, yc), (xd, yc)} to the plaintext image P0. Segment the rectangular image obtained by connecting the coordinates of points A, B, C, and D in the plaintext image P0, and output the final region of interest image. The plaintext image P0 excluding the region of interest. The remaining portion of the image is then output as the region of interest (ROI). .