%transform LIF images to concentration images function [DataOut,DataOut_1,DataMask]=concentration(Data,XmlData,Data_1,XmlData_1,Ref) cpath=which('uvmat'); addpath(fullfile(fileparts(cpath),'transform_field'))% define path for phys_polar.m DataOut_1=[]; %% for use in uvmat num_level=Data.ZIndex; if ~exist('Ref','var') huvmat=findobj(allchild(0),'tag','uvmat'); hhuvmat=guidata(huvmat); RootPath=get(hhuvmat.RootPath,'String'); %reference file RootPath=fullfile(RootPath,'LIF_REF'); file_ref=fullfile(RootPath,['lif_ref_' num2str(num_level) '.nc']); Ref=nc2struct(file_ref); end %% Parameters XmlData.GeometryCalib.PolarCentre=Ref.IlluminationOrigin;%[-515 -175]; %position of the laser origin [x, y] XmlData_1.GeometryCalib.PolarCentre=Ref.IlluminationOrigin;%[-515 -175]; %position of the laser origin [x, y] ImageOffset=Ref.ImageOffset; %237;% image value for black background nfilt=64; %% concentration image Data.A(Ref.CoverIndex:end,:)=Ref.CoverCoeff*(double(Data.A(Ref.CoverIndex:end,:))-ImageOffset(1))+ImageOffset(1);% COMPENSATION OF BRIGHTNESS UNDER THE COVER [DataOut,DataOut_1]=phys_polar(Data,XmlData,Data_1,XmlData_1); A=Ref.Aref;%default ind_good=find(Ref.Aref~=0); ind_bad=find(Ref.Aref==0); A(ind_good)=double(DataOut.A(ind_good))-ImageOffset(1)-0.07*(double(DataOut_1.A(ind_good))-ImageOffset(2));%substract PIV image information for removing particles %filtering and decimate Afilt=filter2(ones(nfilt,nfilt),A); Mask=filter2(ones(nfilt,nfilt),double(Ref.Aref~=0)); B=Afilt./Mask; A(ind_bad)=B(ind_bad); [npy,npx]=size(A); DataMask=DataOut; DataMask.A=2*ones(npy,npx);%mask=2 for good data DataMask.A(Ref.Aref==0)=1;%mask=0 for undefined data C=filter2(ones(nfilt,nfilt),Ref.Aref); D=C./Mask; Ref.Aref(ind_bad)=D(ind_bad); DataOut_1=[]; AX=DataOut.AX; AY=DataOut.AY; dX=(AX(2)-AX(1))/(npx-1); dY=(AY(1)-AY(2))/(npy-1);%mesh of new pixels [R,Y]=meshgrid(linspace(AX(1),AX(2),npx),linspace(AY(1),AY(2),npy)); r=AX(1)+[0:npx-1]*dX;%distance from laser %A(ind_good)=(A(ind_good)>=0).*A(ind_good); %replaces negative values by zeros A=A./Ref.Aref;% luminosity normalised by the reference (value at the edge of the box) %% Interpolation % [Rindex,Yindex]=meshgrid(linspace(0.5,npx-0.5,npx),linspace(npy-0.5,0.5,npy)); % Rgood=Rindex(ind_good); % Ygood=Yindex(ind_good); %F=TriScatteredInterp(Rgood,Ygood,A(ind_good)); %A=F(Rindex,Yindex); DataMask.A(isnan(A)|isinf(A)|A>1.5)=0;% mask=1 for interpolated data r_edge=Ref.r_edge*ones(1,npx); Edge_ind=find((abs(R-r_edge)/dX)<=1 & DataMask.A~=0);%indies of positions close to r_edge, values greater than 1 are not expected yedge=min(min(Y(Edge_ind))); jmax=round(-(yedge-AY(1))/dY+1); DataMask.A(jmax:end,:)=0; A(isnan(A)|isinf(A))=0; % radius along the reference line Theta=(linspace(AY(1),AY(2),npy)*pi/180)'*ones(1,npx);%theta in radians gamma_coeff=Ref.GammaCoeff*ones(1,npx); A(R=1 & R<=npx & Theta >=1 & Theta<=npy;%flagin=1 inside the original image vec_A=reshape(DataIn.A,1,npx*npy);%put the original image in line ind_in=find(flagin); ind_out=find(~flagin); ICOMB=((R-1)*npy+(npy+1-Theta)); ICOMB=ICOMB(flagin);%index corresponding to XIMA and YIMA in the aligned original image vec_A vec_B(ind_in)=vec_A(ICOMB); vec_B(ind_out)=zeros(size(ind_out)); DataOut.A=flipdim(reshape(vec_B,npy,npx),1);%new image in real coordinates %Rangx=Rangx-radius_ref; DataOut.AX=RangeX; DataOut.AY=RangeY;