コード例 #1
0
def marcar(block_array, watermark, coef, delta):
    # Convirtiendo a modelo de color YCbCr
    block_ycbcr_array = ImageTools().rgb2ycbcr(block_array)
    # Y component
    Y_array = block_ycbcr_array[:, :, 0]
    # Krawtchouk transform
    dqkt_block = DqKT().dqkt2(np.array(Y_array, dtype=np.float32))
    
    negative = False
    if dqkt_block[get_indice(coef)[0], get_indice(coef)[1]] < 0:
        negative = True

    if watermark == 0:
        # Bit a insertar 0
        dqkt_block[get_indice(coef)[0], get_indice(coef)[1]] = 2*delta*round(abs(dqkt_block[get_indice(coef)[0], get_indice(coef)[1]])/(2.0*delta)) - delta/2.0
    else:
        # Bit a insertar 1
        dqkt_block[get_indice(coef)[0], get_indice(coef)[1]] = 2*delta*round(abs(dqkt_block[get_indice(coef)[0], get_indice(coef)[1]])/(2.0*delta)) + delta/2.0

    if negative:
        dqkt_block[get_indice(coef)[0], get_indice(coef)[1]] *= -1
    
    Y_array = DqKT().idqkt2(dqkt_block)
    block_ycbcr_array[:, :, 0] = Y_array
    # Convirtiendo a modelo de color RGB
    block_rgb_array = ImageTools().ycbcr2rgb(block_ycbcr_array)
    
    return block_rgb_array
コード例 #2
0
ファイル: AvilaDomenech2019R.py プロジェクト: eadomenech/wMLP
    def extract(self, watermarked_image):

        print("...Proceso de extraccion...")

        # Instancias necesarias
        itools = ImageTools()

        print("Convirtiendo a YCbCr")
        # Convirtiendo a modelo de color YCbCr
        watermarked_ycbcr_array = itools.rgb2ycbcr(watermarked_image)

        # Tomando componente Y
        watermarked_array = watermarked_ycbcr_array[:, :, 0]

        bt_of_watermarked_Y = BlocksImage(watermarked_array)

        extract = []

        print("Extrayendo")
        # Recorrer todos los bloques de la imagen
        for i in range(self.len_watermark_list):
            block = bt_of_watermarked_Y.get_block(self.pos[i])
            # Valores de coeficiente y delta optimo para el bloque
            (c, delta) = self.clasificar(self.pos[i], watermarked_image)
            dqkt_block = DqKT().dqkt2(np.array(block, dtype=np.float32))
            
            negative = False
            
            (px, py) = self.get_indice(c)           
            if dqkt_block[px, py] < 0:
                negative = True
            
            C1 = (2*delta*round(abs(dqkt_block[px, py])/(2.0*delta)) + delta/2.0) - abs(dqkt_block[px, py])
            
            C0 = (2*delta*round(abs(dqkt_block[px, py])/(2.0*delta)) - delta/2.0) - abs(dqkt_block[px, py])

            if negative:
                C1 *= -1
                C0 *= -1
            if C0 < C1:
                extract.append(0)
            else:
                extract.append(1)

        wh = int(math.sqrt(self.len_watermark_list))
        extract_image = Image.new("1", (wh, wh), 255)
        array_extract_image1 = misc.fromimage(extract_image)

        for i in range(wh):
            for y in range(wh):
                if extract[wh*i+y] == 0:
                    array_extract_image1[i, y] = 0
        
        watermark_extracted = misc.toimage(array_extract_image1)
        for i in range(10):
            watermark_extracted = DAT().dat2(watermark_extracted)
        
        return watermark_extracted
