Skip to content
GitLab
Projects
Groups
Snippets
/
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Menu
Open sidebar
irp
HoloTomoToolbox
Commits
5c823582
Commit
5c823582
authored
Jan 12, 2022
by
p.jhagema
Browse files
rescaleDefocusSeries: new mode which avoids cropping of data
parent
bca53aa6
Pipeline
#265404
failed with stage
in 55 seconds
Changes
1
Pipelines
1
Hide whitespace changes
Inline
Side-by-side
functions/phaseRetrieval/utilities/rescaleDefocusSeries.m
View file @
5c823582
...
...
@@ -45,6 +45,8 @@ function [imAligned,fresnelNumbersRescaled,imFiltered] = rescaleDefocusSeries(im
% alignReconstructedImages : Default = false
% Should alignment be performed for single-distance CTF reconstructed
% projections?
% noCropOutput : Default = false
% Output the full holograms after rescaling without cropping.
% ctfsettings : Default = []
% Settings for the CTF reconstruction, if alignReconstructedImages is true. If it is
% empty, the settings betaDeltaRatio = 1/100, lim1 = 0.01 and lim2 = 0.1 are
...
...
@@ -145,6 +147,8 @@ defaults.cutBottom = 0;
defaults
.
alignMethod
=
'dftreg'
;
defaults
.
registrationMode
=
'shift'
;
defaults
.
registrationAccuracy
=
10
;
defaults
.
noCropOutput
=
false
;
defaults
.
givestatus
=
0
;
defaults
.
alignReconstructedImages
=
false
;
...
...
@@ -236,6 +240,11 @@ fresnelNumbersRescaled = fresnelNumbers .* (magnifications ./ maxMagnification).
% determine scaling factors with respect to image with largest magnification
scalings
=
maxMagnification
.
/
magnifications
;
if
(
settings
.
noCropOutput
)
[
imAligned
,
imFiltered
]
=
rescaleNoCrop
();
return
end
if
(
settings
.
givestatus
)
disp
([
'Aligning image 1 / '
num2str
(
numHolos
)])
end
...
...
@@ -299,6 +308,72 @@ for imageIdx = idxMaxMagnification+direction:direction:idxMaxMagnification+direc
shifts
,
rotAngleDegree
,
scalings
(:,
imageIdx
));
end
function
[
imAligned
,
imFiltered
]
=
rescaleNoCrop
()
% for the no crop option it makes sense to do everything the other way
% round. starting at the smallest magnification but the largest scaling.
% since this is what determines the output.
[
maxScaling
,
maxScalingIdx
]
=
max
(
scalings
(
1
,:));
% image with largest scaling is reference --> no alignment needed
imReference
=
imresize
(
images
(:,:,
maxScalingIdx
),
scalings
(
1
,
maxScalingIdx
),
'lanczos3'
);
outputSize
=
size
(
imReference
);
imAligned
=
zeros
([
outputSize
numHolos
]);
imAligned
(:,:,
maxScalingIdx
)
=
imReference
;
% all other images are aligned to the predecessor
shift
=
0
;
number
=
1
;
direction
=
direction
*-
1
;
for
imageIdx
=
maxScalingIdx
+
direction
:
direction
:
maxScalingIdx
+
direction
*
(
numHolos
-
1
)
if
(
settings
.
givestatus
)
number
=
number
+
1
;
disp
([
'Aligning image '
num2str
(
number
)
' / '
num2str
(
numHolos
)])
end
% scale all images to the pixelsize of the one with the largest
% magnification
% imScaled = magnifyImage(images(:,:,imageIdx), scalings(:,imageIdx));
imScaled
=
imresize
(
images
(:,:,
imageIdx
),
scalings
(
1
,
imageIdx
),
'lanczos3'
);
imScaled
=
padToSize
(
imScaled
,
outputSize
,
0
);
% optional CTF reconstruction to better align images to each other as
% holograms might look too different
if
settings
.
alignReconstructedImages
imScaled
=
phaserec_ctf
(
imScaled
,
fresnelNumbersRescaled
(:,
imageIdx
),
settings
.
ctfsettings
);
end
% identify feature for manually determining shifts between images
if
strcmp
(
settings
.
alignMethod
,
'manualFeature'
)
imagesc
(
imScaled
)
colormap
gray
axis
equal
tight
off
% get coordinates (y, x)
featureCoords
(
imageIdx
,:)
=
fliplr
(
ginput
(
1
))
-
...
[(
size
(
imScaled
,
1
)
-
size
(
images
(:,:,
idxMaxMagnification
),
1
))/
2
...
(
size
(
imScaled
,
2
)
-
size
(
images
(:,:,
idxMaxMagnification
),
2
))/
2
];
shift_diff
=
featureCoords
(
imageIdx
-
direction
,:)
-
featureCoords
(
imageIdx
,:);
shift
=
shift
+
shift_diff
;
imFiltered
=
imScaled
;
else
% align the cropped image to the reference using alignImages and dftregistration
[
~
,
shifts
,
rotAngleDegree
,
imFiltered
]
=
alignImages
(
imScaled
,
imReference
,
settings
);
shifts
rotAngleDegree
end
imScaled
=
padToSize
(
imScaled
,
ceil
(
outputSize
*
1.1
),
0
);
imScaled
=
circshiftSubPixel
(
imScaled
,
shifts
);
imScaled
=
cropToCenter
(
imScaled
,
outputSize
);
imAligned
(:,:,
imageIdx
)
=
imScaled
;
end
end
% end rescaleNoCrop
end
% end RescaleDefocusSeries
Write
Preview
Supports
Markdown
0%
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment