function [topsum,botsum,leftsum,ritsum] = edgeadd(MB,rcd,ccd,edgemax) %HEMIADD inputs a 3D image matrix and centroid location and finds the difference of %the sums of 3 edge pixels at radial distance "radial" from centroid for %the top half, bottom half, left half and right half at each time %compared to their means over that time %round coordinates of centroid rc=round(rcd); cc=round(ccd); %subtract approximate background M=abs(MB-mean(mean(min(MB)))); %initialize values [rn,cn,tn]=size(M); t=1; topsum=[]; botsum=[]; leftsum=[]; ritsum=[]; %find radial distance of threshold r=rc; c=cc; while MB(r,c,1)>edgemax c=c+1; end radial=(c-cc); %sum each half-plane for each image while t<(tn+1) topM=M((rc-radial),(cc-1):(cc+1),t); botM=M((rc+radial),(cc-1):(cc+1),t); lftM=M((rc-1):(rc+1),(cc-radial),t); ritM=M((rc-1):(rc+1),(cc+radial),t); topsum=cat(1,topsum,sum(sum(topM))); botsum=cat(1,botsum,sum(sum(botM))); leftsum=cat(1,leftsum,sum(sum(lftM))); ritsum=cat(1,ritsum,sum(sum(ritM))); t=t+1; end topsum=topsum-mean(topsum); botsum=botsum-mean(botsum); leftsum=leftsum-mean(leftsum); ritsum=ritsum-mean(ritsum); %Plot and Label subplot(2,1,1) plot(topsum) hold; plot(botsum,'Color','Red') hold; subplot(2,1,2) plot(leftsum) hold; plot(ritsum,'Color','Red') hold; subplot(2,1,1) title('Intensity Deviation of Top/Bottoms Edges') xlabel('Time(arb. units)') ylabel('Diff. of intensity from mean (arb units)') legend('Top Half','Bottom Half') subplot(2,1,2) title('Intensity Deviation of Left/Right Edges') xlabel('Time(arb. units)') ylabel('Diff. of intensity from mean (arb units)') legend('Left Half', 'Right Half') end