Changeset 910 for trunk/src


Ignore:
Timestamp:
Jun 13, 2015, 7:20:37 PM (9 years ago)
Author:
sommeria
Message:

bugs corrected in fix in civ_series. vectors set to 0 inside mask

Location:
trunk/src
Files:
4 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/series.m

    r909 r910  
    14811481errormsg='';%default error message
    14821482xmlfile=fullfile(path_series,'PARAM.xml');
    1483 test_batch=0;%default: ,no batch mode available
     1483%test_batch=0;%default: ,no batch mode available
    14841484if ~exist(xmlfile,'file')
    14851485    [success,message]=copyfile(fullfile(path_series,'PARAM.xml.default'),xmlfile);
    14861486end
    1487 % RunTime='';
    14881487if strcmp(ActionExt,'.sh')
    14891488    if exist(xmlfile,'file')
    14901489        s=xml2struct(xmlfile);
    14911490        if strcmp(RunMode,'cluster_oar') && isfield(s,'BatchParam')
    1492 %             if isfield(s.BatchParam,'RunTime')
    1493 %                 RunTime=s.BatchParam.RunTime;
    1494 %             end
    14951491            if isfield(s.BatchParam,'NbCore')
    14961492                NbCore=s.BatchParam.NbCore;
    14971493            end
    14981494        elseif (strcmp(RunMode,'background')||strcmp(RunMode,'local')) && isfield(s,'RunParam')
    1499 %             if isfield(s.RunParam,'RunTime')
    1500 %                 RunTime=s.RunParam.RunTime;
    1501 %             end
    15021495            if isfield(s.RunParam,'NbCore')
    15031496                NbCore=s.RunParam.NbCore;
     
    15051498        end
    15061499    end
    1507 %     if isempty(RunTime) && strcmp(RunMode,'cluster_oar')
    1508 %        errormsg='RunTime name not found in PARAM.xml, compiled version .sh cannot run on cluster';
    1509 %         return
    1510 %     end
    15111500end
    15121501
     
    17271716end
    17281717nbfield_j=numel(ref_j); % number of j indices
    1729 BlockLength=numel(ref_i);%default
    1730 if isempty(Param.IndexRange.NbSlice)
    1731     NbProcess=NbCore;% choose one process per core by default if NbSlice is not imposed
    1732     switch RunMode
    1733         case 'cluster_oar'
    1734             BlockLength= ceil(20/(CPUTime*nbfield_j));% short iterations are grouped such that the minimum time of a process is 20 min.
    1735             NbProcess=ceil(numel(ref_i)/BlockLength) ; % nbre of processes sent to oar
    1736     end
    1737 else
    1738     NbProcess=Param.IndexRange.NbSlice;% the parameter NbSlice sets the nbre of run processes
    1739     NbCore=min(NbCore,NbProcess);% reduces the number of cores if it exceeds the number of processes
    1740 end
    1741 
    1742 %BlockLength=ceil(numel(ref_i)/NbProcess);% nbre of input fields in each process
    1743 %nbfield_j=numel(ref_j); % number of j indices
     1718BlockLength=numel(ref_i);% by default, job involves the full set of i field indices
     1719NbProcess=1;
     1720switch RunMode
     1721    case {'cluster_oar','cluster_pbs'}
     1722        if isempty(Param.IndexRange.NbSlice)% if NbSlice is not defined
     1723             BlockLength= ceil(20/(CPUTime*nbfield_j));% short iterations are grouped such that the minimum time of a process is 20 min.
     1724             BlockLength=max(BlockLength,ceil(numel(ref_i)/1000));% possibly increase the BlockLength to have less than 1000 jobs
     1725             NbProcess=ceil(numel(ref_i)/BlockLength) ; % nbre of processes sent to oar
     1726        else
     1727            NbProcess=Param.IndexRange.NbSlice;% the parameter NbSlice sets the nbre of run processes
     1728            NbCore=min(NbCore,NbProcess);% reduces the number of cores if it exceeds the number of processes
     1729        end
     1730end
    17441731
    17451732%% record nbre of output files and starting time for computation for status
  • trunk/src/series/civ_input.m

    r908 r910  
    130130            return
    131131        end
     132        if isfield(Data,'.Civ1_ImageA')
    132133        [PathCiv1_ImageA,Civ1_ImageA,FileExtA]=fileparts(Data.Civ1_ImageA);%look for the source image A
    133134        [PathCiv1_ImageB,Civ1_ImageB,FileExtA]=fileparts(Data.Civ1_ImageB);%look for the source image B
     135        end
    134136        if isfield(Data,'Civ2_ImageA')
    135137            [PathCiv2_ImageA,Civ2_ImageA,FileExtA]=fileparts(Data.Civ2_ImageA);
     
    137139        end
    138140        if size(Param.InputTable,1)==1
     141             if isfield(Data,'.Civ1_ImageA')
    139142            series('display_file_name',hhseries,Data.Civ1_ImageA,'append');%append the image series to the input list
    140         end
    141         [RootPath,SubDir,RootFile,i1,i2,j1,j2,FileExt,NomTypeImaA]=fileparts_uvmat(Data.Civ1_ImageA);
     143                    [RootPath,SubDir,RootFile,i1,i2,j1,j2,FileExt,NomTypeImaA]=fileparts_uvmat(Data.Civ1_ImageA);
    142144        [RootPath,SubDir,RootFile,i1,i2,j1,j2,FileExt,NomTypeImaB]=fileparts_uvmat(Data.Civ1_ImageB);
     145             else
     146                 series('display_file_name',hhseries,Data.Civ2_ImageA,'append');%append the image series to the input list
     147                         [RootPath,SubDir,RootFile,i1,i2,j1,j2,FileExt,NomTypeImaA]=fileparts_uvmat(Data.Civ2_ImageA);
     148        [RootPath,SubDir,RootFile,i1,i2,j1,j2,FileExt,NomTypeImaB]=fileparts_uvmat(Data.Civ2_ImageB);
     149             end
     150        end
     151
    143152        iview_image=2;%line # for the input images
    144153    case 'civxdata'% case of  civx data,
  • trunk/src/series/civ_series.m

    r908 r910  
    10241024            if sizemask > 1/2% eliminate point if more than half of the correlation box is masked
    10251025                F(ivec)=3; %
     1026                utable(ivec)=0;
     1027                vtable(ivec)=0;
    10261028            else
    10271029                image1_crop=image1_crop.*~mask1_crop;% put to zero the masked pixels (mask1_crop='true'=1)
     
    10421044                F(ivec)=3;
    10431045            end
    1044             if F(ivec)~=3
     1046            if F(ivec)==3
     1047                utable(ivec)=0;
     1048                vtable(ivec)=0;
     1049            else
    10451050                %mask
    10461051                if checkmask
     
    10991104                    catch ME
    11001105                        F(ivec)=3;
     1106                        disp(ME.message)
    11011107                    end
    11021108                else
     
    11271133%http://urapiv.wordpress.com
    11281134peaky = y;
    1129 if y <= npy-1 && y >= 1
     1135if y <= npy-1 && y > 1
    11301136    f0 = log(result_conv(y,x));
    11311137    f1 = log(result_conv(y-1,x));
     
    11361142end
    11371143peakx=x;
    1138 if x <= npx-1 && x >= 1
     1144if x <= npx-1 && x > 1
    11391145    f0 = log(result_conv(y,x));
    11401146    f1 = log(result_conv(y,x-1));
  • trunk/src/uvmat.m

    r909 r910  
    14691469    flag=1;
    14701470    if ~isfield(UvData.Field,'A')
    1471             msgbox_uvmat('ERROR','an image needs to be opened to set the mask size');
    1472     return
     1471        msgbox_uvmat('ERROR','an image needs to be opened to set the mask size');
     1472        return
    14731473    end
    14741474    npx=size(UvData.Field.A,2);
     
    14771477    yi=0.5:npy-0.5;
    14781478    [Xi,Yi]=meshgrid(xi,yi);
    1479         for iobj=1:length(UvData.ProjObject)
    1480             ObjectData=UvData.ProjObject{iobj};
    1481             if isfield(ObjectData,'ProjMode') &&(isequal(ObjectData.ProjMode,'mask_inside')||isequal(ObjectData.ProjMode,'mask_outside'));
    1482                 flagobj=1;
    1483                 testphys=0; %coordinates in pixels by default
    1484                 if isfield(ObjectData,'CoordUnit') && ~isequal(ObjectData.CoordUnit,'pixel')
    1485                     if isfield(UvData,'XmlData')&& isfield(UvData.XmlData{1},'GeometryCalib')
    1486                         Calib=UvData.XmlData{1}.GeometryCalib;
    1487                         testphys=1;
     1479    for iobj=1:length(UvData.ProjObject)
     1480        ObjectData=UvData.ProjObject{iobj};
     1481        if isfield(ObjectData,'ProjMode') &&(isequal(ObjectData.ProjMode,'mask_inside')||isequal(ObjectData.ProjMode,'mask_outside'));
     1482            flagobj=1;
     1483            testphys=0; %coordinates in pixels by default
     1484            if isfield(ObjectData,'CoordUnit') && ~isequal(ObjectData.CoordUnit,'pixel')
     1485                if isfield(UvData,'XmlData')&& isfield(UvData.XmlData{1},'GeometryCalib')
     1486                    Calib=UvData.XmlData{1}.GeometryCalib;
     1487                    testphys=1;
     1488                end
     1489            end
     1490            if isfield(ObjectData,'Coord')&& isfield(ObjectData,'Type')
     1491                if isequal(ObjectData.Type,'polygon')
     1492                    X=ObjectData.Coord(:,1);
     1493                    Y=ObjectData.Coord(:,2);
     1494                    if testphys
     1495                        pos=[X Y zeros(size(X))];
     1496                        if isfield(Calib,'SliceCoord') && length(Calib.SliceCoord)>=3
     1497                            if isfield(Calib,'SliceAngle')&&~isequal(Calib.SliceAngle,[0 0 0])
     1498                                om=norm(Calib.SliceAngle);%norm of rotation angle in radians
     1499                                OmAxis=Calib.SliceAngle/om; %unit vector marking the rotation axis
     1500                                cos_om=cos(pi*om/180);
     1501                                sin_om=sin(pi*om/180);
     1502                                pos=cos_om*pos+sin_om*cross(OmAxis,pos)+(1-cos_om)*(OmAxis*pos')*OmAxis;
     1503                            end
     1504                            pos(:,1)=pos(:,1)+Calib.SliceCoord(1);
     1505                            pos(:,2)=pos(:,2)+Calib.SliceCoord(2);
     1506                            pos(:,3)=pos(:,3)+Calib.SliceCoord(3);
     1507                        end
     1508                        [X,Y]=px_XYZ(Calib,pos(:,1),pos(:,2),pos(:,3));
    14881509                    end
     1510                    flagobj=~inpolygon(Xi,Yi,X',Y');%=0 inside the polygon, 1 outside
     1511                elseif isequal(ObjectData.Type,'ellipse')
     1512                    if testphys
     1513                        %[X,Y]=px_XYZ(Calib,X,Y,0);% TODO:create a polygon boundary and transform to phys
     1514                    end
     1515                    RangeX=max(ObjectData.RangeX);
     1516                    RangeY=max(ObjectData.RangeY);
     1517                    X2Max=RangeX*RangeX;
     1518                    Y2Max=RangeY*RangeY;
     1519                    distX=(Xi-ObjectData.Coord(1,1));
     1520                    distY=(Yi-ObjectData.Coord(1,2));
     1521                    flagobj=(distX.*distX/X2Max+distY.*distY/Y2Max)>1;
     1522                elseif isequal(ObjectData.Type,'rectangle')
     1523                    if testphys
     1524                        %[X,Y]=px_XYZ(Calib,X,Y,0);% TODO:create a polygon boundary and transform to phys
     1525                    end
     1526                    distX=abs(Xi-ObjectData.Coord(1,1));
     1527                    distY=abs(Yi-ObjectData.Coord(1,2));
     1528                    flagobj=distX>max(ObjectData.RangeX) | distY>max(ObjectData.RangeY);
    14891529                end
    1490                 if isfield(ObjectData,'Coord')&& isfield(ObjectData,'Type')
    1491                     if isequal(ObjectData.Type,'polygon')
    1492                         X=ObjectData.Coord(:,1);
    1493                         Y=ObjectData.Coord(:,2);
    1494                         if testphys
    1495                             pos=[X Y zeros(size(X))];
    1496                             if isfield(Calib,'SliceCoord') && length(Calib.SliceCoord)>=3
    1497                                 if isfield(Calib,'SliceAngle')&&~isequal(Calib.SliceAngle,[0 0 0])
    1498                                     om=norm(Calib.SliceAngle);%norm of rotation angle in radians
    1499                                     OmAxis=Calib.SliceAngle/om; %unit vector marking the rotation axis
    1500                                     cos_om=cos(pi*om/180);
    1501                                     sin_om=sin(pi*om/180);
    1502                                     pos=cos_om*pos+sin_om*cross(OmAxis,pos)+(1-cos_om)*(OmAxis*pos')*OmAxis;
    1503                                 end
    1504                                 pos(:,1)=pos(:,1)+Calib.SliceCoord(1);
    1505                                 pos(:,2)=pos(:,2)+Calib.SliceCoord(2);
    1506                                 pos(:,3)=pos(:,3)+Calib.SliceCoord(3);
    1507                             end                           
    1508                             [X,Y]=px_XYZ(Calib,pos(:,1),pos(:,2),pos(:,3));
    1509                         end
    1510                         flagobj=~inpolygon(Xi,Yi,X',Y');%=0 inside the polygon, 1 outside
    1511                     elseif isequal(ObjectData.Type,'ellipse')
    1512                         if testphys
    1513                             %[X,Y]=px_XYZ(Calib,X,Y,0);% TODO:create a polygon boundary and transform to phys
    1514                         end
    1515                         RangeX=max(ObjectData.RangeX);
    1516                         RangeY=max(ObjectData.RangeY);
    1517                         X2Max=RangeX*RangeX;
    1518                         Y2Max=RangeY*RangeY;
    1519                         distX=(Xi-ObjectData.Coord(1,1));
    1520                         distY=(Yi-ObjectData.Coord(1,2));
    1521                         flagobj=(distX.*distX/X2Max+distY.*distY/Y2Max)>1;
    1522                     elseif isequal(ObjectData.Type,'rectangle')
    1523                         if testphys
    1524                             %[X,Y]=px_XYZ(Calib,X,Y,0);% TODO:create a polygon boundary and transform to phys
    1525                         end
    1526                         distX=abs(Xi-ObjectData.Coord(1,1));
    1527                         distY=abs(Yi-ObjectData.Coord(1,2));
    1528                         flagobj=distX>max(ObjectData.RangeX) | distY>max(ObjectData.RangeY);
    1529                     end
    1530                     if isequal(ObjectData.ProjMode,'mask_outside')
    1531                         flagobj=~flagobj;
    1532                     end
    1533                     flag=flag & flagobj;
     1530                if isequal(ObjectData.ProjMode,'mask_outside')
     1531                    flagobj=~flagobj;
    15341532                end
    1535             end
    1536         end
     1533                flag=flag & flagobj;
     1534            end
     1535        end
     1536    end
    15371537    %mask name
    15381538    RootPath=get(handles.RootPath,'String');
     
    15481548    imflag=uint8(255*(0.392+0.608*flag));% =100 for flag=0 (vectors not computed when 20<imflag<200)
    15491549    imflag=flipdim(imflag,1);
    1550 
     1550   
    15511551    %display the mask
    15521552    hfigmask=figure;
     
    15701570            end
    15711571        end
    1572         imwrite(imflag,answer,'BitDepth',8);
     1572        try
     1573            imwrite(imflag,answer,'BitDepth',8);
     1574        catch ME
     1575            msgbox_uvmat('ERROR',ME.message)
     1576        end
    15731577    end
    15741578    set(handles.ListObject,'Value',1)
Note: See TracChangeset for help on using the changeset viewer.