-
Notifications
You must be signed in to change notification settings - Fork 2
Image registration
When the selected method of analysis is 4POLAR 2D
or 4POLAR 3D
, an image registration is needed. This image registration overlays the four images taken at four different polarization angles (0°, 45°, 90°, 135°). This procedure is performed using the scale-invariant feature transform (SIFT) algorithm.
Two options:
- The registration has already been performed with PyPOLAR, so load the registration file (
*.pyreg
file containing the geometric transformation). Click 'Load'. - Otherwise, the registration is performed with a beads image file (
*.tif
or*.tiff
file) and a whitelight image file (namedWhitelight.tif
orWhitelight.tiff
). The two files need to be in the same folder. Click 'Perform'. A figure displays the resulting registration: If this registration is satisfactory, click 'Validate'. If it is satisfactory and you want to save it (to skip performing this registration in future analysis), click 'Save'. A.pyreg
file is created in the same folder as the beads and whitelight files.
If the registration is unsuccessful or unsatisfactory, the parameters of the SIFT method can be changed. Click 'Change', and a window appears with the parameters to change. Click 'Perform' to redo the registration. If at any stage, you want to abort registration, click 'Cancel'. A new registration can be initiated by selecting '4POLAR 2D' or '4POLAR 3D' as the method of analysis.
The image registration proceeds as follows:
-
First, it determines the contours of the four fields of view using the whitelight image -- the image is thresholded using
cv2.threshold
withcv2.THRESH_BINARY + cv2.THRESH_OTSU
and the contours are determined usingcv2.findContours
(see OpenCV documentation for more details) -
Second, the beads image is split in four equal-sized images corresponding to the four polarized images of the beads using the contours obtained from the whitelight image; The intensities in the four images are normalized and thresholded using
cv2.threshold
-
Third, the registration is performed using the polarized image on the top left as the fixed image and the three other polarized images as moving images. We use the scale-invariant feature transform (SIFT) algorithm
cv2.SIFT_create
to detect local features in the images. Using a matching algorithm between the location of the beads in the fixed and moving images (by solving the linear sum assignment problem withscipy.optimize.linear_sum_assignment
), we determine the perspective transformations usingcv2.findHomography
. These geometric transformations will be applied to all the images selected in the analysis.
-
contrastThreshold
: The contrast threshold used to filter out weak features in semi-uniform (low-contrast) regions. The larger the threshold, the less features are produced by the detector. -
sigma
: The sigma of the Gaussian applied to the input image at the octave #0. If your image is captured with a weak camera with soft lenses, you might want to reduce the number. For more information on these parameters, see cv::SIFT Class Reference.
- What if the file
Whitelight.tif
is missing? Use Fiji to createWhitelight.tif
from a beads image file.-
Open the beads image file with Fiji.
-
Adjust the brightness/contrast settings (Tab Image > Adjust > Brightness/Contrast) to visualize the four quadrants that contain the beads. You can manually set the intensity range with the "Set" button of the brightness/contrast window if needed.
-
Using the Oval selection tool, draw a circle over the upper left quadrant; use shift to make the selection circular.
-
When satisfied with the position and size of the circular selection, right-click on the selection and select "Create Mask". A new window will open with the respective selection as a black circle.
-
Go back to the beads image file, click on the circular selection and displace it to the next quadrant; resize if needed to fit the quadrant. Right-click and "Create Mask" as before to add this second circular selection to the mask image.
-
Proceed in the same way for the two last quadrants.
-
Once done invert the LUT of the image to have white circles in a black background (Tab Image > Lookup Tables > Invert LUT). Save the mask as "Whitelight.tif".
-
An example of Fiji-built Whitelight is given below:
-
PyPOLAR is developed under BSD 2-Clause License, Copyright(c) 2021 [email protected]