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 :

Index exceeds matrix dimensions.


Sujet :

Images

  1. #1
    Membre à l'essai
    Homme Profil pro
    Inscrit en
    Novembre 2011
    Messages
    6
    Détails du profil
    Informations personnelles :
    Sexe : Homme

    Informations forums :
    Inscription : Novembre 2011
    Messages : 6
    Points : 12
    Points
    12
    Par défaut Index exceeds matrix dimensions.
    Salut, je n'ai pas trouvé la solution de ce erreur:
    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
    >> run('VLFEATROOT/toolbox/vl_setup');
    >> gridSpacing = 6;
    >> I = vl_impattern('roofs1') ;
    >> I = im2single(rgb2gray(I));
    >> [im_h, im_w] = size(I);
    >>  binSize = 16 ;
            magnif = 3 ;
            Is = vl_imsmooth(I, sqrt((binSize/magnif)^2 - .25)) ;
            [f,d] = vl_dsift(Is, 'size', binSize,'step',8) ;
            f(3,:) = binSize/magnif ;
            f(4,:) = 0 ;
            [f_, d_] = vl_sift(I, 'frames', f) ;
     
    >> d_=double(d_);
    for i=1:length(d_(1,:))
    x=sum(d_(:,i));
    for j=1:length(d_(:,1))
    d_(j,i)=d_(j,i)./x;
    end
    end;
    >> patchSize=16;
     
            remX = mod(im_w-patchSize,gridSpacing);
            offsetX = floor(remX/2)+1;
            remY = mod(im_h-patchSize,gridSpacing);
            offsetY = floor(remY/2)+1;
     
            [gridX,gridY] = meshgrid(offsetX:gridSpacing:im_w-patchSize+1, offsetY:gridSpacing:im_h-patchSize+1);
    >> 
    >> x = gridX(:) + binSize/2 - 0.5;
       y = gridY(:) + binSize/2 - 0.5; 
    >> pyramid = [1, 2, 4];                % spatial block structure for the SPM
    knn = 5;                            % number of neighbors for local coding
    c = 10;  
    >> load('C:\Program Files\MATLAB\MATLAB Production Server\R2013a\bin\workspace\New\dictionary\Caltech101_SIFT_Kmeans_1024.mat');
    >> B=B';
    >> d_=d_';
    >> nbase = size(B, 1);
    nframe = size(X, 1);
    Undefined function or variable 'X'.
     
    Did you mean:
    >> nbase = size(B, 1);
    nframe = size(d_, 1);
    >> idxBin = zeros(nframe, 1);
    >> % llc coding
            if ~exist('knn', 'var') || isempty(knn),
                knn = 5;
            end
     
            if ~exist('beta', 'var') || isempty(beta),
                beta = 1e-4;
            end
            % find k nearest neighbors
            XX = sum(X.*X, 2);
            BB = sum(B.*B, 2);
            D  = repmat(XX, 1, nbase)-2*X*B'+repmat(BB', nframe, 1);
            IDX = zeros(nframe, knn);
            for i = 1:nframe,
                d = D(i,:);
                [dummy, idx] = sort(d, 'ascend');
                IDX(i, :) = idx(1:knn);
            end
    Undefined function or variable 'X'.
     
    Did you mean:
    >> % llc coding
            if ~exist('knn', 'var') || isempty(knn),
                knn = 5;
            end
     
            if ~exist('beta', 'var') || isempty(beta),
                beta = 1e-4;
            end
            % find k nearest neighbors
            XX = sum(d_.*d_, 2);
            BB = sum(B.*B, 2);
            D  = repmat(XX, 1, nbase)-2*d_*B'+repmat(BB', nframe, 1);
            IDX = zeros(nframe, knn);
            for i = 1:nframe,
                d = D(i,:);
                [dummy, idx] = sort(d, 'ascend');
                IDX(i, :) = idx(1:knn);
            end
    >> % llc approximation coding
            II = eye(knn, knn);
            Coeff = zeros(nframe, nbase);
            for i=1:nframe
            idx = IDX(i,:);
            z = B(idx,:) - repmat(d_(i,:), knn, 1);           % shift ith pt to origin
            C = z*z';                                        % local covariance
            C = C + II*beta*trace(C);                        % regularlization (K>D)
            w = C\ones(knn,1);
            w = w/sum(w);                                    % enforce sum(w)=1
            Coeff(i,idx) = w';
            end
    >> llc_codes=Coeff';
    >> 
            % spatial levels
    pLevels = length(pyramid);
    % spatial bins on each level
    pBins = pyramid.^2;
    % total spatial bins
    tBins = sum(pBins);
     
    beta = zeros(1024, tBins);
    bId = 0;
    >> for iter1 = 1:pLevels,
     
        nBins = pBins(iter1);
     
        wUnit = im_w / pyramid(iter1);
        hUnit = im_h / pyramid(iter1);
     
        % find to which spatial bin each local descriptor belongs
        xBin = ceil(x / wUnit);
        yBin = ceil(y / hUnit);
        idxBin = (yBin - 1)*pyramid(iter1) + xBin;
     
        for iter2 = 1:nBins,     
            bId = bId + 1;
            sidxBin = find(idxBin == iter2);
            if isempty(sidxBin),
                continue;
            end      
            beta(:, bId) = max(llc_codes(:, sidxBin), [], 2);
        end
    end
    erreur:
    Index exceeds matrix dimensions.

  2. #2
    Modérateur

    Homme Profil pro
    Ingénieur en calculs scientifiques
    Inscrit en
    Août 2007
    Messages
    4 639
    Détails du profil
    Informations personnelles :
    Sexe : Homme
    Localisation : Royaume-Uni

    Informations professionnelles :
    Activité : Ingénieur en calculs scientifiques

    Informations forums :
    Inscription : Août 2007
    Messages : 4 639
    Points : 7 614
    Points
    7 614
    Par défaut
    Bonjour,

    tout d'abord, un conseil, utilise l'éditeur de code de matlab, tu pourras y copier tout ton code et après avoir enregistré le fichier, tu pourras éxécuter le code en entier. Le code sera alors plus facile à débugguer.

    Il y a des erreurs à corriger avant la dernière que tu nous montres, par exemple ligne 38 :
    Code : Sélectionner tout - Visualiser dans une fenêtre à part
    1
    2
    3
    >> nbase = size(B, 1);
    nframe = size(X, 1);
    Undefined function or variable 'X'.
    Matlab te propose une correction, mais dans ce cas, il y a peu de chance que la correction proposée soit juste. Pour comprendre et corriger les messages d'erreurs, voir la :
    http://matlab.developpez.com/faq-erreurs/
    Pour une bonne utilisation des balises code c'est ici!
    Petit guide du voyageur MATLABien : Le forum La faq Les tutoriels Les sources


    La nature est un livre écrit en langage mathématique. Galilée.

Discussions similaires

  1. Réponses: 1
    Dernier message: 29/01/2010, 21h01
  2. "Index exceeds matrix dimensions. " erreur
    Par M.Chaabane dans le forum MATLAB
    Réponses: 2
    Dernier message: 04/11/2008, 16h54
  3. error : index exceeds matrix dimensions
    Par spinalrock dans le forum Images
    Réponses: 21
    Dernier message: 29/05/2008, 11h18
  4. Message d'erreur "Index exceeds matrix dimensions."
    Par bela1280 dans le forum MATLAB
    Réponses: 1
    Dernier message: 21/04/2007, 13h27
  5. Erreur "Index exceeds matrix dimensions"
    Par usama2 dans le forum MATLAB
    Réponses: 2
    Dernier message: 06/03/2007, 00h34

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