% TRALONG2 option 2 called by DEPINTL; sets up TRAnsverse vectors rep. electrode periods, % assuming either integer or non-integer periodic electrode widths and gaps then % i.e. NO interpolation then sums LONGitudinal dirn then transverse direction (using constrctd vectors). % D. Bakewell Mo/15/2/1999 fflag=menu('Enter electrode prmtrs:','K/brd & mouse','K/brd - only','mouse only'); vwgset=fflag-1 fredo = 1 % Flag begin processing that can be REDOne if unsatisfactory while fredo == 1 fpoint1 = 2; while fpoint1 == 2; switch vwgset case 0 % select wr, gr, mp, frmula from keyboard or ASCII, & yr(1) mouse mouskbr; case 1 % select from keyboard or memory kbrmem; case 2 % selecting from mouse imagmous; % for case 3 determining the points & SETting Variables W, G etc yr=round(y) % compute Rounded vector of 6 pnts chosen % Calculate w=electrode width, g=inter-electrode spacing dummy3 = menu('Calc av elctrd width & gap choose numbr of periods','1','2','3','4','5','6','7','8','9','10'); mp=double(dummy3); mp1=mp+1 if frmula == 1 % select points 1,3,4,6 elctrd -> gap & 2,5 gap -> elctrd g=(y(3)-y(2)+y(6)-y(5))/2 % electrode Gap average w=(y(2)-y(1)+y(5)-y(4))/2 % electrode Width average else %if frmula == 2 select points 1,3,4,6 gap -> elctrd & 2,5 elctrd -> gap & w=(y(3)-y(2)+y(6)-y(5))/2 % electrode Width average g=(y(2)-y(1)+y(5)-y(4))/2 % electrode Gap average end wg=w+g wr=round(w) % Discrete or ROUNDed w & g gr=round(g) wgr=wr+gr vwgset = 3 % --------------- case 3 % vwgset = 3 Variables W, G etc have been set, now more computation dummy = menu('depintl, line 65 ','Press to continue'); imagcomplt; end % end switch vwgset 0,1,& or 2 end % end fpoint1 while jump = 2 % jump ahead to summing & plotting switch jump case 1 % increase size of image so w & g are integer amounts xs = num2str(x); % NUM2STR(X) converts matrix X into string repr ~ 4 digits ys = num2str(y); xr = round(x); yr = round(y); p=1:1:4; j = yr(p); % convert chosen POINTs from PIXEL coord sys to MATRIX i = xr(p); jim=input2(j,i); djim=diag(jim); gvald = double(djim'); % convert Unit8 @ chosen coord to Double precis gvr = num2str(gvald); % read value of 4 pixel c=0; fpoint3 = 2 while fpoint3 == 1 c=c+1 cs=num2str(c) line20 = ['point no. 'cs ' pixel: x=' xs(c) ', y=' ys(c) ' & value=' gvr(c)]; display3 = [line20] figure axis off text(0.4,0.8,display3); dummy = menu('do you wish to select more points?','Yes','No'); fpoint3 = dummy; end % fpoint3 while close % end hold off nmax=n % text(0,0.5,display1) var1 = max(input2); var2 = max(var1); [m,n] = size(input2); % display4 = input2; imshow(input2); pause(1); switch fflag case 1 surf(input2);axis equal;shading interp;view(2) pause(2) close end end % end switch jump suml = sum(input2,2); % SUMs intensity matix 'input2' over j in MATRIX coord. sys. % i.e along ea row or Longitud x dirctn in PIXEL cord sys relatng to electrode strips % GENerate VECtor (pmxtrv rows x 1 column) from chosen points for plot sumj smlmaxr=round(max(suml)); smlminr=round(min(suml)); smldifr=smlmaxr-smlminr; pvec = smlminr:smldifr/200:smlmaxr; t = 1:1:pmxtrv; % Integer VECtor Transverse direction on elctrd plne (1 row x pmxtrv colmns) fvecgen = 1; % Flag for VECtor GENeration dummy = menu(' ','Press to continue'); % display4 = sumhoriz k = []; figure plot(suml',t');axis ij; % hold on for k = 1:1:mp1 plot(smlminr',ye1vr(k)','g+',pvec',ye1v(k)','g--') plot(smlminr',ye2vr(k)','r+',pvec',ye2v(k)','r--') plot(smlminr',ym1vr(k)','b+',pvec',ym1v(k)','b--') plot(smlminr',ym2vr(k)','m+',pvec',ym2v(k)','m--') end choice3=menu('Now transverse av.','variable integer periods','same integer periods'); hold off %close %print suml-f % Take average of intesities over electrode periods % organise Vertical (matrix i) summing spans, number = 2 x mp = 2xno peroids % Current aim is to evaluate accumulation over 1 period (w + g) which consists of % two sub-periods, each (w + g)/2, A & B which -> accum. over 1 sub-period (w + g)/2. % 1. First option is to use w,g e {R+} -> where periods may/not same no. elements switch choice3; case 1 k=[]; int1 = [] int2 = [] k = 1:1:mp int1(k)=abs(floor(ym1v(k))-ceil(ym1v(k))+1) % avoids counting same point twice (0,1) int2(k)=abs(floor(ym2v(k))-ceil(ym2v(k))+1) % avoids counting same point twice (0,1) pAst(k)=ceil(ym1v(k)) + int1(k) % Point of region A STart pAnd(k)=floor(ym2v(k)) % Point of region A eND pBst(k)=ceil(ym2v(k)) + int2(k) % Point of region B STart pBnd(k)=floor(ym1v(k+1)) % Point of region B eND % 2. Other option is to use w,g e {R+} -> where All periods have same no. elements % which means case 2 k=[]; k=1:1:mp switch fwrop % Flag for wr ODD parity (= 1 Odd, 0 even) case 0 % w is even => regions A & B are w/2 elements pAst(k)=ym1vr(k) pBnd(k)=ym1vr(k+1) case 1 % w is odd => regions A & B are w/2 + extra element pAst(k)=floor(ym1vr(k)) pBnd(k)= ceil(ym1vr(k+1)) end switch fgrop case 0 % g is even => regions A & B are g/2 elements pAnd(k)=ym2vr(k) pBst(k)=ym2vr(k) case 1 % g is odd => regions A & B are g/2 + extra element pAnd(k)= ceil(ym2vr(k)) pBst(k)=floor(ym2vr(k)) end end % switch choice3 % 3. Constructing SPaN vectors and summing the suml elements over ml periodic str. pAspn(k)=pAnd(k)-pAst(k); % point A SPaN pBspn(k)=pBnd(k)-pBst(k); % point B SPaN pAav=mean(pAspn) pBav=mean(pBspn) pAstd=std(pAspn) pBstd=std(pBspn) % sum suml -> sumt for two regions A & B p=0; q=0; sumAt=0; sumBt=0; p = 1:1:pAspn(1) for k=1:1:mp; pAst1 = pAst(k) + p-1; sumAt=suml(pAst1) + sumAt; end q = 1:1:pBspn(1) for k=1:1:mp; pBst1 = pBst(k) + q-1; sumBt=suml(pBst1) + sumBt; end pAst1 pBst1 % plot switch choice3 case 1 pr=pAspn(1):-1:1 prr=pAspn(1)+1:-1:2 figure plot(sumAt,p',sumBt,pr',sumBt,prr');axis ij; case 2 qr=pBspn(1):-1:1 % q vector Reflected about horizontal plot(sumAt,p',sumBt,qr');axis ij; end dummy = menu('Press to','Re-process data/plot','Add two plots'); fredo=dummy hold off switch fredo case 1 imshow(input2) hold on truesize wr wr=input('integer input wr = ') % enter new values for reprocessing image gr gr=input('integer input gr = ') wgr=wr+gr yr(1) yr1=input('integer input yr(1) = ') yr(1)=round(yr1) vwgset = 2 hold off case 2 sumBTt(q)=sumBt(qr) sumCy=sumAt + sumBTt' figure plot(sumCy,p');axis ij; % sum of Collected solute (along Longitudinal) as a % function of Transverse direction (also called Y to avoid confusion with time) choice = menu('Satisfactory:store results','Yes','no'); switch choice case 1 ouvar=zeros(1,5); ouvar(1)=wr; ouvar(2)=gr; ouvar(3)=yr(1); ouvar(4)=mp; ouvar(5)=frmula; ofnam = [ifname '.dat'] dlmwrite(ofnam,ouvar, ';') % output data (ASCII) wth ifname of tif image ofnamc= [ifname 'Cy.dat'] dlmwrite(ofnamc,sumCy, ';') %print sumCy-f end end end % end main program loop: fredo while close close close