Ignore:
Timestamp:
Mar 16, 2010, 7:41:52 AM (11 years ago)
Author:
sommeria
Message:

sub_background modified to accept various movie and image inputs
geometry_calib, editxml, civ modified to read a unique PARAM.xml parameter file (instead of PARAM_LINUX...)

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/series/sub_background.m

    r38 r54  
    5858%-----------------------------------------------------------------
    5959if iscell(Series.RootPath)
    60     wardlg_uvmat('This function use only one input file series','ERROR')
     60    msgbox_uvmat('ERROR','This function use only one input image series')
     61    return
     62end
     63
     64%determine input image type
     65FileType=[];%default
     66MovieObject=[];
     67if isequal(lower(FileExt),'.avi')
     68    hhh=which('mmreader');
     69    if ~isequal(hhh,'')&& mmreader.isPlatformSupported()
     70        MovieObject=mmreader(fullfile(RootPath,[RootFile FileExt]));
     71        FileType='movie';
     72    else
     73        FileType='avi';
     74    end
     75elseif isequal(lower(FileExt),'.vol')
     76    FileType='vol';
     77else
     78   form=imformats(FileExt(2:end));
     79   if ~isempty(form)% if the extension corresponds to an image format recognized by Matlab
     80       if isequal(NomType,'*');
     81           FileType='multimage';
     82       else
     83           FileType='image';
     84       end
     85   end
     86end
     87if isempty(FileType)
     88    msgbox_uvmat('ERROR',['invalid file extension ' FileExt ': this function only accepts image or movie input'])
     89    return
    6190end
    6291
     
    206235    %read the first series of nbaver_ima images and sort by luminosity at each pixel
    207236    for ifield = 1:nbaver_ima
    208               ifile=indselect(ifield);
    209                 [filename,idetect]=...
    210            name_generator(filebase,num_i1(ifile),num_j1(ifile),Series.FileExt,Series.NomType);
    211                Aread=imread(filename);
    212                size(Aread)
    213                if size(Aread,3)>1 %(color images)
    214                    Aread=sum(Aread,3); %sum over color components
    215                end
    216                 Ak(:,:,ifield)=Aread;           
     237        ifile=indselect(ifield);
     238        filename=name_generator(filebase,num_i1(ifile),num_j1(ifile),Series.FileExt,Series.NomType);
     239        Aread=read_image(filename,FileType,num_i1(ifile),movieobject);
     240        Ak(:,:,ifield)=Aread;           
    217241    end
    218242    Asort=sort(Ak,3);%sort the luminosity of images at each point
     
    241265            stopstate=get(hseries.RUN,'BusyAction');
    242266            if isequal(stopstate,'queue')% enable STOP command
    243 %                 waitbarpos(4)=((ifield+(islice-1)*nbfield_slice)/(nbfield_slice*nbslice_i))*Series.WaitbarPos(4);
    244 %                 waitbarpos(2)=Series.WaitbarPos(4)+Series.WaitbarPos(2)-waitbarpos(4);
    245 %                 set(hwaitbar,'Position',waitbarpos)
    246 %                 drawnow
    247267                update_waitbar(hseries.waitbar,WaitbarPos,(ifield+(islice-1)*nbfield_slice)/(nbfield_slice*nbslice_i))
    248268                (ifield+(islice-1)*nbfield_slice)/(nbfield_slice*nbslice_i)
     
    251271                for iburst=1:step
    252272                    ifile=indselect(ifield+step*floor(nbaver/2)+iburst-1);
    253                     [filename,idetect]=...
    254                        name_generator(filebase,num_i1(ifile),num_j1(ifile),Series.FileExt,Series.NomType);
    255                     Aread=imread(filename);
    256                     if size(Aread,3)>1 %(color images)
    257                        Aread=sum(Aread,3); %sum over color components
    258                     end
     273                    filename=name_generator(filebase,num_i1(ifile),num_j1(ifile),Series.FileExt,Series.NomType);
     274                    Aread=read_image(filename,FileType,num_i1(ifile),movieobject);
    259275                    Ak(:,:,nbaver_ima-step+iburst)=Aread;
    260276                end
     
    298314
    299315
     316%------------------------------------------------------------------------
     317%--read images and convert them to the uint16 format used for PIV
     318function A=read_image(filename,type_ima,num,movieobject)
     319%------------------------------------------------------------------------
     320%num is the view number needed for an avi movie
     321switch type_ima
     322    case 'movie'
     323        A=read(movieobject,num);
     324    case 'avi'
     325        mov=aviread(filename,num);
     326        A=frame2im(mov(1));
     327    case 'multimage'
     328        A=imread(filename,num);
     329    case 'image'   
     330        A=imread(filename);
     331end
     332siz=size(A);
     333if length(siz)==3;%color images
     334    A=sum(double(A),3);
     335end
    300336   
    301    
Note: See TracChangeset for help on using the changeset viewer.