-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathmatlabRegistration.m
More file actions
34 lines (27 loc) · 1.25 KB
/
matlabRegistration.m
File metadata and controls
34 lines (27 loc) · 1.25 KB
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
%script to read snapshot from Ca imaging data and get how it is transformed
%load snapshot, adjust contrast
[snapFN, snapPath] = uigetfile('*.tif', 'Brightfield snapshot for overlay');
snap = imread(snapFN);
snapAdjusted = imadjust(snap);
figure; imshow(snapAdjusted);
%crop green channel out (on the left)
[snapGreen,rectGreen] = imcrop(snapAdjusted);
%crop red channel out (on the right)
[snapRed,rectRed] = imcrop(snapAdjusted);
%save cropped green chn
greenSnapFN = strcat(snapFN(1:end-4),'_greenCropped.tif');
imwrite(snapGreen,greenSnapFN)
%save cropped red pic
redSnapFN = strcat(snapFN(1:end-4),'_redCropped.tif');
imwrite(snapRed,redSnapFN)
%choose 3 corresponding points in each
[greenPoints redPoints] = cpselect(snapGreen,snapRed,'wait',true);
%figure out function for transformation
t_concord = fitgeotrans(greenPoints, redPoints,'affine'); %no idea whether projective is the right type
%this needs to be done for each image separately?
resizedRed = imref2d(size(snapRed));
greenRegistered = imwarp(snapGreen,t_concord,'OutputView',resizedRed);
figure, imshowpair(greenRegistered,snapRed,'blend')
transformationsFN = strcat(snapFN(1:end-4),'_transformations.mat');
save(transformationsFN,'rectGreen','rectRed','greenPoints','redPoints','t_concord')
%bla