Ignore:
Timestamp:
Apr 18, 2011, 10:55:57 PM (13 years ago)
Author:
sommeria
Message:

sub_background improved (memory allocation) and calc_background created (global backgound)

File:
1 edited

Legend:

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

    r217 r239  
    129129try
    130130    mkdir([dir_images term]);
    131 catch
    132     errormsg=lasterr
    133             msgbox_uvmat('ERROR',errormsg);
     131catch ME
     132            msgbox_uvmat('ERROR',ME.message);
    134133            return
    135134end
     
    142141
    143142%% set processing parameters
    144 prompt = {'Number of images for the sliding background';'The number of positions (laser slices)';'volume scan mode (Yes/No)';...
     143prompt = {'Number of images for the sliding background (MUST FIT IN COMPUETER MEMORY)';'The number of positions (laser slices)';'volume scan mode (Yes/No)';...
    145144        'the luminosity rank chosen to define the background (0.1=for dense particle seeding, 0.5 (median) for sparse particles'};
    146145dlg_title = ['get (slice by slice) a sliding background and substract to each image, result in subdir ' subdir_ima term];
     
    154153nbaver=ceil(nbaver_ima/siz(1));%number of bursts for the sliding background
    155154if isequal(floor(nbaver/2),nbaver)
    156    nbaver=nbaver+1%put the number of burst to an odd number (so the middle burst is defined)
     155   nbaver=nbaver+1;%put the number of burst to an odd number (so the middle burst is defined)
    157156end
    158157step=siz(1);%case of bursts: the sliding background is shifted by one burst
     
    181180nbfield_slice=nbfield*nbfield2;% number of fields per slice
    182181if nbaver_ima > nbfield*nbfield2
    183     errordlg('number of images in a slice smaller than the proposed number of images for the sliding average')
     182    msgbox_uvmat('ERROR','number of images in a slice smaller than the proposed number of images for the sliding average')
    184183    return
    185184end
     
    189188    step=1;
    190189    nbaver=nbaver_ima;
     190end
     191
     192%% prealocate memory for the sliding background
     193first_image=name_generator(filebase,num_i1(1),num_j1(1),Series.FileExt,Series.NomType);
     194Afirst=read_image(first_image,FileType,num_i1(1),MovieObject);
     195[npy,npx]=size(Afirst);
     196try
     197Ak=zeros(npy,npx,nbaver_ima,'uint16'); %prealocate memory
     198Asort=zeros(npy,npx,nbaver_ima,'uint16'); %prealocate memory
     199catch ME
     200    msgbox_uvmat('ERROR',ME.message)
     201    return
    191202end
    192203
     
    204215    ImageName=name_generator(filebase_b,num_i1(1),num_j1(1),'.png',Series.NomType);
    205216    [pth,ImageName]=fileparts(ImageName);
    206     ImageName=[ImageName '.png']
     217    ImageName=[ImageName '.png'];
    207218    if isempty(uid_ImageName)
    208219       [t,uid_ImageName]=add(t,uid_Heading,'element','ImageName');
     
    210221    uid_value=children(t,uid_ImageName);
    211222    if isempty(uid_value)
    212         t=add(t,uid_ImageName,'chardata',ImageName)%indicate  name of the first image, with ;png extension
     223        t=add(t,uid_ImageName,'chardata',ImageName);%indicate  name of the first image, with ;png extension
    213224    else
    214         t=set(t,uid_value(1),'value',ImageName)%indicate  name of the first image, with ;png extension
     225        t=set(t,uid_value(1),'value',ImageName);%indicate  name of the first image, with ;png extension
    215226    end 
    216227
     
    239250
    240251%MAIN LOOP ON SLICES
     252
    241253for islice=1:nbslice_i
    242254    %% select the series of image indices at the level islice
     
    360372windowsize=round(min(size(B,1),size(B,2))/20);
    361373windowsize=floor(windowsize/2)*2+1;
    362 ix=[1/2-windowsize/2:-1/2+windowsize/2];%
     374ix=1/2-windowsize/2:-1/2+windowsize/2;%
    363375%del=np/3;
    364376%fct=exp(-(ix/del).^2);
Note: See TracChangeset for help on using the changeset viewer.