module demonstrating the usage of intensity based registration tracking 2d algorithm
More...
module demonstrating the usage of intensity based registration tracking 2d algorithm
Overview
This script allows to track a rigid motion transform over a sequence of 2d images.
- See also
- intensity based registration tracker 2d algorithm
Usage
The application is a standalone script user can navigate through image plans of sequence using following keys :
- left key : go to previous plan
- right key : go to next plan
- up key : go to last plan
- down key : go to first plan
- Note
- this script requieres PyQt5 (see https://pypi.python.org/pypi/PyQt5 for example)
Here is a snapshot algorithm expected behavior:
Source code documentation
We start by importing all necessary libraries:
import sys
import os
import PyIPSDK
import PyIPSDK.IPSDKIPLFeatureDetection as fd
import PyIPSDK.IPSDKIPLRegistration as registration
from PyQt5.QtWidgets import QWidget, QApplication, QLabel
from PyQt5.QtGui import QPainter, QColor, QFont, QPen, QBrush, QImage, QPixmap, QPolygon
from PyQt5.QtCore import Qt, QCoreApplication, QPoint
Then we use tracking algorithm to compute motion registration over image sequence.
imagesSamplePath = PyIPSDK.getIPSDKDirectory(PyIPSDK.eInternalDirectory.eID_Images)
inputImgPath = os.path.join(imagesSamplePath, "rotation_seq_2d_1.tif")
self.seqImg = PyIPSDK.loadTiffImageFile(inputImgPath, PyIPSDK.eTiffDirectoryMode.eTDM_Temporal)
firstImgPlan = PyIPSDK.extractPlan(0, 0, 0, self.seqImg)
nbSamples = 400
minDist = 5
pixels2d = fd.harrisCorner2d(firstImgPlan, nbSamples, minDist)
self.initGrid = PyIPSDK.createRegistrationTracking2dGrid(self.seqImg.getSizeX() * 0.25,
self.seqImg.getSizeY() * 0.25,
self.seqImg.getSizeX() * 0.75,
self.seqImg.getSizeY() * 0.75)
self.initPts = PyIPSDK.toCoords2dColl(pixels2d)
self.piMotionTransform2d = registration.intensityBasedTracker2d(self.seqImg, self.initPts,
PyIPSDK.eRegistrationMotionModel2d.eRMM2d_Rigid,
self.initGrid)
See the full source listing