import numpy as np

def DecodingDNAImage(m, n, I, KeyDecimal, KeyFeature):
    d1 = KeyDecimal[0]
    d2 = KeyDecimal[1]
    d3 = KeyDecimal[2]
    d4 = KeyDecimal[3]
    d5 = KeyDecimal[4]
    d6 = KeyDecimal[5]
    d7 = KeyDecimal[6]
    d8 = KeyDecimal[7]
    xx = np.bitwise_xor(np.bitwise_xor(np.bitwise_xor(np.bitwise_xor(np.bitwise_xor(np.bitwise_xor(np.bitwise_xor(d1, d2), d3), d4), d5), d6), d7), d8) ^ KeyFeature) / 256
    u = 3.89 + xx * 0.01

    d1 = KeyDecimal[8]
    d2 = KeyDecimal[9]
    d3 = KeyDecimal[10]
    d4 = KeyDecimal[11]
    d5 = KeyDecimal[12]
    d6 = KeyDecimal[13]
    d7 = KeyDecimal[14]
    d8 = KeyDecimal[15]
    x = np.bitwise_xor(np.bitwise_xor(np.bitwise_xor(np.bitwise_xor(np.bitwise_xor(np.bitwise_xor(np.bitwise_xor(d1, d2), d3), d4), d5), d6), d7), d8) ^ KeyFeature) / 256

    Len = d1 + d2 + d3 + KeyFeature
    for i in range(Len):
        x = u * x * (1 - x)

    Len4mn = 4 * n * m
    x[0] = x
    for i in range(1, Len4mn):
        x[i] = u * x[i-1] * (1 - x[i-1])
    LogisticSeq = x

    R = np.floor(8 * LogisticSeq) + 1

    DecodeDNA = np.zeros((4 * n * m, 1))
    for i in range(Len4mn):
        if R[i] == 1:
            if I[i] == 0:
                DecodeDNA[i] = 1
            elif I[i] == 1:
                DecodeDNA[i] = 0
            elif I[i] == 2:
                DecodeDNA[i] = 3
            elif I[i] == 3:
                DecodeDNA[i] = 2
        elif R[i] == 2:
            if I[i] == 0:
                DecodeDNA[i] = 2
            elif I[i] == 1:
                DecodeDNA[i] = 0
            elif I[i] == 2:
                DecodeDNA[i] = 3
            elif I[i] == 3:
                DecodeDNA[i] = 1
        elif R[i] == 3:
            if I[i] == 0:
                DecodeDNA[i] = 0
            elif I[i] == 1:
                DecodeDNA[i] = 1
            elif I[i] == 2:
                DecodeDNA[i] = 2
            elif I[i] == 3:
                DecodeDNA[i] = 3
        elif R[i] == 4:
            if I[i] == 0:
                DecodeDNA[i] = 0
            elif I[i] == 1:
                DecodeDNA[i] = 2
            elif I[i] == 2:
                DecodeDNA[i] = 1
            elif I[i] == 3:
                DecodeDNA[i] = 3
        elif R[i] == 5:
            if I[i] == 0:
                DecodeDNA[i] = 3
            elif I[i] == 1:
                DecodeDNA[i] = 1
            elif I[i] == 2:
                DecodeDNA[i] = 2
            elif I[i] == 3:
                DecodeDNA[i] = 0
        elif R[i] == 6:
            if I[i] == 0:
                DecodeDNA[i] = 3
            elif I[i] == 1:
                DecodeDNA[i] = 2
            elif I[i] == 2:
                DecodeDNA[i] = 1
            elif I[i] == 3:
                DecodeDNA[i] = 0
        elif R[i] == 7:
            if I[i] == 0:
                DecodeDNA[i] = 1
            elif I[i] == 1:
                DecodeDNA[i] = 3
            elif I[i] == 2:
                DecodeDNA[i] = 0
            elif I[i] == 3:
                DecodeDNA[i] = 2
        elif R[i] == 8:
            if I[i] == 0:
                DecodeDNA[i] = 2
            elif I[i] == 1:
                DecodeDNA[i] = 3
            elif I[i] == 2:
                DecodeDNA[i] = 0
            elif I[i] == 3:
                DecodeDNA[i] = 1

    Imagedecoding = np.zeros((m * n, 1))
    sign = 1
    num = 0
    for i in range(0, Len4mn, 4):
        for j in range(i, i+4):
            if j % 4 == 1:
                num = num + DecodeDNA[j] * 64
            elif j % 4 == 2:
                num = num + DecodeDNA[j] * 16
            elif j % 4 == 3:
                num = num + DecodeDNA[j] * 4
            elif j % 4 == 0:
                num = num + DecodeDNA[j] * 1
                Imagedecoding[sign] = num
                num = 0
                sign = sign + 1
    
    Imagedecoding = np.reshape(Imagedecoding, (m, n))
    
    return Imagedecoding
DNA Image Decoding Algorithm: Python Implementation

原文地址: https://www.cveoy.top/t/topic/qEZF 著作权归作者所有。请勿转载和采集!

免费AI点我,无需注册和登录