2017-03-05 4 views
0

Comment fusionner 2 images à l'aide de la transformée en ondelettes. Il existe plusieurs méthodes disponibles telles que l'analyse des composants principaux, le filtrage passe-haut, IHS, etc. Je veux savoir comment fusionner en utilisant la transformée en ondelettes. Je connais la théorie derrière et je veux savoir comment l'implémenter en Python.Fusion d'images Utilisation de la transformation d'ondelettes en python

Voici le lien de la fusion d'image basée sur la transformée en ondelettes https://www.slideshare.net/paliwalumed/wavelet-based-image-fusion-33185100

+0

Vous dites que vous connaissez la théorie alors s'il vous plaît ajouter une explication nation comment faire la fusion en théorie et que peut-être que les gens qui ne connaissent pas la théorie pourraient vous aider à la mise en œuvre. –

+0

@AmitayNachmani https://www.slideshare.net/paliwalumed/wavelet-based-image-fusion-33185100 – Salveru

+0

Pouvez-vous s'il vous plaît poster deux images que vous voulez fusionner –

Répondre

2

D'abord, vous devez télécharger PyWavelet https://pywavelets.readthedocs.io/en/latest/

Deuxième exécutez le code suivant sur vos images:

import pywt 
import cv2 
import numpy as np 

# This function does the coefficient fusing according to the fusion method 
def fuseCoeff(cooef1, cooef2, method): 

    if (method == 'mean'): 
     cooef = (cooef1 + cooef2)/2 
    elif (method == 'min'): 
     cooef = np.minimum(cooef1,cooef2) 
    elif (method == 'max'): 
     cooef = np.maximum(cooef1,cooef2) 
    else: 
     cooef = [] 

    return cooef 


# Params 
FUSION_METHOD = 'mean' # Can be 'min' || 'max || anything you choose according theory 

# Read the two image 
I1 = cv2.imread('i1.bmp',0) 
I2 = cv2.imread('i2.jpg',0) 

# We need to have both images the same size 
I2 = cv2.resize(I2,I1.shape) # I do this just because i used two random images 

## Fusion algo 

# First: Do wavelet transform on each image 
wavelet = 'db1' 
cooef1 = pywt.wavedec2(I1[:,:], wavelet) 
cooef2 = pywt.wavedec2(I2[:,:], wavelet) 

# Second: for each level in both image do the fusion according to the desire option 
fusedCooef = [] 
for i in range(len(cooef1)-1): 

    # The first values in each decomposition is the apprximation values of the top level 
    if(i == 0): 

     fusedCooef.append(fuseCoeff(cooef1[0],cooef2[0],FUSION_METHOD)) 

    else: 

     # For the rest of the levels we have tupels with 3 coeeficents 
     c1 = fuseCoeff(cooef1[i][0],cooef2[i][0],FUSION_METHOD) 
     c2 = fuseCoeff(cooef1[i][1], cooef2[i][1], FUSION_METHOD) 
     c3 = fuseCoeff(cooef1[i][2], cooef2[i][2], FUSION_METHOD) 

     fusedCooef.append((c1,c2,c3)) 

# Third: After we fused the cooefficent we nned to transfor back to get the image 
fusedImage = pywt.waverec2(fusedCooef, wavelet) 

# Forth: normmalize values to be in uint8 
fusedImage = np.multiply(np.divide(fusedImage - np.min(fusedImage),(np.max(fusedImage) - np.min(fusedImage))),255) 
fusedImage = fusedImage.astype(np.uint8) 

# Fith: Show image 
cv2.imshow("win",fusedImage) 

Le fusedImage est la fusion résultante de I1 et I2

+0

Merci frère .... pouvez-vous s'il vous plaît me partager un lien de tutoriels pour Pywavelets – Salveru

+0

dans le même lien que j'ai posté il ya un lien vers là didacticiels –