Changeset 1200 for trunk/src/series


Ignore:
Timestamp:
Mar 20, 2026, 4:42:36 PM (24 hours ago)
Author:
sommeria
Message:

bug repaired for civ image rescale

Location:
trunk/src/series
Files:
3 edited

Legend:

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

    r1199 r1200  
    8989FileType='image';%fdefault
    9090FileInfo=[];
    91 if isfield(SeriesData,'FileInfo')
     91if isfield(SeriesData,'FileInfo') && ~isempty(SeriesData.FileInfo)
    9292    FileType=SeriesData.FileInfo{1}.FileType;% info on the first input file series
    9393else
  • trunk/src/series/civ_series.m

    r1199 r1200  
    392392            [par_civ1.ImageB,VideoObject_B] = read_image(ImageName_B,FileType_B,VideoObject_B,FrameIndex_B);
    393393           
    394         % catch ME % display errors in reading input images
    395         %     if ~isempty(ME.message)
    396         %         disp_uvmat('ERROR', ['error reading input image: ' ME.message],checkrun)
    397         %         continue
    398         %     end
    399         % end
    400394       
    401395        % case of background image to subtract
    402396        if par_civ1.CheckBackground &&~isempty(par_civ1.Background)
    403397            [RootPath_background,SubDir_background,RootFile_background,~,~,~,~,Ext_background]=fileparts_uvmat(Param.ActionInput.Civ1.Background);
    404             if ~isempty(i2_series_Civ1)% case of volume,backgrounds act on different j levels
     398            if strcmp(NomTypeNc,'_1-2_1')% case of volume,backgrounds act on different j levels
    405399                backgroundname=fullfile_uvmat(RootPath_background,SubDir_background,RootFile_background,Ext_background,'_1',j1_series_Civ1(ifield));
    406             elseif isfield(par_civ1,'NbSlice')
     400            elseif isfield(par_civ1,'NbSlice')&& ~isequal(par_civ1.NbSlice,1)
    407401                i1_background=mod(i1-1,par_civ1.NbSlice)+1;
    408402                backgroundname=fullfile_uvmat(RootPath_background,SubDir_background,RootFile_background,Ext_background,'_1',i1_background);
     
    418412                if ~isempty(regexp(backgroundname,'(^http://)|(^https://)', 'once'))|| exist(backgroundname,'file')
    419413                    try
    420                         par_civ1.Background=imread(backgroundname);%update the background, an store it for future use
     414                        par_civ1.Background=uint16(imread(backgroundname));%update the background, an store it for future use
    421415                    catch ME
    422416                        if ~isempty(ME.message)
     
    432426                backgroundoldname=backgroundname;
    433427            end
    434             par_civ1.ImageA=par_civ1.ImageA-par_civ1.Background;
    435             par_civ1.ImageB=par_civ1.ImageB-par_civ1.Background;
     428            par_civ1.ImageA=uint16(par_civ1.ImageA)-par_civ1.Background;
     429            par_civ1.ImageB=uint16(par_civ1.ImageB)-par_civ1.Background;
    436430        end
    437431       
     
    496490            if ~isempty(i2_series_Civ1)&& ~isequal(i1_series_Civ1,i2_series_Civ1)% case of volume,masks act on different j levels
    497491                maskname=fullfile_uvmat(RootPath_mask,SubDir_mask,RootFile_mask,Ext_mask,'_1',j1);
    498             elseif isfield(par_civ1,'NbSlice')
     492            elseif isfield(par_civ1,'NbSlice')&& ~isequal(par_civ1.NbSlice,1)
    499493                i1_mask=mod(i1-1,par_civ1.NbSlice)+1;
    500494                maskname=fullfile_uvmat(RootPath_mask,SubDir_mask,RootFile_mask,Ext_mask,'_1',i1_mask);
     
    638632        if strcmp(ImageName_A_Civ2,ImageName_A) && isequal(FrameIndex_A,FrameIndex_A_2)
    639633            par_civ2.ImageA=par_civ1.ImageA;
     634            CheckDuplicate_1to2A=true;
    640635        else
    641636            [par_civ2.ImageA,VideoObject_A] = read_image(ImageName_A_Civ2,FileType_A,VideoObject_A,FrameIndex_A_2);
     637            CheckDuplicate_1to2A=false;
    642638        end
    643639        if CheckRelabel
     
    650646        if strcmp(ImageName_B_Civ2,ImageName_B) && isequal(FrameIndex_B_2,FrameIndex_B)
    651647            par_civ2.ImageB=par_civ1.ImageB;
     648            CheckDuplicate_1to2B=true;
    652649        else
    653650            [par_civ2.ImageB,VideoObject_B] = read_image(ImageName_B_Civ2,FileType_B,VideoObject_B,FrameIndex_B_2);
     651             CheckDuplicate_1to2B=false;
    654652        end
    655653        %  [FileInfo_A,VideoObject_A]=get_file_info(ImageName_A_Civ2);
     
    673671        end
    674672       
    675         %                 %% user defined image transform
    676         %         if ~isempty(transform_fct)
    677         %                par_civ2 =transform_fct(par_civ2,Param);
    678         %         end
     673        %% case of background image to subtract, if images civ2 different from civ1
     674        if (~CheckDuplicate_1to2A || ~CheckDuplicate_1to2B) && par_civ2.CheckBackground &&~isempty(par_civ2.Background)
     675            [RootPath_background,SubDir_background,RootFile_background,~,~,~,~,Ext_background]=fileparts_uvmat(Param.ActionInput.Civ2.Background);
     676            j1=1;
     677            if ~isempty(j1_series_Civ2)
     678                j1=j1_series_Civ2(ifield);
     679            end
     680            if ~isempty(i2_series_Civ2)% case of volume,backgrounds act on different j levels
     681                backgroundname=fullfile_uvmat(RootPath_background,SubDir_background,RootFile_background,Ext_background,'_1',j1);
     682            elseif isfield(par_civ2,'NbSlice') && ~isequal(par_civ2.NbSlice,1)
     683                i1_background=mod(i1-1,par_civ2.NbSlice)+1;
     684                backgroundname=fullfile_uvmat(RootPath_background,SubDir_background,RootFile_background,Ext_background,'_1',i1_background);
     685                if strcmp(Param.ActionInput.PairIndices.ListPairMode,'series(Di)')% case of volume, background index refers to j index
     686                    par_civ2.NbSlice_j=par_civ2.NbSlice;
     687                end
     688            else
     689                backgroundname=Param.ActionInput.Civ2.Background;
     690            end
     691            if strcmp(backgroundoldname,backgroundname)% background exist, not already read in civ2
     692                par_civ2.Background=background; %use background already opened
     693            else
     694                if ~isempty(regexp(backgroundname,'(^http://)|(^https://)', 'once'))|| exist(backgroundname,'file')
     695                    try
     696                        par_civ2.Background=uint16(imread(backgroundname));%update the background, an store it for future use
     697                    catch ME
     698                        if ~isempty(ME.message)
     699                            errormsg=['error reading input image: ' ME.message];
     700                            disp_uvmat('ERROR',errormsg,checkrun)
     701                            return
     702                        end
     703                    end
     704                else
     705                    par_civ2.Background=[];
     706                end
     707                background=par_civ2.Background;
     708                backgroundoldname=backgroundname;
     709            end
     710            if ~CheckDuplicate_1to2A
     711            par_civ2.ImageA=uint16(par_civ2.ImageA)-par_civ2.Background;
     712            end
     713            if ~CheckDuplicate_1to2B
     714            par_civ2.ImageB=uint16(par_civ2.ImageB)-par_civ2.Background;
     715            end
     716        end
     717   
    679718        %% case of image luminosity rescaling
    680         if par_civ2.CheckRescale &&~isempty(par_civ2.Maxtanh)
    681             par_civ2.ImageA =par_civ2.Maxtanh*tanh(double(par_civ2.ImageA)/par_civ2.Maxtanh);
    682             par_civ2.ImageB=par_civ2.Maxtanh*tanh(double(par_civ2.ImageB)/par_civ2.Maxtanh);
     719        if  par_civ2.CheckRescale && ~isempty(par_civ2.Maxtanh)
     720            if ~CheckDuplicate_1to2A %if the image A is different from civ1
     721                par_civ2.ImageA =par_civ2.Maxtanh*tanh(double(par_civ2.ImageA)/par_civ2.Maxtanh);
     722            end
     723            if ~CheckDuplicate_1to2B % if the image B is different from civ1
     724                par_civ2.ImageB=par_civ2.Maxtanh*tanh(double(par_civ2.ImageB)/par_civ2.Maxtanh);
     725            end
    683726        end
    684727       
     
    761804                end
    762805                maskname=fullfile_uvmat(RootPath_mask,SubDir_mask,RootFile_mask,Ext_mask,'_1',j1);
    763             elseif isfield(par_civ2,'NbSlice')
     806            elseif isfield(par_civ2,'NbSlice')&& ~isequal(par_civ2.NbSlice,1)
    764807                i1=i1_series_Civ2(ifield);
    765808                i1_mask=mod(i1-1,par_civ2.NbSlice)+1;
     
    794837        end
    795838       
    796         % case of background image to subtract
    797         if par_civ2.CheckBackground &&~isempty(par_civ2.Background)
    798             [RootPath_background,SubDir_background,RootFile_background,~,~,~,~,Ext_background]=fileparts_uvmat(Param.ActionInput.Civ1.Background);
    799             j1=1;
    800             if ~isempty(j1_series_Civ1)
    801                 j1=j1_series_Civ1(ifield);
    802             end
    803             if ~isempty(i2_series_Civ1)% case of volume,backgrounds act on different j levels
    804                 backgroundname=fullfile_uvmat(RootPath_background,SubDir_background,RootFile_background,Ext_background,'_1',j1);
    805             elseif isfield(par_civ2,'NbSlice')
    806                 i1_background=mod(i1-1,par_civ2.NbSlice)+1;
    807                 backgroundname=fullfile_uvmat(RootPath_background,SubDir_background,RootFile_background,Ext_background,'_1',i1_background);
    808                 if strcmp(Param.ActionInput.PairIndices.ListPairMode,'series(Di)')% case of volume, background index refers to j index
    809                     par_civ2.NbSlice_j=par_civ2.NbSlice;
    810                 end
    811             else
    812                 backgroundname=Param.ActionInput.Civ1.Background;
    813             end
    814             if strcmp(backgroundoldname,backgroundname)% background exist, not already read in civ2
    815                 par_civ2.Background=background; %use background already opened
    816             else
    817                 if ~isempty(regexp(backgroundname,'(^http://)|(^https://)', 'once'))|| exist(backgroundname,'file')
    818                     try
    819                         par_civ2.Background=imread(backgroundname);%update the background, an store it for future use
    820                     catch ME
    821                         if ~isempty(ME.message)
    822                             errormsg=['error reading input image: ' ME.message];
    823                             disp_uvmat('ERROR',errormsg,checkrun)
    824                             return
    825                         end
    826                     end
    827                 else
    828                     par_civ2.Background=[];
    829                 end
    830                 background=par_civ2.Background;
    831                 backgroundoldname=backgroundname;
    832             end
    833             par_civ2.ImageA=par_civ2.ImageA-par_civ2.Background;
    834             par_civ2.ImageB=par_civ2.ImageB-par_civ2.Background;
    835         end
    836        
     839        %% get civ2 correlation parameters
    837840        if strcmp(Param.ActionInput.ListCompareMode,'displacement')
    838841            Civ1_Dt=1;
     
    852855        end
    853856       
    854         % calculate velocity data (y and v in image indices, reverse to y component)
    855        
     857        % calculate velocity data     
    856858        [Civ_X,Civ_Y,Civ_U,Civ_V,Civ_C,Civ_FF,~, errormsg] = civ (par_civ2);
    857859        Civ_X_shifted=Civ_X-0.5+Civ_U/2;% get the exact positions
     
    878880        Data.ListGlobalAttribute=[Data.ListGlobalAttribute Civ2_param];
    879881       
    880         %        nbvar=numel(Data.ListVarName);
    881         % define the Civ2 variable (if Civ2 data are not replaced from previous calculation)
    882         %         if isempty(find(strcmp('Civ2_X',Data.ListVarName),1))
    883         %             Data.ListVarName=[Data.ListVarName {'Civ2_X','Civ2_Y','Civ2_U','Civ2_V','Civ2_C','Civ2_FF'}];%  cell array containing the names of the fields to record
    884         %             Data.VarDimName=[Data.VarDimName {'nb_vec_2','nb_vec_2','nb_vec_2','nb_vec_2','nb_vec_2','nb_vec_2'}];
    885         %             Data.VarAttribute{nbvar+1}.Role='coord_x';
    886         %             Data.VarAttribute{nbvar+2}.Role='coord_y';
    887         %             Data.VarAttribute{nbvar+3}.Role='vector_x';
    888         %             Data.VarAttribute{nbvar+4}.Role='vector_y';
    889         %             Data.VarAttribute{nbvar+5}.Role='ancillary';
    890         %             Data.VarAttribute{nbvar+6}.Role='errorflag';
    891         %         end
    892882        disp('civ2 performed')
    893883        time_civ2=toc(tstart_civ2);
     
    930920        end
    931921        Data.ListGlobalAttribute=[Data.ListGlobalAttribute Patch2_param];
    932        
    933         %  nbvar=length(Data.ListVarName);
    934         %         Data.ListVarName=[Data.ListVarName {'Civ2_U_smooth','Civ2_V_smooth','Civ2_SubRange','Civ2_NbCentres','Civ2_Coord_tps','Civ2_U_tps','Civ2_V_tps'}];
    935         %         Data.VarDimName=[Data.VarDimName {'nb_vec_2','nb_vec_2',{'nb_coord','nb_bounds','nb_subdomain_2'},{'nb_subdomain_2'},...
    936         %             {'nb_tps_2','nb_coord','nb_subdomain_2'},{'nb_tps_2','nb_subdomain_2'},{'nb_tps_2','nb_subdomain_2'}}];
    937        
    938         %         Data.VarAttribute{nbvar+1}.Role='vector_x';
    939         %         Data.VarAttribute{nbvar+2}.Role='vector_y';
    940         %         Data.VarAttribute{nbvar+5}.Role='coord_tps';
    941         %         Data.VarAttribute{nbvar+6}.Role='vector_x';
    942         %         Data.VarAttribute{nbvar+7}.Role='vector_y';
    943922       
    944923        if isempty(Civ_FF)
Note: See TracChangeset for help on using the changeset viewer.