Changeset 1176 for trunk/src


Ignore:
Timestamp:
Mar 12, 2025, 12:35:15 PM (3 days ago)
Author:
sommeria
Message:

background image introduced for civ1

Location:
trunk/src
Files:
6 edited

Legend:

Unmodified
Added
Removed
  • TabularUnified trunk/src/plot_field.m

    r1175 r1176  
    183183else  %plot 2D field
    184184%     if ~exist('PosColorbar','var'),PosColorbar=[];end;
    185     [tild,PlotParamOut,PlotType,errormsg]=plot_plane(Data,CellInfo(index_2D),haxes,PlotParamOut);
     185    [~,PlotParamOut,PlotType,errormsg]=plot_plane(Data,CellInfo(index_2D),haxes,PlotParamOut);
    186186    AxeData.NbDim=2;
    187187    if testzoomaxes && isempty(errormsg)
    188         [zoomaxes,PlotParamOut,tild,errormsg]=plot_plane(Data,CellInfo(index_2D),zoomaxes,PlotParamOut);
     188        [zoomaxes,PlotParamOut,~,errormsg]=plot_plane(Data,CellInfo(index_2D),zoomaxes,PlotParamOut);
    189189        AxeData.ZoomAxes=zoomaxes;
    190190    end
     
    409409
    410410%% prepare the string for plot command
    411 if isfield(PlotParam,'Type')&& strcmp(PlotParam.Type,'semilogx')
    412    plotstr='hhh=semilogx(';
    413 else
    414 plotstr='hhh=plot(';
     411if isfield(PlotParam,'Type')
     412    switch PlotParam.Type
     413        case 'semilogx'
     414            plotstr='hhh=semilogx(';
     415        case 'semilogy'
     416            plotstr='hhh=semilogy(';
     417        case 'loglog'
     418            plotstr='hhh=loglog(';
     419        otherwise
     420            plotstr='hhh=plot(';
     421    end
    415422end
    416423xtitle='';
  • TabularUnified trunk/src/series/civ_input.m

    r1171 r1176  
    12861286    end
    12871287    % browse for a mask
    1288     filemask= uigetfile_uvmat('pick a mask image file:',InputTable{ind_A,1},'image');
    1289     if ~isempty(filemask)
    1290         [FilePath,FileName,FileExt]=fileparts(filemask);
     1288    filebackground= uigetfile_uvmat('pick a mask image file:',InputTable{ind_A,1},'image');
     1289    if ~isempty(filebackground)
     1290        [FilePath,FileName,FileExt]=fileparts(filebackground);
    12911291        [RootPath,SubDir,RootFile,i1_series,i2,j1,j2,NomType]=find_file_series(FilePath,[FileName FileExt]);
    12921292        if strcmp(NomType,'_1')
     
    12971297            return
    12981298        end
    1299         set(hObject,'UserData',filemask);%store for future use
     1299        set(hObject,'UserData',filebackground);%store for future use
    13001300        testmask=1;
    13011301    end
     
    13031303if testmask
    13041304    set(handles.Mask,'Visible','on')
    1305     set(handles.Mask,'String',filemask)
     1305    set(handles.Mask,'String',filebackground)
    13061306    set(handles.CheckMask,'Value',1)
    13071307    if strcmp(NomType,'_1')
     
    19641964
    19651965
     1966% --- Executes on button press in CheckBackground.
     1967function CheckBackground_Callback(hObject, eventdata, handles)
     1968hparent=get(hObject,'parent');
     1969hchildren=get(hparent,'children');
     1970handle_txtbox=findobj(hchildren,'tag','Background');% look for the mask name box in the same panel
     1971testmask=0;
     1972if get(hObject,'Value')% if the checkbox is activated
     1973    hseries=findobj(allchild(0),'Tag','series');
     1974    hhseries=guidata(hseries);
     1975    InputTable=get(hhseries.InputTable,'Data');
     1976    if strcmp(InputTable{1,5},'.nc')
     1977        ind_A=2;%case of nc file as input (for civ3), image in second line
     1978    else
     1979        ind_A=1;% line index of the (first) image series
     1980    end
     1981    % browse for a mask
     1982    filebackground= uigetfile_uvmat('pick a background image file:',InputTable{ind_A,1},'image');
     1983    if ~isempty(filebackground)
     1984        [FilePath,FileName,FileExt]=fileparts(filebackground);
     1985        [RootPath,SubDir,RootFile,i1_series,i2,j1,j2,NomType]=find_file_series(FilePath,[FileName FileExt]);
     1986        if strcmp(NomType,'_1')
     1987            NbSlice=i1_series(1,2,end);
     1988            set(handles.num_NbSlice,'String',num2str(NbSlice))
     1989        elseif ~strcmp(NomType,'*')
     1990            msgbox_uvmat('ERROR','multilevel background images must be labeled with a single index as _1,_2,...');
     1991            return
     1992        end
     1993        set(hObject,'UserData',filebackground);%store for future use
     1994        testmask=1;
     1995    end
     1996end
     1997if testmask
     1998    set(handles.Background,'Visible','on')
     1999    set(handles.Background,'String',filebackground)
     2000    set(handles.CheckBackground,'Value',1)
     2001    if strcmp(NomType,'_1')
     2002        set(handles.num_NbSlice,'Visible','on')
     2003    end
     2004else
     2005    set(hObject,'Value',0);
     2006    set(handle_txtbox,'Visible','off')
     2007    set(handles.num_NbSlice,'Visible','off')
     2008end
     2009set(handles.ConfigSource,'String','NEW')
     2010set(handles.ConfigSource,'BackgroundColor',[1 0 1])
     2011
     2012
     2013
     2014function Background_Callback(hObject, eventdata, handles)
     2015% hObject    handle to Background (see GCBO)
     2016% eventdata  reserved - to be defined in a future version of MATLAB
     2017% handles    structure with handles and user data (see GUIDATA)
     2018
     2019% Hints: get(hObject,'String') returns contents of Background as text
     2020%        str2double(get(hObject,'String')) returns contents of Background as a double
  • TabularUnified trunk/src/series/civ_series.m

    r1175 r1176  
    256256
    257257%% introduce input image transform
     258transform_fct=[];%default, no transform
    258259if isfield(Param,'FieldTransform')&&~isempty(Param.FieldTransform.TransformName)
    259260        addpath(Param.FieldTransform.TransformPath)
     
    265266%%%%% MAIN LOOP %%%%%%
    266267maskoldname='';% initiate the mask name
     268backgroundoldname='';
    267269FileType_A='';
    268270FileType_B='';
     
    384386            end
    385387        end
     388
     389 % case of background image to subtract
     390        if par_civ1.CheckBackground &&~isempty(par_civ1.Background)
     391            [RootPath_background,SubDir_background,RootFile_background,~,~,~,~,Ext_background]=fileparts_uvmat(Param.ActionInput.Civ1.Background);
     392            j1=1;
     393            if ~isempty(j1_series_Civ1)
     394                j1=j1_series_Civ1(ifield);
     395            end
     396            if ~isempty(i2_series_Civ1)% case of volume,backgrounds act on different j levels
     397                backgroundname=fullfile_uvmat(RootPath_background,SubDir_background,RootFile_background,Ext_background,'_1',j1);
     398            elseif isfield(par_civ1,'NbSlice')
     399                i1_background=mod(i1-1,par_civ1.NbSlice)+1;
     400                backgroundname=fullfile_uvmat(RootPath_background,SubDir_background,RootFile_background,Ext_background,'_1',i1_background);
     401                if strcmp(Param.ActionInput.PairIndices.ListPairMode,'series(Di)')% case of volume, background index refers to j index
     402                    par_civ1.NbSlice_j=par_civ1.NbSlice;
     403                end
     404            else
     405                backgroundname=Param.ActionInput.Civ1.Background;
     406            end
     407            if strcmp(backgroundoldname,backgroundname)% background exist, not already read in civ1
     408                par_civ1.Background=background; %use background already opened
     409            else
     410                if ~isempty(regexp(backgroundname,'(^http://)|(^https://)', 'once'))|| exist(backgroundname,'file')
     411                    try
     412                        par_civ1.Background=imread(backgroundname);%update the background, an store it for future use
     413                    catch ME
     414                        if ~isempty(ME.message)
     415                            errormsg=['error reading input image: ' ME.message];
     416                            disp_uvmat('ERROR',errormsg,checkrun)
     417                            return
     418                        end
     419                    end
     420                else
     421                    par_civ1.Background=[];
     422                end
     423                background=par_civ1.Background;
     424                backgroundoldname=backgroundname;
     425            end
     426            par_civ1.ImageA=par_civ1.ImageA-par_civ1.Background;
     427            par_civ1.ImageB=par_civ1.ImageB-par_civ1.Background;
     428        end
     429
     430
    386431        %% user defined image transform
    387432        if ~isempty(transform_fct)
     
    472517            end
    473518        end
    474        
     519
    475520        % case of input grid
    476521        if par_civ1.CheckGrid &&~isempty(par_civ1.Grid)
  • TabularUnified trunk/src/uvmat.m

    r1175 r1176  
    43854385                C=reshape(double(B),1,nxy(1)*nxy(2));% reshape in a vector
    43864386                Histo.histo(:,col)=hist(C, Histo.(FieldName));  %calculate histogram
    4387                 if isequal(get(handles.LogLinHisto,'Value'),2)
    4388                     PlotParam.Type='semilogx';
    4389                 else
    4390                     PlotParam.Type='plot';
     4387                switch get(handles.LogLinHisto,'Value')
     4388                    case 1
     4389                        PlotParam.Type='plot';
     4390                    case 2
     4391                    PlotParam.Type='semilogy';
     4392                    case 3
     4393                       PlotParam.Type='semilogx';
     4394                    case 4
     4395                    PlotParam.Type='loglog';
    43914396                end
    43924397            end
Note: See TracChangeset for help on using the changeset viewer.