Esempio n. 1
0
def decomposerSeuilTaille(img, LO_D, HI_D, compteur, seuil, taille, energie):
    compteur -= 1
    #print(img)
    if (compteur == 0):
        a1 = jp2.decompose(LO_D, LO_D, img)
    else:
        a1, count, energie = decomposerSeuilTaille(
            jp2.decompose(LO_D, LO_D, img), LO_D, HI_D, compteur, seuil,
            taille, energie)
        taille += count
        energie += energie
    im_out = np.double(np.zeros(img.shape))
    d1 = jp2.decompose(HI_D, HI_D, img)
    h1 = jp2.decompose(LO_D, HI_D, img)
    v1 = jp2.decompose(HI_D, LO_D, img)
    #pour seuiller les ondelettes: :
    h1 = np.where(np.abs(h1) > seuil, h1, 0.0)
    v1 = np.where(np.abs(v1) > seuil, v1, 0.0)
    d1 = np.where(np.abs(d1) > seuil, d1, 0.0)
    taille += (h1.size - np.count_nonzero(h1) + v1.size -
               np.count_nonzero(v1) + d1.size - np.count_nonzero(d1))
    energie += ((h1**2).sum() + (v1**2).sum() + (d1**2).sum())

    im_out[0:a1.shape[0], 0:a1.shape[1]] = a1
    im_out[0:a1.shape[0], a1.shape[0]:2 * a1.shape[0]] = h1
    im_out[a1.shape[0]:2 * a1.shape[0], 0:a1.shape[1]] = v1
    im_out[a1.shape[0]:2 * a1.shape[0], a1.shape[0]:2 * a1.shape[0]] = d1
    return im_out, taille, energie
Esempio n. 2
0
def decomposer(techno, LO_D, HI_D, compteur):
    compteur -= 1
    if (compteur == 0):
        a1 = jp2.decompose(LO_D, LO_D, techno)
    else:
        a1 = decomposer(jp2.decompose(LO_D, LO_D, techno), LO_D, HI_D,
                        compteur)
    im_out = np.double(np.zeros(techno.shape))
    d1 = jp2.decompose(HI_D, HI_D, techno)
    h1 = jp2.decompose(LO_D, HI_D, techno)
    v1 = jp2.decompose(HI_D, LO_D, techno)
    print("techno shape : ", techno.shape)
    print("h1 shape : ", h1.shape)

    im_out[0:a1.shape[0], 0:a1.shape[1]] = a1
    im_out[0:a1.shape[0], a1.shape[0]:2 * a1.shape[0]] = h1
    im_out[a1.shape[0]:2 * a1.shape[0], 0:a1.shape[1]] = v1
    im_out[a1.shape[0]:2 * a1.shape[0], a1.shape[0]:2 * a1.shape[0]] = d1

    # compress image
    #plt.imshow(jp2.composite_image(a1,np.abs(v1),np.abs(h1),np.abs(d1)),cmap='gray')
    #plt.show()

    h2 = jp2.decompose(HI_D, LO_D, a1)
    v2 = jp2.decompose(LO_D, HI_D, a1)
    d2 = jp2.decompose(HI_D, HI_D, a1)
    a2 = jp2.decompose(LO_D, LO_D, a1)

    # plt.imshow(jp2.composite_image(a2*0.1,np.abs(v2),np.abs(h2),np.abs(d2)),cmap='gray')
    # plt.show()

    return im_out
Esempio n. 3
0
def decomposer(img, LO_D, HI_D, compteur):
    compteur -= 1
    if (compteur == 0):
        a1 = jp2.decompose(LO_D, LO_D, img)
    else:
        a1 = decomposer(jp2.decompose(LO_D, LO_D, img), LO_D, HI_D, compteur)
    im_out = np.double(np.zeros(img.shape))
    d1 = jp2.decompose(HI_D, HI_D, img)
    h1 = jp2.decompose(LO_D, HI_D, img)
    v1 = jp2.decompose(HI_D, LO_D, img)

    im_out[0:a1.shape[0], 0:a1.shape[1]] = a1
    im_out[0:a1.shape[0], a1.shape[0]:2 * a1.shape[0]] = h1
    im_out[a1.shape[0]:2 * a1.shape[0], 0:a1.shape[1]] = v1
    im_out[a1.shape[0]:2 * a1.shape[0], a1.shape[0]:2 * a1.shape[0]] = d1
    return im_out
