Changeset 388 for trunk/src/civ.m


Ignore:
Timestamp:
Apr 6, 2012, 4:37:12 PM (12 years ago)
Author:
sommeria
Message:

several bugs corrected
file indexing, color images...

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/civ.m

    r387 r388  
    919919    drawnow
    920920end
    921 % datnum=[];
    922921Tabchar={};
    923922nbfiles=numel(civ_files);
     
    11691168nbfield=numel(i1_civ1);
    11701169nbslice=numel(j1_civ1);
     1170if ~strcmp(CivMode,'CivX')
     1171    [Param.Civ1.FileTypeA,FileInfo,Param.Civ1.ImageA]=get_file_type(filecell.ima1.civ1{1});
     1172    [Param.Civ1.FileTypeB,FileInfo,Param.Civ1.ImageB]=get_file_type(filecell.ima2.civ1{1});
     1173end
    11711174
    11721175%% MAIN LOOP
     
    12191222            Param.Civ1.ImageHeight=ImageInfo.Height;
    12201223            Param.Civ1.ImageBitDepth=ImageInfo.BitDepth;
     1224            Param.Civ1.i1=i1_civ1;
     1225            Param.Civ1.i2=i2_civ1;
    12211226            % read mask parameters
    12221227            if Param.Civ1.CheckMask % the lines below should be changed with the new gui
     
    12271232                    [RootPathMask,RootFileMask]=fileparts(maskbase);
    12281233                    Param.Civ1.Mask=fullfile_uvmat(RootPathMask,[],RootFileMask,'.png','_1',i1_mask);
    1229                    % Param.Civ1.Mask=name_generator(maskbase,i1_mask,1,'.png','_i');
    12301234                end
    12311235            end
     
    13881392            Param.Civ2.ImageHeight=ImageInfo.Height;
    13891393            Param.Civ2.ImageBitDepth=ImageInfo.BitDepth;
     1394            Param.Civ2.i1=i1_civ2;
     1395            Param.Civ2.i2=i2_civ2;
    13901396            % TODO: case of movie   
    13911397            switch CivMode
     
    17961802%------------------------------------------------------------------------
    17971803filecell=[];%default
     1804ListProgram=get(handles.ListProgram,'String');
     1805CivMode=ListProgram{get(handles.ListProgram,'Value')};%Program to use , CivX or Matlab
    17981806
    17991807%% get the root name and check dir
     
    18091817    return
    18101818end
    1811 [xx,message]=fileattrib(RootPath);
     1819[tild,message]=fileattrib(RootPath);
    18121820if ~isempty(message) && ~isequal(message.UserWrite,1)
    18131821    msgbox_uvmat('ERROR',['No writting access to ' RootPath])
     
    24142422set(handles.SubdirCiv2,'String',subdir_civ2);%update the edit box
    24152423
    2416 %COPY IMAGES TO THE FORMAT .png IF NEEDED
    2417 if isequal(NomType_ima1,'*')%case of movie files
    2418     NomType_imanew1='_i';
    2419 else
    2420     NomType_imanew1=NomType_ima1;
    2421 end
    2422 if isequal(NomType_ima2,'*')%case of movie files
    2423     NomType_imanew2='_i';
    2424 else
    2425     NomType_imanew2=NomType_ima2;
    2426 end
    2427 if ~isequal(ext_ima,'.png')
    2428     %%type of image file
    2429     type_ima1='none';%default
    2430     movieobject1=[];%default
    2431     if strcmpi(ext_ima,'.avi')
    2432         if ~isempty(which('mmreader'))% if the mmreader function is found (recent version of matlab)
    2433             type_ima1='movie';
    2434             movieobject1=mmreader([filecell.filebase ext_ima]);
    2435         else
    2436             type_ima1='avi';
    2437         end
    2438     elseif ischar(ext_ima) && ~isempty(ext_ima(2:end))
    2439         form=imformats(ext_ima(2:end));
    2440         if ~isempty(form)% if the extension corresponds to an image format recognized by Matlab
    2441             if isequal(NomType_ima1,'*');
    2442                 type_ima1='multimage';%image series in a single image file
     2424% For CivX COPY IMAGES TO THE FORMAT .png IF NEEDED
     2425if strcmp(CivMode,'CivX')
     2426    if isequal(NomType_ima1,'*')%case of movie files
     2427        NomType_imanew1='_i';
     2428    else
     2429        NomType_imanew1=NomType_ima1;
     2430    end
     2431    if isequal(NomType_ima2,'*')%case of movie files
     2432        NomType_imanew2='_i';
     2433    else
     2434        NomType_imanew2=NomType_ima2;
     2435    end
     2436    if ~isequal(ext_ima,'.png')
     2437        %%type of image file
     2438        type_ima1='none';%default
     2439        movieobject1=[];%default
     2440        if strcmpi(ext_ima,'.avi')
     2441            if ~isempty(which('mmreader'))% if the mmreader function is found (recent version of matlab)
     2442                type_ima1='movie';
     2443                movieobject1=mmreader([filecell.filebase ext_ima]);
    24432444            else
    2444                 type_ima1='image';
    2445             end
    2446         end
    2447     end
    2448     type_ima2='none';%default
    2449     movieobject2=[];
    2450     if strcmpi(ext_ima,'.avi')
    2451         if ~isempty(which('mmreader'))% if the mmreader function is found (recent version of matlab)
    2452             type_ima2='movie';
    2453             movieobject2=mmreader([filecell.filebase ext_ima]);
    2454         else
    2455             type_ima2='avi';
    2456         end
    2457     elseif ischar(ext_ima) && ~isempty(ext_ima(2:end))
    2458         form=imformats(ext_ima(2:end));
    2459         if ~isempty(form)% if the extension corresponds to an image format recognized by Matlab
    2460             if isequal(NomType_ima1,'*');
    2461                 type_ima2='multimage';%image series in a single image file
     2445                type_ima1='avi';
     2446            end
     2447        elseif ischar(ext_ima) && ~isempty(ext_ima(2:end))
     2448            form=imformats(ext_ima(2:end));
     2449            if ~isempty(form)% if the extension corresponds to an image format recognized by Matlab
     2450                if isequal(NomType_ima1,'*');
     2451                    type_ima1='multimage';%image series in a single image file
     2452                else
     2453                    type_ima1='image';
     2454                end
     2455            end
     2456        end
     2457        type_ima2='none';%default
     2458        movieobject2=[];
     2459        if strcmpi(ext_ima,'.avi')
     2460            if ~isempty(which('mmreader'))% if the mmreader function is found (recent version of matlab)
     2461                type_ima2='movie';
     2462                movieobject2=mmreader([filecell.filebase ext_ima]);
    24622463            else
    2463                 type_ima2='image';
    2464             end
    2465         end
    2466     end
    2467     if checkbox(1) %if civ1 is performed
    2468         h = waitbar(0,'copy images to the .png format for civ1');% display a wait bar
    2469         for ifile=1:nbfield
    2470             waitbar(ifile/nbfield);
    2471             for j=1:nbslice
    2472                 filename=fullfile_uvmat(RootPath,[],RootFile_ima1,'.png',NomType_imanew1,i1_civ1(ifile),[],j1_civ1(j));
    2473                 if ~exist(filename,'file')
    2474                     A=read_image(filecell.ima1.civ1{ifile,j},type_ima1,i1_civ1(ifile),movieobject1);
    2475                     imwrite(A,filename,'BitDepth',16);
     2464                type_ima2='avi';
     2465            end
     2466        elseif ischar(ext_ima) && ~isempty(ext_ima(2:end))
     2467            form=imformats(ext_ima(2:end));
     2468            if ~isempty(form)% if the extension corresponds to an image format recognized by Matlab
     2469                if isequal(NomType_ima1,'*');
     2470                    type_ima2='multimage';%image series in a single image file
     2471                else
     2472                    type_ima2='image';
    24762473                end
    2477                 filecell.ima1.civ1(ifile,j)={filename};
    2478                 filename=fullfile_uvmat(RootPath,[],RootFile_ima2,'.png',NomType_imanew2,i2_civ1(ifile),[],j2_civ1(j));
    2479                 if ~exist(filename,'file')
    2480                     A=read_image(filecell.ima2.civ1{ifile,j},type_ima2,i2_civ1(ifile),movieobject2);
    2481                     imwrite(A,filename,'BitDepth',16);
     2474            end
     2475        end
     2476        if checkbox(1) %if civ1 is performed
     2477            h = waitbar(0,'copy images to the .png format for civ1');% display a wait bar
     2478            for ifile=1:nbfield
     2479                waitbar(ifile/nbfield);
     2480                for j=1:nbslice
     2481                    filename=fullfile_uvmat(RootPath,[],RootFile_ima1,'.png',NomType_imanew1,i1_civ1(ifile),[],j1_civ1(j));
     2482                    if ~exist(filename,'file')
     2483                        A=read_image(filecell.ima1.civ1{ifile,j},type_ima1,i1_civ1(ifile),movieobject1);
     2484                        imwrite(A,filename,'BitDepth',16);
     2485                    end
     2486                    filecell.ima1.civ1(ifile,j)={filename};
     2487                    filename=fullfile_uvmat(RootPath,[],RootFile_ima2,'.png',NomType_imanew2,i2_civ1(ifile),[],j2_civ1(j));
     2488                    if ~exist(filename,'file')
     2489                        A=read_image(filecell.ima2.civ1{ifile,j},type_ima2,i2_civ1(ifile),movieobject2);
     2490                        imwrite(A,filename,'BitDepth',16);
     2491                    end
     2492                    filecell.ima2.civ1(ifile,j)={filename};
    24822493                end
    2483                 filecell.ima2.civ1(ifile,j)={filename};
    2484             end
    2485         end
    2486         close(h)
    2487     end
    2488     if checkbox(4) %if civ2 is performed
    2489         h = waitbar(0,'copy images to the .png format for civ2');% display a wait bar
    2490         for ifile=1:nbfield
    2491             waitbar(ifile/nbfield);
    2492             for j=1:nbslice
    2493                 filename=fullfile_uvmat(RootPath,[],RootFile_ima1,'.png',NomType_imanew1,i1_civ2(ifile),[],j1_civ2(j));
    2494                 if ~exist(filename,'file')
    2495                     A=read_image(cell2mat(filecell.ima1.civ2(ifile,j)),type_ima2,i1_civ2(ifile));
    2496                     imwrite(A,filename,'BitDepth',16);
     2494            end
     2495            close(h)
     2496        end
     2497        if checkbox(4) %if civ2 is performed
     2498            h = waitbar(0,'copy images to the .png format for civ2');% display a wait bar
     2499            for ifile=1:nbfield
     2500                waitbar(ifile/nbfield);
     2501                for j=1:nbslice
     2502                    filename=fullfile_uvmat(RootPath,[],RootFile_ima1,'.png',NomType_imanew1,i1_civ2(ifile),[],j1_civ2(j));
     2503                    if ~exist(filename,'file')
     2504                        A=read_image(cell2mat(filecell.ima1.civ2(ifile,j)),type_ima2,i1_civ2(ifile));
     2505                        imwrite(A,filename,'BitDepth',16);
     2506                    end
     2507                    filecell.ima1.civ2(ifile,j)={filename};
     2508                    filename=fullfile_uvmat(RootPath,[],RootFile_ima2,'.png',NomType_imanew2,i2_civ2(ifile),[],j2_civ2(j));
     2509                    if ~exist(filename,'file')
     2510                        A=read_image(cell2mat(filecell.ima2.civ2(ifile,j)),type_ima2,i2_civ2(ifile));
     2511                        imwrite(A,filename,'BitDepth',16);
     2512                    end
     2513                    filecell.ima2.civ2(ifile,j)={filename};
    24972514                end
    2498                 filecell.ima1.civ2(ifile,j)={filename};
    2499                 filename=fullfile_uvmat(RootPath,[],RootFile_ima2,'.png',NomType_imanew2,i2_civ2(ifile),[],j2_civ2(j));
    2500                 if ~exist(filename,'file')
    2501                     A=read_image(cell2mat(filecell.ima2.civ2(ifile,j)),type_ima2,i2_civ2(ifile));
    2502                     imwrite(A,filename,'BitDepth',16);
    2503                 end
    2504                 filecell.ima2.civ2(ifile,j)={filename};
    2505             end
    2506         end
    2507         close(h);
     2515            end
     2516            close(h);
     2517        end
    25082518    end
    25092519end
     
    39163926    Data.nx=[1 size(Data.A,2)];
    39173927    par_civ1=read_GUI(handles.Civ1);
    3918     par_civ1.ImageWidth=size(Data.A,1);
    3919     par_civ1.ImageHeight=size(Data.A,2);
     3928    par_civ1.ImageWidth=size(Data.A,2);
     3929    par_civ1.ImageHeight=size(Data.A,1);
    39203930    par_civ1.Mask='all';% will provide only the grid set for PIV, no image correlation
     3931    par_civ1.i1=i1_civ1;
     3932    par_civ1.i2=i2_civ1;
    39213933    Param.Civ1=par_civ1;
    39223934    Grid=civ_matlab(Param);% get the grid of x, y positions set for PIV
Note: See TracChangeset for help on using the changeset viewer.