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

Interfaces Graphiques Discussion :

Accélération code dans interface


Sujet :

Interfaces Graphiques

Vue hybride

Message précédent Message précédent   Message suivant Message suivant
  1. #1
    Membre averti
    Femme Profil pro
    Étudiant
    Inscrit en
    Février 2012
    Messages
    17
    Détails du profil
    Informations personnelles :
    Sexe : Femme
    Localisation : France

    Informations professionnelles :
    Activité : Étudiant
    Secteur : High Tech - Électronique et micro-électronique

    Informations forums :
    Inscription : Février 2012
    Messages : 17
    Par défaut Accélération code dans interface
    bonjour, je suis entrain de créer une interface graphique sous matlab(gui) et il se trouve que j'ai créé un bouton poussoir lorsqu'on clique sur celui ci une fonction est appelée et normalement on doit voir le résultat s'afficher sur les axes définis mais il se trouve que cet affichage est très lent par rapport au cas sans interface j'aimerai obtenir de l'aide .merci

  2. #2
    Expert confirmé
    Avatar de duf42
    Homme Profil pro
    Formateur en informatique
    Inscrit en
    Novembre 2007
    Messages
    3 111
    Détails du profil
    Informations personnelles :
    Sexe : Homme
    Âge : 41
    Localisation : France

    Informations professionnelles :
    Activité : Formateur en informatique
    Secteur : High Tech - Éditeur de logiciels

    Informations forums :
    Inscription : Novembre 2007
    Messages : 3 111
    Par défaut
    Bonjour,

    Pourrais-tu nous montrer le code?

    Duf

  3. #3
    Membre averti
    Femme Profil pro
    Étudiant
    Inscrit en
    Février 2012
    Messages
    17
    Détails du profil
    Informations personnelles :
    Sexe : Femme
    Localisation : France

    Informations professionnelles :
    Activité : Étudiant
    Secteur : High Tech - Électronique et micro-électronique

    Informations forums :
    Inscription : Février 2012
    Messages : 17
    Par défaut
    oui

    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
    150
    151
    152
    153
    154
    155
    156
    157
    158
    159
    160
    161
    162
    163
    164
    165
    166
    167
    168
    169
    170
    171
    172
    173
    174
    175
    176
    177
    178
    179
    180
    181
    182
    183
    184
    185
    186
    187
    188
    189
    190
    191
    192
    193
    194
    195
    196
    197
    198
    199
    200
    201
    202
    203
    204
    205
    206
    207
    208
    209
    210
    211
    212
    213
    214
    215
    216
    217
    218
    219
    220
    221
    222
    223
    224
    225
    226
    227
    228
    229
    230
    231
    232
    233
    234
    235
    236
    237
    238
    239
    240
    241
    242
    243
    244
    245
    246
    247
    248
    249
    250
    251
    252
    253
    254
    255
    256
    257
    258
    259
    260
    261
    262
    263
    264
    265
    266
    267
    268
    269
    270
    271
    272
    273
    274
    275
    276
    277
    278
    279
    280
    281
    282
    283
    284
    285
    286
    287
    288
    289
    290
    291
    292
    293
    294
    295
    296
    297
    298
    299
    300
    301
    302
    303
    304
    305
    306
    307
    308
    309
    310
    311
    312
    313
    314
    315
    316
    317
    318
    319
    320
    321
    322
    323
    324
    325
    326
    327
    328
    329
    330
    331
    332
    333
    334
    335
    336
    337
    338
    339
    340
    341
    342
    343
    344
    345
    346
    347
    348
    349
    350
    351
    352
    353
    354
    355
    356
    357
    358
    359
    360
    361
    362
    363
    364
    365
    366
    367
    368
    369
    370
    371
    372
    373
    374
    375
    376
    377
    378
    379
    380
    381
    382
    383
    384
    385
    386
    387
    388
    389
    390
    391
    392
    393
    394
    function varargout = analysis(varargin)
    % ANALYSIS M-file for analysis.fig
    %      ANALYSIS, by itself, creates a new ANALYSIS or raises the existing
    %      singleton*.
    %
    %      H = ANALYSIS returns the handle to a new ANALYSIS or the handle to
    %      the existing singleton*.
    %
    %      ANALYSIS('CALLBACK',hObject,eventData,handles,...) calls the local
    %      function named CALLBACK in ANALYSIS.M with the given input arguments.
    %
    %      ANALYSIS('Property','Value',...) creates a new ANALYSIS or raises the
    %      existing singleton*.  Starting from the left, property value pairs are
    %      applied to the GUI before analysis_OpeningFunction gets called.  An
    %      unrecognized property name or invalid value makes property application
    %      stop.  All inputs are passed to analysis_OpeningFcn via varargin.
    %
    %      *See GUI Options on GUIDE's Tools menu.  Choose "GUI allows only one
    %      instance to run (singleton)".
    %
    % See also: GUIDE, GUIDATA, GUIHANDLES
     
    % Copyright 2002-2003 The MathWorks, Inc.
     
    % Edit the above text to modify the response to help analysis
     
    % Last Modified by GUIDE v2.5 04-May-2012 10:20:47
     
    % Begin initialization code - DO NOT EDIT
    gui_Singleton = 1;
    gui_State = struct('gui_Name',       mfilename, ...
        'gui_Singleton',  gui_Singleton, ...
        'gui_OpeningFcn', @analysis_OpeningFcn, ...
        'gui_OutputFcn',  @analysis_OutputFcn, ...
        'gui_LayoutFcn',  [] , ...
        'gui_Callback',   []);
    if nargin && ischar(varargin{1})
        gui_State.gui_Callback = str2func(varargin{1});
    end
     
    if nargout
        [varargout{1:nargout}] = gui_mainfcn(gui_State, varargin{:});
    else
        gui_mainfcn(gui_State, varargin{:});
    end
    % End initialization code - DO NOT EDIT
     
     
    % --- Executes just before analysis is made visible.
    function analysis_OpeningFcn(hObject, eventdata, handles, varargin)
    % This function has no output args, see OutputFcn.
    % hObject    handle to figure
    % eventdata  reserved - to be defined in a future version of MATLAB
    % handles    structure with handles and user data (see GUIDATA)
    % varargin   command line arguments to analysis (see VARARGIN)
    handles.banner = imread('C:\Documents and Settings\Administrateur\Bureau\tete_psi_interface\Copie de 3D.jpg', 'jpg');
    axes(handles.axes1);
    image(handles.banner)
     
    handles.X = imread('C:\Documents and Settings\Administrateur\Bureau\tete_psi_interface\3D.jpg', 'jpg');
    axes(handles.axes2);
    image(handles.X)
     
    % Choose default command line output for analysis
    handles.output = hObject;
     
    % Update handles structure
    guidata(hObject, handles);
     
    % UIWAIT makes analysis wait for user response (see UIRESUME)
    % uiwait(handles.figure1);
     
     
    % --- Outputs from this function are returned to the command line.
    function varargout = analysis_OutputFcn(hObject, eventdata, handles)
    % varargout  cell array for returning output args (see VARARGOUT);
    % hObject    handle to figure
    % eventdata  reserved - to be defined in a future version of MATLAB
    % handles    structure with handles and user data (see GUIDATA)
     
    % Get default command line output from handles structure
    varargout{1} = handles.output;
     
     
    % --- Executes on selection change in popupmenu1.
    function popupmenu1_Callback(hObject, eventdata, handles)
    % hObject    handle to popupmenu1 (see GCBO)
    % eventdata  reserved - to be defined in a future version of MATLAB
    % handles    structure with handles and user data (see GUIDATA)
     
    % Hints: contents = get(hObject,'String') returns popupmenu1 contents as cell array
    %        contents{get(hObject,'Value')} returns selected item from popupmenu1
     
     
    % --- Executes during object creation, after setting all properties.
    function popupmenu1_CreateFcn(hObject, eventdata, handles)
    % hObject    handle to popupmenu1 (see GCBO)
    % eventdata  reserved - to be defined in a future version of MATLAB
    % handles    empty - handles not created until after all CreateFcns called
     
    % Hint: popupmenu controls usually have a white background on Windows.
    %       See ISPC and COMPUTER.
    if ispc
        set(hObject,'BackgroundColor','white');
    else
        set(hObject,'BackgroundColor',get(0,'defaultUicontrolBackgroundColor'));
    end
     
     
    % --- Executes on button press in pushbutton1.
    function pushbutton1_Callback(hObject, eventdata, handles)
    % hObject    handle to pushbutton1 (see GCBO)
    % eventdata  reserved - to be defined in a future version of MATLAB
    % handles    structure with handles and user data (see GUIDATA)
    %Let the user select the file
    [FileName,PathName] = uigetfile({'*.bmp'},'Select the first intensity image');
    %combine the filename and pathname
    directory=strcat(PathName ,FileName);
    %.bmp check file extension
    ext=findstr(FileName,'.bmp');
    n=isempty(ext);
    if n==0
        I1=double(imread(directory));
     
    end
     
     
    I1=medfilt2(I1);
    Imax=max(max(abs(I1)));
    Imin=min(min(abs(I1)));
    I1=((((I1-Imin)/(Imax-Imin))));
    setappdata(0,'I1',I1)
    axes(handles.axes3);
    imshow(I1)
     
    % axes3,imshow(I1);
     
    % --- Executes on button press in pushbutton2.
    function pushbutton2_Callback(hObject, eventdata, handles)
    % hObject    handle to pushbutton2 (see GCBO)
    % eventdata  reserved - to be defined in a future version of MATLAB
    % handles    structure with handles and user data (see GUIDATA)
    %Let the user select the file
    [FileName,PathName] = uigetfile({'*.bmp'},'Select the second intensity image');
    %combine the filename and pathname
    directory=strcat(PathName ,FileName);
    %.bmp check file extension
    ext=findstr(FileName,'.bmp');
    n=isempty(ext);
    if n==0
        I2=double(imread(directory));
     
    end
    I2=medfilt2(I2);
    Imax=max(max(abs(I2)));
    Imin=min(min(abs(I2)));
    I2=((((I2-Imin)/(Imax-Imin))));
    setappdata(0,'I2',I2)
    axes(handles.axes3);
    imshow(I2);
     
    % --- Executes on button press in pushbutton3.
    function pushbutton3_Callback(hObject, eventdata, handles)
    % hObject    handle to pushbutton3 (see GCBO)
    % eventdata  reserved - to be defined in a future version of MATLAB
    % handles    structure with handles and user data (see GUIDATA)
    %Let the user select the file
    [FileName,PathName] = uigetfile({'*.bmp'},'Select the third  intensity image');
    %combine the filename and pathname
    directory=strcat(PathName ,FileName);
    %.bmp check file extension
    ext=findstr(FileName,'.bmp');
    n=isempty(ext);
    if n==0
        I3=double(imread(directory));
     
    end
     
    I3=medfilt2(I3);
    Imax=max(max(abs(I3)));
    Imin=min(min(abs(I3)));
    I3=((((I3-Imin)/(Imax-Imin))));
    setappdata(0,'I3',I3)
    axes(handles.axes3);
    imshow(I3);
     
    % --- Executes on button press in pushbutton4.
    function pushbutton4_Callback(hObject, eventdata, handles)
    % hObject    handle to pushbutton4 (see GCBO)
    % eventdata  reserved - to be defined in a future version of MATLAB
    % handles    structure with handles and user data (see GUIDATA)
    %Let the user select the file
    [FileName,PathName] = uigetfile({'*.bmp'},'Select the texture  image');
    %combine the filename and pathname
    directory=strcat(PathName ,FileName);
    %.bmp check file extension
    ext=findstr(FileName,'.bmp');
    n=isempty(ext);
    if n==0
        [A]=importdata(directory);
     
    end
    C=struct2cell(A);
    ref=C{1,1};
    ref=double(ref);
    map=C{2,1};
    setappdata(0,'ref',ref)
    setappdata(0,'map',map)
    axes(handles.axes3);
    imagesc(ref),colormap(map)
     
     
    % --- Executes on button press in pushbutton5.
    function pushbutton5_Callback(hObject, eventdata, handles)
    % hObject    handle to pushbutton5 (see GCBO)
    % eventdata  reserved - to be defined in a future version of MATLAB
    % handles    structure with handles and user data (see GUIDATA)
    %***************************CALCUL DE LA PHASE ***********************************************
     
    I1=getappdata(0,'I1');
    I2=getappdata(0,'I2');
    I3=getappdata(0,'I3');
    [N,M]=size(I1);
    setappdata(0,'N',N)
    valsin=I3-I2;
    sinsign=sign(valsin);
    valcos=I1-I2;
    cossign=sign(valcos);
    %***************ici on évite la division par zéro*******************************
    for i=1:N
        for j=1:M
            if(valcos(i,j)==0)
                valcos(i,j)=eps;
            end
        end
    end
    betta=(valsin./valcos);
    phase1=atan(betta);
    for i=1:N
        for j=1:M
            if((sinsign(i,j)==0) && (cossign(i,j)==1))
                phase1(i,j)=0;
            elseif((sinsign(i,j)==1) && (cossign(i,j)==0))
                phase1(i,j)=pi/2;
            elseif((sinsign(i,j)==1) && (cossign(i,j)==-1))
                phase1(i,j)=phase1(i,j)+pi;
            elseif((sinsign(i,j)==0) && (cossign(i,j)==-1))
                phase1(i,j)=pi;
            elseif((sinsign(i,j)==-1) && (cossign(i,j)==-1))
                phase1(i,j)=phase1(i,j)+pi;
            elseif((sinsign(i,j)==-1) && (cossign(i,j)==0))
                phase1(i,j)=3*pi/2;
            elseif((sinsign(i,j)==-1) && (cossign(i,j)==1))
                phase1(i,j)=phase1(i,j)+2*pi;
            else
                phase1(i,j)=phase1(i,j);
            end
        end
    end
    phase_obj=phase1;
    axes(handles.axes3);
    imagesc(phase_obj),colormap(gray)
    setappdata(0,'phase_obj',phase_obj)
     
     
     
    % c'est la mon probleme le deroulement est tres tres lent en plus il se bloque
     
     
     
     
    % --- Executes on button press in pushbutton6.
    function pushbutton6_Callback(hObject, eventdata, handles)
    % hObject    handle to pushbutton6 (see GCBO)
    % eventdata  reserved - to be defined in a future version of MATLAB
    % handles    structure with handles and user data (see GUIDATA)
    %======================= DEROULEMENT DE PHASE   ====================================
    phase_obj=getappdata(0,'phase_obj');
     
    [objet_deroule] = cunwrap(phase_obj);
    axes(handles.axes3);
    % objet_deroule=objet_deroule;
    %
    % for i=1:size(objet_deroule,1)
    %     deltaphi=objet_deroule(i,:);
    %     for j=1:size(objet_deroule,2)-2
    %         deltapha=deltaphi(j+1)-deltaphi(j);
    %         if(abs(deltapha)>(0))
    %            deltaphi(j+1)=(deltaphi(j)+deltaphi(j+2))/2;
    %         end
    %     end
    %       objet_deroule(i,:)=deltaphi;
    % end
    % imagesc(objet_deroule),colormap(gray)
     
    surf(objet_deroule,'FaceColor','interp', 'EdgeColor','none', 'FaceLighting','phong')
    %  view(-30,30), camlight left, axis tight,title('Phase du plan + forme déroulée ')
    %  xlabel('Pixels'), ylabel('Pixels'), zlabel('Phase en radians')
    setappdata(0,'objet_deroule',objet_deroule)
     
     
    % --- Executes on button press in pushbutton7.
    function pushbutton7_Callback(hObject, eventdata, handles)
    % hObject    handle to pushbutton7 (see GCBO)
    % eventdata  reserved - to be defined in a future version of MATLAB
    % handles    structure with handles and user data (see GUIDATA)
     
    objet_deroule=getappdata(0,'objet_deroule');
    sss=objet_deroule;
    ii=1;
    vect=sss(ii,:);
    maxx=max(vect);
    for j=1:length(vect)
        if(vect(j)~=0)
            minn=vect(j);
            k=j;
            break,end
    end
     
    for i=1:length(vect)
        if(vect(i)==maxx)
            k1=i;
            break,end
    end
    tt=(maxx-minn)/(k1-k);
    b=((maxx+minn)-(tt*(k+k1)))/2;
    for i=k:k1
        vect_ref(i)=(tt*i)+b;
    end
    vect_ref(1:k-1)=0;
    vect_ref(k1+1:length(vect))=0;
     
    for i=1:size(sss,1)
        for j=1:size(sss,2)
            ref_ref(i,:)=vect_ref;
        end
    end
    for i=1:size(sss,1)
        for j=1:size(sss,2)
            if( sss(i,j)~=0)
                objet(i,j)=sss(i,j)-ref_ref(i,j);
            end
        end
    end
    B=[0 1 0;1 0 1;0 1 0];
    objet= FILTER2(B,objet,'same');
    % ***********************************CREATION DU MASQUE ***********************************************************************************************
    i=imread('C:\Documents and Settings\Administrateur\Bureau\ffta+dpd\te\te_tex.bmp');
    i=i(:,115:440);
    imshow(i)
    j=double(i);
    [row col ]=size(j);
    T1=0;
    T2=24;
    for x=1:1:row             % from 1st row to last row with increment 1
        for y=1:1:col         % from 1st col to last col with increment 2
            if((j(x,y)>=T1) && (j(x,y)<=T2))
                j(x,y)=255;
            else
                j(x,y)=0;
            end
        end
    end
    j=medfilt2(j);
    masq=(j==0);
    masq=medfilt2(masq);
    masq=medfilt2(masq);
    masq=medfilt2(masq);
    masq=medfilt2(masq);
    mask=medfilt2(masq);
     
    %  mask=getappdata(0,'mask');
    axes(handles.axes3);
    objet=objet.*mask;
    for i=1:size(sss,1)
        for j=1:size(sss,2)
            if( objet(i,j)==0)
                objet(i,j)=nan;
            end
        end
    end
    objet=medfilt2(objet);
    objet=medfilt2(objet);
    objet=medfilt2(objet);
    objet=medfilt2(objet);
    objet=medfilt2(objet);
    objet=flipud(objet);
    mesh((objet))
    ref=getappdata(0,'ref');
    map=getappdata(0,'map');
    h = findobj('Type','surface');
    hem =[ref];
    set(h,'CData',flipud(hem),'FaceColor','texturemap'),colormap(map)
    rotate3d on ;

  4. #4
    Invité
    Invité(e)
    Par défaut
    Bonjour,

    Je te conseille la lecture de la Qu'est-ce que la préallocation de mémoire ?.
    Tes boucles sont simplifiables en utilisant la vectorisation, et surtout l'indexage logique.
    Par exemple :
    Code : Sélectionner tout - Visualiser dans une fenêtre à part
    1
    2
    3
    4
    5
    6
    7
    for i=1:N
        for j=1:M
            if(valcos(i,j)==0)
                valcos(i,j)=eps;
            end
        end
    end
    valcos(valcos==0) = eps;.
    Et
    Code : Sélectionner tout - Visualiser dans une fenêtre à part
    1
    2
    3
    4
    5
    6
    7
    8
    9
    for x=1:1:row             % from 1st row to last row with increment 1
        for y=1:1:col         % from 1st col to last col with increment 2
            if((j(x,y)>=T1) && (j(x,y)<=T2))
                j(x,y)=255;
            else
                j(x,y)=0;
            end
        end
    end
    j = 255*(j>=T1 & j<=T2);
    Code : Sélectionner tout - Visualiser dans une fenêtre à part
    1
    2
    3
    4
    5
    masq=medfilt2(masq);
    masq=medfilt2(masq);
    masq=medfilt2(masq);
    masq=medfilt2(masq);
    mask=medfilt2(masq);
    Ne serait-ce pas plus simple de renseigner la deuxième entrée :
    Code : Sélectionner tout - Visualiser dans une fenêtre à part
    masq=medfilt2(masq,[m n]);

  5. #5
    Membre averti
    Femme Profil pro
    Étudiant
    Inscrit en
    Février 2012
    Messages
    17
    Détails du profil
    Informations personnelles :
    Sexe : Femme
    Localisation : France

    Informations professionnelles :
    Activité : Étudiant
    Secteur : High Tech - Électronique et micro-électronique

    Informations forums :
    Inscription : Février 2012
    Messages : 17
    Par défaut
    oui, c'est vrai que c'est plus simple comme ça .merci à vous.

+ Répondre à la discussion
Cette discussion est résolue.

Discussions similaires

  1. Compilation de code Pascal dans interface web
    Par boumadien dans le forum Développement Web en Java
    Réponses: 3
    Dernier message: 02/05/2015, 11h50
  2. Comparaison de code dans plusieurs modules
    Par jbaudin dans le forum Access
    Réponses: 2
    Dernier message: 03/10/2005, 11h47
  3. [C#]ajout code dans code behind
    Par liliprog dans le forum ASP.NET
    Réponses: 8
    Dernier message: 21/06/2005, 11h03
  4. [VBA Excel] Comment écrire un code dans le ThisWorkBook ?
    Par WebPac dans le forum Macros et VBA Excel
    Réponses: 3
    Dernier message: 03/05/2005, 15h03

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