コード例 #3
0
    def insert(self, cover_image):
        
        print("...Proceso de insercion...")

        # Instancias necesarias
        itools = ImageTools()

        print("Convirtiendo a YCbCr")
        # Convirtiendo a modelo de color YCbCr
        cover_ycbcr_array = itools.rgb2ycbcr(cover_image)

        # Obteniendo componente Y
        cover_array = cover_ycbcr_array[:, :, 0]

        # Objeto de la clase Bloque
        bt_of_cover = BlocksImage(cover_array)

        # Generando bloques a marcar
        print("Generando bloques a marcar")
        self.generar(bt_of_cover.max_num_blocks())

        print("Marcando")
        # Marcar los self.len_watermark_list bloques
        for i in range(self.len_watermark_list):
            block = bt_of_cover.get_block(self.pos[i])

            # Calculando DCT
            dct_block = DCT().dct2(block)

            c = self.c
            delta = self.delta

            # negative = False
            (px, py) = self.get_indice(c)
            # if dct_block[px, py] < 0:
            #     negative = True

            if self.watermark_list[i % self.len_watermark_list] == 0:
                # Bit a insertar 0
                dct_block[px, py] = 2*delta*round(abs(dct_block[px, py])/(2.0*delta)) - delta/2.0
            else:
                # Bit a insertar 1
                dct_block[px, py] = 2*delta*round(abs(dct_block[px, py])/(2.0*delta)) + delta/2.0

            # if negative:
            #     dct_block[px, py] *= -1

            idct_block = DCT().idct2(dct_block)
            
            bt_of_cover.set_block(idct_block, self.pos[i])

        print("Convirtiendo a RGB")
        image_rgb_array = itools.ycbcr2rgb(cover_ycbcr_array)

        return Image.fromarray(image_rgb_array)
コード例 #4
0
ファイル: Liu2018R.py プロジェクト: eadomenech/watermarking
    def extract(self, watermarked_image):
        # Instancias necesarias
        itools = ImageTools()

        # Convirtiendo a modelo de color YCbCr
        watermarked_ycbcr_array = itools.rgb2ycbcr(watermarked_image)

        # Tomando componente Y
        watermarked_array = watermarked_ycbcr_array[:, :, 0]

        # Wavelet Transform
        LL, [LH, HL, HH] = pywt.dwt2(watermarked_array, 'haar')

        colums = len(LL[0])

        extract = []

        # Extracting
        # Dividiendo LL en bloques de 8x8
        bt_of_LL = BlocksImage(LL)

        for i in range(bt_of_LL.max_num_blocks()):
            # Cuantificado
            QLL = utils.quantification(bt_of_LL.get_block(i), self.Q)
            # replaced directly by the resulting Q-LL
            bt_of_LL.set_block(QLL, i)

        for i in range(self.len_watermark_list):
            # Extrayendo
            px = self.pos[i] // colums
            py = self.pos[i] - (px * colums)
            extract.append(abs(round((HH[px, py] - LL[px, py]) / self.k)))

        # for i in range(self.len_watermark_list + 1):
        #     # Marcado
        #     if i > 0:
        #         px = i // colums
        #         py = i - (px * colums)
        #         extract.append(abs(round((HH[px, py] - LL[px, py])/self.k)))

        wh = int(math.sqrt(self.len_watermark_list))
        extract_image1 = Image.new("L", (wh, wh), 255)
        array_extract_image = misc.fromimage(extract_image1)

        for i in range(wh):
            for y in range(wh):
                if extract[wh * i + y] == 0:
                    array_extract_image[i, y] = 0

        watermark_extracted = misc.toimage(array_extract_image)

        return watermark_extracted
コード例 #5
0
    def insert(self, cover_image):
        # Instancias necesarias
        itools = ImageTools()

        # Embedding of Copyright Information (robust watermarking)
        # Convirtiendo a modelo de color YCbCr
        cover_ycbcr_array = itools.rgb2ycbcr(cover_image)

        # Tomando componente Y
        cover_array = cover_ycbcr_array[:, :, 0]

        # Wavelet Transform
        LL, [LH, HL, HH] = pywt.dwt2(cover_array, 'haar')

        # Watermark resize
        self.watermark_proccesing(LL.shape)

        colums = len(LL[0])

        print("Creando posisciones random")
        val = [x for x in range(self.cant_posibilidades)]
        random.shuffle(val)
        self.v = val[:self.len_watermark_list]

        print("Insertando")
        # Embedding
        for i in range(self.len_watermark_list):
            px = self.v[i] // colums
            py = self.v[i] - (px * colums)
            if self.watermark_list[i] == 255:
                if HL[px, py] <= LH[px, py]:
                    T = abs(LH[px, py]) - abs(HL[px, py])
                    A3w = T + HL[px][py]
                    HL[px, py] = A3w + (LH[px, py] + HL[px, py]) / 2.0
            else:
                if LH[px, py] <= HL[px, py]:
                    T = abs(HL[px, py]) - abs(LH[px, py])
                    A2w = T + LH[px, py]
                    LH[px, py] = A2w + (LH[px, py] + HL[px, py]) / 2.0

        # Inverse transform
        cover_ycbcr_array[:, :, 0] = pywt.idwt2((LL, (LH, HL, HH)), 'haar')

        image_rgb_array = itools.ycbcr2rgb(cover_ycbcr_array)

        # Generating the watermarked image
        watermarked_image = Image.fromarray(image_rgb_array)

        return watermarked_image
コード例 #6
0
def extraer(block_array, coef, delta):
    # Convirtiendo a modelo de color YCbCr
    block_ycbcr_array = ImageTools().rgb2ycbcr(block_array)
    # Y component
    Y_array = block_ycbcr_array[:, :, 0]

    # DCT
    dct_block = DCT().dct2(Y_array)

    negative = False

    (px, py) = get_indice(coef)

    if dct_block[px, py] < 0:
        negative = True

    C1 = (2 * delta * round(abs(dct_block[px, py]) / (2.0 * delta)) +
          delta / 2.0) - abs(dct_block[px, py])
    C0 = (2 * delta * round(abs(dct_block[px, py]) / (2.0 * delta)) -
          delta / 2.0) - abs(dct_block[px, py])

    if negative:
        C1 *= -1
        C0 *= -1
    if (dct_block[px, py] - C0) < (dct_block[px, py] - C1):
        return 0
    else:
        return 1
コード例 #7
0
ファイル: clasification1.py プロジェクト: eadomenech/wMLP
def extraer(block_array, coef, delta):
    # Convirtiendo a modelo de color YCbCr
    block_ycbcr_array = ImageTools().rgb2ycbcr(block_array)
    # Y component
    Y_array = block_ycbcr_array[:, :, 0]
    # Krawtchouk transform
    dqkt_block = DqKT().dqkt2(np.array(Y_array, dtype=np.float32))

    negative = False
    if dqkt_block[get_indice(coef)[0], get_indice(coef)[1]] < 0:
        negative = True

    C1 = (2 * delta * round(
        abs(dqkt_block[get_indice(coef)[0],
                       get_indice(coef)[1]]) /
        (2.0 * delta)) + delta / 2.0) - abs(dqkt_block[get_indice(coef)[0],
                                                       get_indice(coef)[1]])
    C0 = (2 * delta * round(
        abs(dqkt_block[get_indice(coef)[0],
                       get_indice(coef)[1]]) /
        (2.0 * delta)) - delta / 2.0) - abs(dqkt_block[get_indice(coef)[0],
                                                       get_indice(coef)[1]])

    if negative:
        C1 *= -1
        C0 *= -1
    if C0 < C1:
        return 0
    else:
        return 1
コード例 #8
0
    def extract(self, watermarked_image):
        # Instancias necesarias
        itools = ImageTools()

        # Embedding of Copyright Information (robust watermarking)
        # Convirtiendo a modelo de color YCbCr
        watermarked_ycbcr_array = itools.rgb2ycbcr(watermarked_image)

        # Tomando componente Y
        watermarked_array = watermarked_ycbcr_array[:, :, 0]

        # Wavelet Transform
        LL, [LH, HL, HH] = pywt.dwt2(watermarked_array, 'haar')

        colums = len(LL[0])

        extract = []

        # Extracting
        for i in range(self.len_watermark_list):
            px = self.v[i] // colums
            py = self.v[i] - (px * colums)
            if HL[px, py] >= LH[px, py]:
                extract.append(1)
            else:
                extract.append(0)

        wh = int(math.sqrt(self.len_watermark_list))
        extract_image1 = Image.new("1", (wh, wh), 255)
        array_extract_image = misc.fromimage(extract_image1)

        for i in range(wh):
            for y in range(wh):
                if extract[wh * i + y] == 0:
                    array_extract_image[i, y] = 0

        watermark_extracted = misc.toimage(array_extract_image)

        return watermark_extracted
コード例 #9
0
def marcar(block_array, watermark, coef, delta):
    # Convirtiendo a modelo de color YCbCr
    block_ycbcr_array = ImageTools().rgb2ycbcr(block_array)
    # Y component
    Y_array = block_ycbcr_array[:, :, 0]

    # DCT
    dct_block = DCT().dct2(Y_array)

    # negative = False
    # if dct_block[get_indice(coef)[0], get_indice(coef)[1]] < 0:
    #     negative = True

    (px, py) = get_indice(coef)

    if watermark == 0:
        # Bit a insertar 0
        dct_block[
            px,
            py] = 2 * delta * round(abs(dct_block[px, py]) /
                                    (2.0 * delta)) - delta / 2.0
    else:
        # Bit a insertar 1
        dct_block[
            px,
            py] = 2 * delta * round(abs(dct_block[px, py]) /
                                    (2.0 * delta)) + delta / 2.0

    # if negative:
    #     dct_block[get_indice(coef)[0], get_indice(coef)[1]] *= -1

    Y_array = DCT().idct2(dct_block)
    block_ycbcr_array[:, :, 0] = Y_array
    # Convirtiendo a modelo de color RGB
    block_rgb_array = ImageTools().ycbcr2rgb(block_ycbcr_array)

    return block_rgb_array
コード例 #10
0
    def insert(self, cover_image):
        
        print("...Proceso de insercion...")

        # Instancias necesarias
        itools = ImageTools()

        print("Convirtiendo a YCbCr")
        # Convirtiendo a modelo de color YCbCr
        cover_ycbcr_array = itools.rgb2ycbcr(cover_image)

        # Obteniendo componente Y
        cover_array = cover_ycbcr_array[:, :, 0]

        # Objeto de la clase Bloque
        bt_of_cover = BlocksImage(cover_array)

        # Generando bloques a marcar
        print("Generando bloques a marcar")
        self.generar(bt_of_cover.max_num_blocks())

        print("Marcando")
        # Marcar los self.len_watermark_list bloques
        for i in range(self.len_watermark_list):
            block = bt_of_cover.get_block(self.pos[i])

            # Valores de coeficiente y delta optimo para el bloque
            (c, delta) = self.clasificar(self.pos[i], cover_image) 

            # Calculando Krawchout Transform
            dqkt_block = DqKT().dqkt2(block)

            negative = False
            (px, py) = self.get_indice(c)
            if dqkt_block[px, py] < 0:
                negative = True

            if self.watermark_list[i % self.len_watermark_list] == 0:
                # Bit a insertar 0
                dqkt_block[px, py] = 2*delta*round(abs(dqkt_block[px, py])/(2.0*delta)) + delta/2.0
            else:
                # Bit a insertar 1
                dqkt_block[px, py] = 2*delta*round(abs(dqkt_block[px, py])/(2.0*delta)) - delta/2.0

            if negative:
                dqkt_block[px, py] *= -1
            idqkt_block = DqKT().idqkt2(dqkt_block)
            inv = idqkt_block
            for x in range(8):
                for y in range(8):
                    if (inv[x, y] - int(inv[x, y])) < 0.5:
                        inv[x, y] = int(inv[x, y])
                    else:
                        inv[x, y] = int(inv[x, y]) + 1
                    if inv[x, y] > 255:
                        inv[x, y] = 255
                    if inv[x, y] < 0:
                        inv[x, y] = 0
            bt_of_cover.set_block(idqkt_block, self.pos[i])

        print("Convirtiendo a RGB")
        image_rgb_array = itools.ycbcr2rgb(cover_ycbcr_array)

        return Image.fromarray(image_rgb_array)
