- Timestamp:
- Nov 6, 2013, 10:52:01 PM (11 years ago)
- Location:
- trunk/src
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/geometry_calib.m
r696 r697 848 848 corners_Y=(Coord(end:-1:end-3,5)); 849 849 850 %%%%%% 851 % corners_X=1000*[1.5415 1.7557 1.7539 1.5415]'; 852 % corners_Y=1000*[1.1515 1.1509 1.3645 1.3639]'; 853 850 854 %reorder the last two points (the two first in the list) if needed 851 855 angles=angle((corners_X-corners_X(1))+1i*(corners_Y-corners_Y(1))); … … 859 863 end 860 864 861 %% initiate the grid 865 %% initiate the grid in phys coordinates 862 866 CalibData=get(handles.geometry_calib,'UserData');%get information stored on the GUI geometry_calib 863 867 grid_input=[];%default … … 867 871 [T,CalibData.grid,CalibData.grid.CheckWhite]=create_grid(grid_input,'detect_grid');%display the GUI create_grid, read the set of phys coordinates T 868 872 set(handles.geometry_calib,'UserData',CalibData)%store the phys grid parameters for later use 873 X=[CalibData.grid.x_0 CalibData.grid.x_1 CalibData.grid.x_0 CalibData.grid.x_1]';%corner absissa in the phys coordinates (cm) 874 Y=[CalibData.grid.y_0 CalibData.grid.y_0 CalibData.grid.y_1 CalibData.grid.y_1]';%corner ordinates in the phys coordinates (cm) 869 875 870 876 %% read the current image, displayed in the GUI uvmat … … 873 879 A=UvData.Field.A;%currently displayed image 874 880 npxy=size(A); 875 X=[CalibData.grid.x_0 CalibData.grid.x_1 CalibData.grid.x_0 CalibData.grid.x_1]';%corner absissa in the phys coordinates (cm) 876 Y=[CalibData.grid.y_0 CalibData.grid.y_0 CalibData.grid.y_1 CalibData.grid.y_1]';%corner ordinates in the phys coordinates (cm) 877 878 %calculate transform matrices for plane projection: rectangle assumed to be viewed in perspective 881 882 %% calculate transform matrices for plane projection: rectangle assumed to be viewed in perspective 879 883 % reference: http://alumni.media.mit.edu/~cwren/interpolator/ by Christopher R. Wren 880 884 B = [ X Y ones(size(X)) zeros(4,3) -X.*corners_X -Y.*corners_X ... … … 887 891 C = [l(7:8)' 1]; 888 892 889 % transform grid image into 'phys' coordinates893 %% transform grid image into 'phys' coordinates 890 894 GeometryCalib.CalibrationType='3D_linear'; 891 895 GeometryCalib.fx_fy=[1 1]; … … 908 912 DataOut=phys(Data,Calib); 909 913 rmpath(fullfile(path_UVMAT,'transform_field')) 910 Amod=DataOut.A;% current im gage expressed in 'phys' coord911 Rangx=DataOut.AX; 912 Rangy=DataOut.AY; 914 Amod=DataOut.A;% current image expressed in 'phys' coord 915 Rangx=DataOut.AX;% x coordinates of first and last pixel centres in phys 916 Rangy=DataOut.AY;% y coordinates of first and last pixel centres in phys 913 917 if CalibData.grid.CheckWhite 914 918 Amod=double(Amod);%case of white grid markers: will look for image maxima … … 923 927 ind_range_y=ceil(abs(GeometryCalib.R(2,2)*CalibData.grid.Dy/3));% range of search of image ma around each point obtained by linear interpolation from the marked points 924 928 nbpoints=size(T,1); 925 %lokk for image maxima around each expected pgrid point 929 TIndex=ones(size(T));% image indices corresponding to point coordinates 930 %look for image maxima around each expected grid point 926 931 for ipoint=1:nbpoints 927 i0=1+round((T(ipoint,1)-Rangx(1))/Dx);%round(Xpx(ipoint)); 928 j0=1+round((T(ipoint,2)-Rangy(1))/Dy);%round(Xpx(ipoint)); 929 j0min=max(j0-ind_range_y,1); 930 j0max=min(j0+ind_range_y,size(Amod,1)); 931 i0min=max(i0-ind_range_x,1); 932 i0max=min(i0+ind_range_x,size(Amod,2)); 933 Asub=Amod(j0min:j0max,i0min:i0max); 934 935 936 932 i0=1+round((T(ipoint,1)-Rangx(1))/Dx);% x index of the expected point in the phys image Amod 933 j0=1+round((T(ipoint,2)-Rangy(1))/Dy);% y index of the expected point in the phys image Amod 934 j0min=max(j0-ind_range_y,1);% min y index selected for the subimage (cut at the edge to avoid index <1) 935 j0max=min(j0+ind_range_y,size(Amod,1));% max y index selected for the subimage (cut at the edge to avoid index > size) 936 i0min=max(i0-ind_range_x,1);% min x index selected for the subimage (cut at the edge to avoid index <1) 937 i0max=min(i0+ind_range_x,size(Amod,2));% max x index selected for the subimage (cut at the edge to avoid index > size) 938 Asub=Amod(j0min:j0max,i0min:i0max); %subimage used to find brigthness extremum 937 939 x_profile=sum(Asub,1);%profile of subimage summed over y 938 940 y_profile=sum(Asub,2);%profile of subimage summed over x 939 %%%% 940 % if ipoint==5 941 % figure(10) 942 % imagesc(Asub) 943 % figure(11) 944 % plot(x_profile,'r') 945 % hold on 946 % plot(y_profile,'b') 947 % end 948 %%%% 949 [tild,ind_x_max]=max(x_profile); 950 [tild,ind_y_max]=max(y_profile); 941 942 [tild,ind_x_max]=max(x_profile);% index of max for the x profile 943 [tild,ind_y_max]=max(y_profile);% index of max for the y profile 951 944 %sub-pixel improvement using moments 952 945 x_shift=0; … … 960 953 y_shift=sum(Atop.*[-2 -1 0 1 2]')/sum(Atop); 961 954 end 962 Delta(ipoint,1)=(i0min+ind_x_max-1+x_shift-i0)*Dx;%shift from the initial guess 963 Delta(ipoint,2)=(j0min+ind_y_max-1+y_shift-j0)*Dy; 964 end 965 Tmod=T(:,(1:2))+Delta;% 'phys' coordinates of the detected points 966 Tmod(:,2)=flipdim(Tmod(:,2),1);% inverse the order of y coordinates 955 %%%% 956 % if ipoint==9 957 % figure(11) 958 % imagesc(Asub) 959 % figure(12) 960 % plot(x_profile,'r') 961 % hold on 962 % plot(y_profile,'b') 963 % grid on 964 % end 965 %%%% 966 TIndex(ipoint,1)=(i0min+ind_x_max-1+x_shift);% x position of the maximum (in index of Amod) 967 TIndex(ipoint,2)=(j0min+ind_y_max-1+y_shift);% y position of the maximum (in index of Amod) 968 end 969 Tmod(:,1)=(TIndex(:,1)-1)*Dx+Rangx(1); 970 Tmod(:,2)=(TIndex(:,2)-1)*Dy+Rangy(1); 971 %Tmod=T(:,(1:2))+Delta;% 'phys' coordinates of the detected points 967 972 [Xpx,Ypx]=px_XYZ(GeometryCalib,Tmod(:,1),Tmod(:,2));% image coordinates of the detected points 968 973 Coord=[T Xpx Ypx zeros(size(T,1),1)]; … … 970 975 PLOT_Callback(hObject, eventdata, handles) 971 976 set(handles.APPLY,'BackgroundColor',[1 0 1]) 977 978 % figure(10) 979 % hold off 980 % imagesc(Rangx,Rangy,Amod) 981 % hold on 982 % plot(Tmod(:,1),Tmod(:,2),'+') 983 972 984 973 985 %----------------------------------------------------------------------- -
trunk/src/xml2struct.m
r687 r697 60 60 end 61 61 case 'char' 62 out=ss; %reproduce the input string63 62 % try to convert to number if the char does not correspond to a function (otherwise str2num calls this function as it uses 'eval') 64 63 if ~isempty(regexp(ss,'^(-*\d+\.*\d*\ *)+$')) || ~isempty(regexp(ss,'\d+e(-|+)\d+')) % if the string corresponds to a set of numbers (with possible sign and decimal, or scientific notation) separated by blanks … … 68 67 if ~isempty(sep_ind) 69 68 sep_ind=[-2 sep_ind length(ss)+1]; 69 out={}; 70 70 for icolumn=1:length(sep_ind)-1 71 out{1,icolumn}=ss(sep_ind(icolumn)+3:sep_ind(icolumn+1)-1); 71 out{1,icolumn}=ss(sep_ind(icolumn)+3:sep_ind(icolumn+1)-1);% get info between separators as a cell array 72 72 end 73 73 else … … 76 76 end 77 77 case 'cell' 78 out= [];%default78 out={};%default 79 79 check_numeric=zeros(size(ss)); 80 80 for ilist=1:numel(ss)
Note: See TracChangeset
for help on using the changeset viewer.