Esempio n. 4
0
def recomposer(img, LO_R, HI_R, compteur):
    compteur -= 1
    sizeX = int(img.shape[0] / 2)
    sizeY = int(img.shape[1] / 2)
    a1 = img[0:sizeX, 0:sizeY]
    h1 = img[0:sizeX, sizeY:2 * sizeY]
    v1 = img[sizeX:2 * sizeX, 0:sizeY]
    d1 = img[sizeX:2 * sizeX, sizeY:2 * sizeY]
    if (compteur == 0):
        a1_r = jp2.reconstruction(LO_R, LO_R, a1)
    else:
        a1_r = jp2.reconstruction(LO_R, LO_R,
                                  recomposer(a1, LO_R, HI_R, compteur))
    h1_r = jp2.reconstruction(LO_R, HI_R, h1)
    v1_r = jp2.reconstruction(HI_R, LO_R, v1)
    d1_r = jp2.reconstruction(HI_R, HI_R, d1)
    img = a1_r + h1_r + v1_r + d1_r
    return img
Esempio n. 5
0
def recomposer(techno, LO_R, HI_R, compteur):
    compteur -= 1
    tailleX = int(techno.shape[0] / 2)
    tailleY = int(techno.shape[1] / 2)
    a1 = techno[0:tailleX, 0:tailleY]
    h1 = techno[0:tailleX, tailleY:2 * tailleY]
    v1 = techno[tailleX:2 * tailleX, 0:tailleY]
    d1 = techno[tailleX:2 * tailleX, tailleY:2 * tailleY]
    if (compteur == 0):
        a1_r = jp2.reconstruction(LO_R, LO_R, a1)
    else:
        a1_r = jp2.reconstruction(LO_R, LO_R,
                                  recomposer(a1, LO_R, HI_R, compteur))
    h1_r = jp2.reconstruction(LO_R, HI_R, h1)
    v1_r = jp2.reconstruction(HI_R, LO_R, v1)
    d1_r = jp2.reconstruction(HI_R, HI_R, d1)
    techno = a1_r + h1_r + v1_r + d1_r
    return techno
Esempio n. 6
0
def decomposerSeuil(img, LO_D, HI_D, compteur, seuil):
    compteur -= 1
    if (compteur == 0):
        a1 = jp2.decompose(LO_D, LO_D, img)
    else:
        a1 = decomposerSeuil(jp2.decompose(LO_D, LO_D, img), LO_D, HI_D,
                             compteur, seuil)
    im_out = np.double(np.zeros(img.shape))
    d1 = jp2.decompose(HI_D, HI_D, img)
    h1 = jp2.decompose(LO_D, HI_D, img)
    v1 = jp2.decompose(HI_D, LO_D, img)
    #pour seuiller les ondelettes: :
    h1 = np.where(np.abs(h1) > seuil, h1, 0.0)
    v1 = np.where(np.abs(v1) > seuil, v1, 0.0)
    d1 = np.where(np.abs(d1) > seuil, d1, 0.0)

    im_out[0:a1.shape[0], 0:a1.shape[1]] = a1
    im_out[0:a1.shape[0], a1.shape[0]:2 * a1.shape[0]] = h1
    im_out[a1.shape[0]:2 * a1.shape[0], 0:a1.shape[1]] = v1
    im_out[a1.shape[0]:2 * a1.shape[0], a1.shape[0]:2 * a1.shape[0]] = d1
    return im_out
Esempio n. 7
0
def biasDecomposing(img, LO_D, HI_D, compteur, deathZone, discretZone, size,
                    energie):
    compteur -= 1
    if (compteur == 0):
        a1 = jp2.decompose(LO_D, LO_D, img)
    else:
        a1, size, energie = biasDecomposing(jp2.decompose(LO_D, LO_D, img),
                                            LO_D, HI_D, compteur, deathZone,
                                            discretZone, size, energie)
        size += size
        energie += energie
    im_out = np.double(np.zeros(img.shape))
    d1 = jp2.decompose(HI_D, HI_D, img)  # similar to decompose() -> find depth
    h1 = jp2.decompose(LO_D, HI_D,
                       img)  # similar to decompose() -> find horizontal
    v1 = jp2.decompose(HI_D, LO_D,
                       img)  # similar to decompose() -> find vertical

    h1 = applyContourByBias(
        h1, discretZone,
        deathZone)  # apply contour by bias on h1 to find horizontal
    v1 = applyContourByBias(
        v1, discretZone,
        deathZone)  # apply contour by bias on v1 to find vertical
    d1 = applyContourByBias(
        d1, discretZone,
        deathZone)  # apply contour by bias on d1 to find depth

    size += (h1.size - np.count_nonzero(h1) + v1.size - np.count_nonzero(v1) +
             d1.size - np.count_nonzero(d1))
    energie += ((h1**2).sum() + (v1**2).sum() + (d1**2).sum())

    im_out[0:a1.shape[0], 0:a1.shape[1]] = a1
    im_out[0:a1.shape[0], a1.shape[0]:2 * a1.shape[0]] = h1
    im_out[a1.shape[0]:2 * a1.shape[0], 0:a1.shape[1]] = v1
    im_out[a1.shape[0]:2 * a1.shape[0], a1.shape[0]:2 * a1.shape[0]] = d1
    return im_out, size, energie  # im_out is a string -> but you can store the returned value by array -> return [a1, h1, v1, d1]