コード例 #11
0
ファイル: my_insert.py プロジェクト: EroPerez/dhmdi
def insert(cover_image, watermark_image):
    from image_tools.ImageTools import ImageTools
    dqkt = DqKT()
    myqr = MyQR62()
    dat = DAT()
    itools = ImageTools()

    delta = 128

    c = [1, 19]

    if (c[1] - c[0]) != 0:
        # Convirtiendo a modelo de color YCbCr
        cover_ycbcr_array = itools.rgb2ycbcr(cover_image)

        cover_array = cover_ycbcr_array[:, :, 0]
        # Cargando watermark
        watermark = watermark_image.convert("1")

        # Utilizando Arnold Transforms
        for i in range(20):
            watermark = dat.dat2(watermark)

        # obteniendo array de la watermark
        watermark_array = misc.fromimage(watermark)  # Array of watermark

        # Instance a la clase Bloque
        bt_of_cover = BlockTools(cover_array)

        # Calculando e imprimeindo datos iniciales
        len_of_watermark = watermark_array.size

        # Datos de la watermark como lista
        list_bit_of_watermark = watermark_array.reshape(
            (1, len_of_watermark))[0]

        # Utilizar Bloques segun key
        dic = {'semilla': 0.00325687, 'p': 0.22415897}
        valores = []
        cantidad = bt_of_cover.max_blocks()
        for i in range(cantidad):
            valores.append(i)
        v = mypwlcm_limit(dic, valores, len_of_watermark)

        # Marcar los self.len_of_watermark bloques
        for i in range(len_of_watermark):

            dqkt_block = dqkt.dqkt2(
                np.array(bt_of_cover.get_block(v[i] + 1), dtype=np.float32))

            negative = False
            if dqkt_block[get_indice(c[1])[0], get_indice(c[1])[1]] < 0:
                negative = True

            if list_bit_of_watermark[i % len_of_watermark] == 0:
                # Bit a insertar 0
                dqkt_block[get_indice(c[1])[0],
                           get_indice(c[1])[1]] = 2 * delta * round(
                               abs(dqkt_block[get_indice(c[1])[0],
                                              get_indice(c[1])[1]]) /
                               (2.0 * delta)) - delta / 2.0
            else:
                # Bit a insertar 1
                dqkt_block[get_indice(c[1])[0],
                           get_indice(c[1])[1]] = 2 * delta * round(
                               abs(dqkt_block[get_indice(c[1])[0],
                                              get_indice(c[1])[1]]) /
                               (2.0 * delta)) + delta / 2.0

            if negative:
                dqkt_block[get_indice(c[1])[0], get_indice(c[1])[1]] *= -1

            idqkt_block = dqkt.idqkt2(dqkt_block)

            inv = idqkt_block
            for x in range(8):
                for y in range(8):
                    if (inv[x, y] - int(inv[x, y])) < 0.5:
                        inv[x, y] = int(inv[x, y])
                    else:
                        inv[x, y] = int(inv[x, y]) + 1
                    if inv[x, y] > 255:
                        inv[x, y] = 255
                    if inv[x, y] < 0:
                        inv[x, y] = 0

            bt_of_cover.set_block(idqkt_block, v[i] + 1)

        cover_marked_ycbcr_array = cover_ycbcr_array

        image_rgb_array = itools.ycbcr2rgb(cover_marked_ycbcr_array)

    return misc.toimage(image_rgb_array)
