-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathrun_autofocusWithRotAndTrans.m
More file actions
74 lines (60 loc) · 2.17 KB
/
Copy pathrun_autofocusWithRotAndTrans.m
File metadata and controls
74 lines (60 loc) · 2.17 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
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
function [finaltranslation] = run_autofocusWithTranslation()
clear; close all;
addpath(genpath('.'));
% Reconstruction parameters
method = 'PC'; % Options: GD, PC, LADMM
cy = 0; nRows=32;
cx = 0; nCols=32;
pixSize = 0.001; % meters / pixel
im = phantom();
im = imresize( im, [nCols nRows], 'bilinear' );
figure; imshow( imresize(im,10,'nearest'), [] );
title('original'); drawnow;
detSize = 0.001;
dTheta = 1 * pi/180;
thetas = 0:dTheta:pi-dTheta;
nThetas = numel(thetas);
nDetectors = nCols*2;
nonzeroTranslations = 1;
if nonzeroTranslations > 0
maxVerticalShift = 0.01; % in meters
maxHorizontalShift = 0.02; % in meters
translations = zeros( nThetas, 2 );
translations(:,1) = linspace(0,maxVerticalShift,nThetas);
translations(:,2) = linspace(0,maxHorizontalShift,nThetas);
else
maxVerticalShift = 0; % in meters
maxHorizontalShift = 0; % in meters
translations = zeros( nThetas, 2 );
end
nonzeroRotations = 1;
if nonzeroRotations > 0
maxRotation = 6 * pi/180;
rotations = linspace(0,maxRotation,nThetas);
else
maxRotation = 0;
rotations = zeros(nThetas,1);
end
im = padImgForRadon( im, maxHorizontalShift*1.5, ...
maxVerticalShift*1.5, pixSize );
[nRows,nCols] = size(im);
sinogram = radonWithRotAndTrans( im, pixSize, nDetectors, detSize, ...
thetas, rotations, translations );
maxX = maxHorizontalShift*1.5;
maxY = maxVerticalShift*1.5;
dx = maxHorizontalShift/2;
dy = maxVerticalShift/2;
[finalTranslation,metric] = autofocusWithRotAndTrans(sinogram, ...
maxX, dx, maxY, dy, maxRot, dr, nRows, nCols, pixSize, detSize, ...
thetas, method);
translations = zeros( nThetas, 2 );
translations(:,1) = linspace(0,finalTranslation(1),nThetas);
translations(:,2) = linspace(0,finalTranslation(2),nThetas);
autofocusRecon = ctCorrectForTranslation( sinogram, nDetectors, ...
detSize, thetas, translations, nCols, nRows, pixSize, ...
'method', method, 'radonMatrix', R );
figure; imshow( imresize(autofocusRecon,10,'nearest'), [] );
title('Autofocus Reconstruction');
figure; imshow( imresize(metric,10,'nearest'), [] );
title('Autofocus Metric');
end