IdentifiantMot de passe
Loading...
Mot de passe oublié ?Je m'inscris ! (gratuit)
Navigation

Inscrivez-vous gratuitement
pour pouvoir participer, suivre les réponses en temps réel, voter pour les messages, poser vos propres questions et recevoir la newsletter

Images Discussion :

image inpainting sous matlab


Sujet :

Images

  1. #1
    Candidat au Club
    Homme Profil pro
    Étudiant
    Inscrit en
    Août 2012
    Messages
    4
    Détails du profil
    Informations personnelles :
    Sexe : Homme
    Localisation : Algérie

    Informations professionnelles :
    Activité : Étudiant
    Secteur : Enseignement

    Informations forums :
    Inscription : Août 2012
    Messages : 4
    Points : 4
    Points
    4
    Par défaut image inpainting sous matlab
    j'ai fait un algorithme sur matlab mais elle n'a pas afficher l'image inpainter svp aide

    Code : Sélectionner tout - Visualiser dans une fenêtre à part
    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
    33
    34
    35
    36
    37
    38
    39
    40
    41
    42
    43
    44
    45
    46
    47
    48
    49
    50
    51
    52
    53
    54
    55
    56
    57
    58
    59
    60
    61
    62
    63
    64
    65
    66
    67
    68
    69
    70
    71
    72
    73
    74
    75
    76
    77
    78
    79
    80
    81
    82
    83
    84
    85
    86
    87
    88
    89
    90
    91
    92
    93
    94
    95
    96
    97
    98
    99
    100
    101
    102
    103
    104
    105
    106
    107
    108
    109
    110
    111
    112
    113
    114
    115
    116
    117
    118
    119
    120
    121
    122
    123
    124
    125
    126
    127
    128
    129
    130
    131
    132
    133
    134
    135
    136
    137
    138
    139
    140
    141
    142
    143
    144
    145
    146
    147
    148
    149
    function [B] = newTVInpaintingTest() 
    clear all; 
    close all; 
    OriginalImg = rgb2gray(imread('man.png')); 
    % OriginalImg = rgb2gray(imread('barbOriginal.bmp')); 
    % OriginalImg = rgb2gray(imread('бÏßͼOriginal.bmp')); 
    % OriginalImg = imread('bookOriginal.bmp'); 
    % OriginalImg = rgb2gray(imread('zhuobuOriginal.bmp')); 
    % OriginalImg = rgb2gray(imread('gunOriginal.bmp')); 
    % OriginalImg = rgb2gray(imread('¼¯ÊÐGRAYDirty.bmp')); 
    % OriginalImg = imread('lenaOriginal.bmp'); 
    % OriginalImg =imread('S_S_Denimb_t.bmp'); 
     
    % OriginalImg=imnoise(OriginalImg,'gaussian',0.01,0.003); 
    figure(1);imshow(OriginalImg); 
     
    % imwrite(uint8(OriginalImg),'lenaNoise.bmp'); 
     
     [ll,cc] = size(OriginalImg)
    % DirtyImg=rgb2gray(imread('clothDirtyCrossGray.bmp')); 
    % DirtyImg=rgb2gray(imread('clothDirtyFirstGray.bmp')); 
    % DirtyImg=rgb2gray(imread('barbDirty.bmp')); 
    % DirtyImg=rgb2gray(imread('бÏßͼdirty.bmp')); 
    % DirtyImg=imread('bookDirty.bmp'); 
    % DirtyImg=rgb2gray(imread('zhuobuDirty.bmp')); 
    % DirtyImg=rgb2gray(imread('gunDirty.bmp')); 
    % DirtyImg=rgb2gray(imread('¼¯ÊÐGRAYDirty.bmp')); 
    % DirtyImg=imread('lenaDirty.bmp'); 
    % DirtyImg=imread('lenaDirtyCon.bmp'); 
    % DirtyImg=imread('S_S_Denimb_tDirty.bmp'); 
    DirtyImg=imread('man-mask.png'); 
    figure(2);imshow(DirtyImg); 
    OriginalImg=double(OriginalImg); 
    DirtyImg=double(DirtyImg); 
    %»ñȡͼÏñ¿í¶ÈºÍ¸ß¶È 
    [width,height] = size(DirtyImg)
    dirtyMSE = 0.0; 
     for j = 1:height 
        for i = 1:width
            dirtyMSE=dirtyMSE+abs(OriginalImg(i,j)-DirtyImg(i,j)); 
        end 
     end 
    dirtyMSE = dirtyMSE/(width*height); 
    dirtyPSNR = 10*log10(255*255/dirtyMSE) 
    % Img = double(DirtyImg); 
    Img=double(DirtyImg); 
     
     
    U = Img; 
    V = Img; 
    IterTimes=100; 
    % MASK = imread('lakeMask.bmp'); 
    % [widthM,heightM] = size(MASK); 
    % for j = 1:height 
    %     for i = 1:width 
    % %         if Img(i,j) > 251 
    %         if Img(i,j) < 1 
    %             MASK(i,j) = 255; 
    %         else 
    %             MASK(i,j) = 0; 
    %         end 
    %     end 
    % end 
     
    %ÀûÓÃÂß¼*ÔËËãÌáÈ¡ÑÚÄ£ 
    % MASK=~(Img); %ÈËΪѡÔñãÐÖµ 
    MASK = (Img < 1); 
    % MASK = (Img > 251);%lena;¼¯ÊÐͼÏñ 
    figure(3);imshow(MASK); 
    %¼ÆËãÊÜËðÂÊ 
    badNum=0; 
    for j = 1:height 
        for i = 1:width 
            if MASK(i,j) == 1 
                badNum=badNum+1; 
            end 
        end 
    end 
    badRatio=badNum/(width*height) 
     
    % %½«¶þÖµÑÚÄ£ÖмäµÄ¿Õ¶´Ìî³ä£¬Ê¹Ö®³ÉΪ´¿´âµÄ¶þÖµÑÚÄ£ 
    % noborder=imclearborder(MASK,4); 
    % % figure,imshow(noborder) 
    % MASK=imfill(noborder,'holes'); 
    % figure,imshow(MASK); 
     
    tic; 
    %%ÎÆÀí·½Ïò(-2£¬3)¼´(m,n)È¡¾öÓÚ×ø±êϵµÄ·½Ïò£¬ÎÞËùν 
    %%ÓÃ×Ô¼ºµÄËã·¨ÇóµÃÎÆÀí·½ÏòΪ(-10£¬16) 
    %¶ÔÆäËûͼÏñ£¬ÈôÎÆÀíÔ½½ç£¬¿É½øÐнüËÆ 
    m=-2;n=3;%cloth 
    % m=1;n=0;%tv 
    %  m=-4;n=1;%gun 
    % m=-1;n=1; 
    iter=1; 
    a=1e-6; 
    while iter <= IterTimes 
        %¸üÐÂÐÞ¸´ÇøÓòÄÚÿµãÖµ 
        for i = 8:width-8 
            for j = 8:height-8 
    %             if (MASK(i,j+1) == 255)|(MASK(i,j-1) == 255)|(MASK(i+1,j) == 255)|(MASK(i-1,j) == 255) 
    %               if (MASK(i,j+1) == 1)|(MASK(i,j-1) == 1)|(MASK(i+1,j) == 1)|(MASK(i-1,j) == 1) 
    %                 if MASK(i,j)==255 
                lamda = 0.005; 
                if MASK(i,j) == 1 
    %                 if (MASK(i,j+2) == 1)|(MASK(i,j-2) == 1)|(MASK(i+2,j) == 1)|(MASK(i-2,j) == 1) 
                    %¼ÆËãw1,w2,w3,w4 
                    lamda = 0; 
                    gridUw2 = (V(i,j)-V(i-m,j-n))^2+(1.0/16)*(V(i+m-n,j+m+n)+V(i+n,j-m)-V(i-(m+n),j+m-n)-V(i-n,j+m))^2; 
                    gridUe2 = (V(i,j)-V(i+m,j+n))^2+(1.0/16)*(V(i+m+n,j-(m-n))+V(i+n,j-m)-V(i-n,j+m)-V(i-(m-n),j-(m+n)))^2; 
                    gridUs2 = (V(i,j)-V(i-n,j+m))^2+(1.0/16)*(V(i+m,j+n)+V(i-(m-n),j-(m+n))-V(i+m,j-n)-V(i-(m+n),j+m-n))^2; 
                    gridUn2 = (V(i,j)-V(i+n,j-m))^2+(1.0/16)*(V(i+m,j+n)+V(i+m+n,j-(m-n))-V(i+m-n,j+m+n)-V(i+m,j-n))^2; 
                    w1 = 1/sqrt(a*a+gridUw2); 
                    w2 = 1/sqrt(a*a+gridUe2); 
                    w3 = 1/sqrt(a*a+gridUs2); 
                    w4 = 1/sqrt(a*a+gridUn2); 
     
                    U(i,j) =(w1*V(i-m,j-n)+w2*V(i+m,j+n)+w3*V(i-n,j+m)+w4*V(i+n,j-m)+lamda*V(i,j))/(w1+w2+w3+w4+lamda); 
     
                end 
    %             gridUw2 = (V(i,j)-V(i-m,j-n))^2+(1.0/16)*(V(i+m-n,j+m+n)+V(i+n,j-m)-V(i-(m+n),j+m-n)-V(i-n,j+m))^2; 
    %             gridUe2 = (V(i,j)-V(i+m,j+n))^2+(1.0/16)*(V(i+m+n,j-(m-n))+V(i+n,j-m)-V(i-n,j+m)-V(i-(m-n),j-(m+n)))^2; 
    %             gridUs2 = (V(i,j)-V(i-n,j+m))^2+(1.0/16)*(V(i+m,j+n)+V(i-(m-n),j-(m+n))-V(i+m,j-n)-V(i-(m+n),j+m-n))^2; 
    %             gridUn2 = (V(i,j)-V(i+n,j-m))^2+(1.0/16)*(V(i+m,j+n)+V(i+m+n,j-(m-n))-V(i+m-n,j+m+n)-V(i+m,j-n))^2; 
    %             w1 = 1/sqrt(a*a+gridUw2); 
    %             w2 = 1/sqrt(a*a+gridUe2); 
    %             w3 = 1/sqrt(a*a+gridUs2); 
    %             w4 = 1/sqrt(a*a+gridUn2); 
    %  
    %             U(i,j) =(w1*V(i-m,j-n)+w2*V(i+m,j+n)+w3*V(i-n,j+m)+w4*V(i+n,j-m)+lamda*V(i,j))/(w1+w2+w3+w4+lamda); 
            end 
        end 
        a=a/5; 
        iter = iter+1; 
        V = U; 
    end 
    t = toc 
    Inpainted = V;
    imagesc(OriginalImg-V);
    inpaintedMSE = 0.0; 
     for j = 1:height 
        for i = 1:width 
            inpaintedMSE=inpaintedMSE+abs(OriginalImg(i,j)-Inpainted(i,j)); 
        end 
     end 
     inpaintedMSE = inpaintedMSE/(height*width) 
    inpaintedPSNR = 10*log10(255*255/inpaintedMSE) 
    figure(4);title('inpainted','FontWeight','bold');imshow(Inpainted,[]); 
    imwrite(uint8(Inpainted),'inpainted.bmp');

  2. #2
    Membre habitué
    Profil pro
    Doctorante
    Inscrit en
    Mai 2012
    Messages
    130
    Détails du profil
    Informations personnelles :
    Localisation : France

    Informations professionnelles :
    Activité : Doctorante

    Informations forums :
    Inscription : Mai 2012
    Messages : 130
    Points : 197
    Points
    197
    Par défaut
    1) Tu n'as pas fait cet algorithme sur Matlab. Tu l'as trouvé sur internet http://read.pudn.com/downloads177/so...ngTest.m__.htm où il y est depuis 2008.

    2) Si ta question est : comment afficher une image ? Regarde la fonction imshow.

    3) Si tu as des questions sur le code, dis-nous quelle ligne te pose problème mais essaye avant par toi-même. Pas de réponse toute faite ici!

  3. #3
    Candidat au Club
    Homme Profil pro
    Étudiant
    Inscrit en
    Août 2012
    Messages
    4
    Détails du profil
    Informations personnelles :
    Sexe : Homme
    Localisation : Algérie

    Informations professionnelles :
    Activité : Étudiant
    Secteur : Enseignement

    Informations forums :
    Inscription : Août 2012
    Messages : 4
    Points : 4
    Points
    4
    Par défaut
    merci mr pour votre réponce, mon question c'est comment enlever l'image de le personne et reste seulement l'image sans le personne je veus inpainter l'image
    le programme n'affiche pas la foto final qui est l'image sans le personne.

  4. #4
    Membre habitué
    Profil pro
    Doctorante
    Inscrit en
    Mai 2012
    Messages
    130
    Détails du profil
    Informations personnelles :
    Localisation : France

    Informations professionnelles :
    Activité : Doctorante

    Informations forums :
    Inscription : Mai 2012
    Messages : 130
    Points : 197
    Points
    197
    Par défaut
    ligne 149 du programme : L'image résultat est enregistrée. Pour afficher une image, tu peux utiliser la fonction imread et ensuite pour l'afficher la fonction imshow.

Discussions similaires

  1. [Débutant] Segmentation d'images médicales sous Matlab
    Par touma_T dans le forum Images
    Réponses: 2
    Dernier message: 27/05/2011, 20h49
  2. [Débutant] Image indexée sous matlab
    Par hamza85 dans le forum Images
    Réponses: 2
    Dernier message: 30/12/2010, 15h38
  3. Segmentation d'images couleurs
    Par Fractals dans le forum Traitement d'images
    Réponses: 2
    Dernier message: 06/12/2010, 15h28
  4. Réponses: 4
    Dernier message: 07/05/2008, 13h05
  5. Compression d'images satellites sous MATLAB
    Par soufiane121 dans le forum Images
    Réponses: 4
    Dernier message: 08/01/2008, 09h46

Partager

Partager
  • Envoyer la discussion sur Viadeo
  • Envoyer la discussion sur Twitter
  • Envoyer la discussion sur Google
  • Envoyer la discussion sur Facebook
  • Envoyer la discussion sur Digg
  • Envoyer la discussion sur Delicious
  • Envoyer la discussion sur MySpace
  • Envoyer la discussion sur Yahoo