コード例 #12
0
def extract(watermarked_filename):
    delta = 128
    c = [1, 19]
    from image_tools.ImageTools import ImageTools
    dqkt = DqKT()
    myqr = MyQR62()
    dat = DAT()
    itools = ImageTools()

    watermarked_image = Image.open(watermarked_filename)
    watermarked_ycbcr_image = itools.rgb2ycbcr(watermarked_image)
    watermarked_array = watermarked_ycbcr_image[:, :, 0]
    bt_of_watermarked_image_without_noise = BlockTools(watermarked_array)

    extract = []

    len_of_watermark = 3844

    # Utilizar Bloques segun key
    dic = {'semilla': 0.00325687, 'p': 0.22415897}
    valores = []
    cantidad = bt_of_watermarked_image_without_noise.max_blocks()
    for i in range(cantidad):
        valores.append(i)
    v = mypwlcm_limit(dic, valores, len_of_watermark)

    for i in range(len_of_watermark):

        dqkt_block = dqkt.dqkt2(
            np.array(bt_of_watermarked_image_without_noise.get_block(v[i] + 1),
                     dtype=np.float32))

        negative = False
        if dqkt_block[get_indice(c[1])[0], get_indice(c[1])[1]] < 0:
            negative = True

        C1 = (2 * delta * round(
            abs(dqkt_block[get_indice(c[1])[0],
                           get_indice(c[1])[1]]) / (2.0 * delta)) +
              delta / 2.0) - abs(dqkt_block[get_indice(c[1])[0],
                                            get_indice(c[1])[1]])
        C0 = (2 * delta * round(
            abs(dqkt_block[get_indice(c[1])[0],
                           get_indice(c[1])[1]]) / (2.0 * delta)) -
              delta / 2.0) - abs(dqkt_block[get_indice(c[1])[0],
                                            get_indice(c[1])[1]])

        if negative:
            C1 *= -1
            C0 *= -1
        if C0 < C1:
            extract.append(0)
        else:
            extract.append(1)

    wh = int(math.sqrt(len_of_watermark))
    extract_image = Image.new("1", (wh, wh), 255)
    array_extract_image = misc.fromimage(extract_image)

    for i in range(wh):
        for y in range(wh):
            if extract[wh * i + y] == 0:
                array_extract_image[i, y] = 0

    watermark_array_image = misc.toimage(array_extract_image)
    for i in range(10):
        watermark_array_image = dat.dat2(watermark_array_image)

    b = BlockTools(misc.fromimage(watermark_array_image), 2, 2)
    for m in range(1, b.max_blocks() + 1):
        b.set_color(m)

    return misc.toimage(myqr.get_resconstructed(b.get()))
