This repository has been archived by the owner on May 3, 2020. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 1
/
asymmetryAnalysis_draft.m
40 lines (37 loc) · 1.77 KB
/
asymmetryAnalysis_draft.m
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
function [sumDiff, avgDiff] = asymmetryAnalysis_draft(CCData, images)
if iscell(images{1})
imageSize = flip(size(images{1}{1}));
else
imageSize = flip(size(images{1}));
end
plane = 1;
for frame=1:length(CCData.Xdroplet)
if iscell(images{1})
image = images{frame}{plane};
else
image = images{plane,frame};
end
cropRadius = CCData.dropRadius(frame)*1.1/CCData.calibration;
dropCenter = [CCData.Xdroplet(frame), CCData.Ydroplet(frame)];
maskedImage = circularCrop(image, dropCenter, cropRadius);
% cropOffset = dropCenter - cropRadius;
aggregateCenter = [CCData.Xaggregate(frame), CCData.Yaggregate(frame)];% - cropOffset;
aggregateRadius = CCData.aggRadius(frame)/CCData.calibration;
aggregateVerticalSpan = 1:imageSize(2);%round(aggregateCenter(2) + [-aggregateRadius : aggregateRadius]);
aggregateHorizontalBounds = round(aggregateCenter(1) + [-aggregateRadius : aggregateRadius]);
leftHalfImage = maskedImage(aggregateVerticalSpan,1:aggregateHorizontalBounds(1));
rightHalfImage = maskedImage(aggregateVerticalSpan,aggregateHorizontalBounds(2):end);
% Fig =figure; imshow(imadjust(image));
% figure; imshow(maskedImage);
% figure; imshow(leftHalfImage);
% figure; imshow(rightHalfImage);
sumLeft = sum(leftHalfImage(:));
sumRight = sum(rightHalfImage(:));
areaLeft = sum(leftHalfImage(:) > 0);
areaRight = sum(rightHalfImage(:) > 0);
avgLeft = sumLeft/areaLeft;
avgRight = sumRight/areaRight;
sumDiff(frame) = sumLeft - sumRight;
avgDiff(frame) = avgLeft - avgRight;
end
end