コード例 #13
0
ファイル: Liu2018R.py プロジェクト: eadomenech/watermarking
    def insert(self, cover_image):
        # Instancia
        itools = ImageTools()

        print("Convirtiendo a YCbCr")
        # Convirtiendo a modelo de color YCbCr
        cover_ycbcr_array = itools.rgb2ycbcr(cover_image)

        # Obteniendo componente Y
        cover_array = cover_ycbcr_array[:, :, 0]

        print("DWT")
        # DWT
        LL, [LH, HL, HH] = pywt.dwt2(cover_array, 'haar')

        # Generando posiciones a utilizar
        self.generar(LL.size)

        # Dividiendo LL en bloques de 8x8
        bt_of_LL = BlocksImage(LL)
        bt_of_HH = BlocksImage(HH)

        print("Re-asignando subbanda HH")
        for i in range(bt_of_LL.max_num_blocks()):
            # Cuantificado
            QLL = utils.quantification(bt_of_LL.get_block(i), self.Q)
            # replaced directly by the resulting Q-LL
            bt_of_HH.set_block(QLL, i)

        QWLL = np.copy(HH)
        # QWLL = np.full_like(HH)

        print("Modificando LL")
        for i in range(self.len_watermark_list):
            colums = len(LL[0])
            # Marcado
            px = self.pos[i] // colums
            py = self.pos[i] - (px * colums)
            QWLL[px, py] = HH[px, py] + self.watermark_list[i] / 255 * self.k

        # print("Modificando LL")
        # for i in range(self.len_watermark_list + 1):
        #     colums = len(LL[0])
        #     # Marcado
        #     if i > 0:
        #         px = i // colums
        #         py = i - (px * colums)
        #         LL[px, py] += self.watermark_list[i-1]/255 * self.k

        bt_of_QWLL = BlocksImage(QWLL)
        for i in range(bt_of_LL.max_num_blocks()):
            # Descuantificando
            UQWLL = utils.unquantification(bt_of_QWLL.get_block(i), self.Q)
            # replaced directly by the resulting Q-LL
            bt_of_LL.set_block(UQWLL, i)

        # Inverse transform
        print("IDWT")
        cover_ycbcr_array[:, :, 0] = pywt.idwt2((LL, (LH, HL, HH)), 'haar')

        print("Convirtiendo a RGB")
        image_rgb_array = itools.ycbcr2rgb(cover_ycbcr_array)

        return Image.fromarray(image_rgb_array)
コード例 #14
0
    def extract(self, watermarked_image):

        c = self.c
        delta = self.delta

        print("...Proceso de extraccion...")

        # Instancias necesarias
        itools = ImageTools()

        print("Convirtiendo a YCbCr")
        # Convirtiendo a modelo de color YCbCr
        watermarked_ycbcr_array = itools.rgb2ycbcr(watermarked_image)

        # Tomando componente Y
        watermarked_array = watermarked_ycbcr_array[:, :, 0]

        bt_of_watermarked_Y = BlocksImage(watermarked_array)

        extract = []

        print("Extrayendo")
        # Recorrer todos los bloques de la imagen
        for i in range(self.len_watermark_list):
            block = bt_of_watermarked_Y.get_block(self.pos[i])
            
            dct_block = DCT().dct2(block)
            
            negative = False
            
            (px, py) = self.get_indice(c)           
            if dct_block[px, py] < 0:
                negative = True
            
            C1 = (2*delta*round(abs(dct_block[px, py])/(2.0*delta)) + delta/2.0) - abs(dct_block[px, py])
            
            C0 = (2*delta*round(abs(dct_block[px, py])/(2.0*delta)) - delta/2.0) - abs(dct_block[px, py])

            if negative:
                C1 *= -1
                C0 *= -1

            if (dct_block[px, py] - C0) < (dct_block[px, py] - C1):
                extract.append(0)
            else:
                extract.append(1)

        wh = int(math.sqrt(self.len_watermark_list))
        extract_image = Image.new("1", (wh, wh), 255)
        array_extract_image1 = misc.fromimage(extract_image)

        for i in range(wh):
            for y in range(wh):
                if extract[wh*i+y] == 0:
                    array_extract_image1[i, y] = 0
        
        # myqr1 = MyQR62()
        
        watermark_extracted = misc.toimage(array_extract_image1)
        for i in range(10):
            watermark_extracted = DAT().dat2(watermark_extracted)
        
        # # Utilizacion de caracteristica de QR code
        
        # array = misc.fromimage(watermark_extracted)
        # watermark_extracted = misc.toimage(
        #     myqr1.get_resconstructed(array))

        # b = BlocksImage(misc.fromimage(watermark_extracted), 2, 2)
        # for m in range(b.max_num_blocks()):
        #     b.set_color(m)
        # watermark_extracted = misc.toimage(b.get())
        
        return watermark_extracted