Skip to content

Commit

Permalink
affine cross phase correlation algo added
Browse files Browse the repository at this point in the history
  • Loading branch information
iltommi committed Feb 7, 2025
1 parent b84378a commit c603e61
Show file tree
Hide file tree
Showing 4 changed files with 77 additions and 8 deletions.
4 changes: 2 additions & 2 deletions .cirrus.yml
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ debian_task:
script: |
export DEBIAN_FRONTEND=noninteractive
apt-get update -qq
apt-get install -yy git file pandoc cmake libxkbcommon-dev libgl1-mesa-dev libvulkan* libnetpbm11-dev libhdf5-dev libfftw3-dev libhdf4-dev g++ build-essential libtiff5-dev libgsl-dev lsb-release libcfitsio-dev libhdf4-dev libhdf5-dev libhdf5-103-1 libxcb-xkb-dev qt6-tools-dev qt6-multimedia-dev qt6-declarative-dev qt6-charts-dev qt6-svg-dev
apt-get install -yy git file pandoc cmake libxkbcommon-dev libgl1-mesa-dev libvulkan* libnetpbm11-dev libfftw3-dev libhdf4-dev g++ build-essential libtiff5-dev libgsl-dev lsb-release libcfitsio-dev libhdf4-dev libhdf5-dev libhdf5-310 libxcb-xkb-dev qt6-tools-dev qt6-multimedia-dev qt6-declarative-dev qt6-charts-dev qt6-svg-dev
apt-get install -yy qml6-module*
mkdir build && cd build
cmake ..
Expand Down Expand Up @@ -258,7 +258,7 @@ AppImageArm_task:
mkdir build && cd build
cmake -DCMAKE_INSTALL_PREFIX=/usr ..
make -j2 install DESTDIR=AppDir
../linuxdeploy-aarch64.AppImage --appdir AppDir --plugin qt --output appimage --custom-apprun=../resources/linuxPackage/AppRun --icon-file=../resources/icons/neutrino.svg
NO_STRIP=true ../linuxdeploy-aarch64.AppImage --appdir AppDir --plugin qt --output appimage --custom-apprun=../resources/linuxPackage/AppRun --icon-file=../resources/icons/neutrino.svg
cp Neutrino-*.AppImage ../Neutrino-Linux-arm64.AppImage
package_artifacts:
path: "Neutrino-*.AppImage"
Expand Down
55 changes: 55 additions & 0 deletions plugins/Affine_transformation/Affine_transformation.cc
Original file line number Diff line number Diff line change
Expand Up @@ -68,6 +68,8 @@ Affine_transformation::Affine_transformation(neutrino *nparent) : nGenericPan(np

connect(actionReset, SIGNAL(triggered()), this, SLOT(resetPoints()));

connect(actionShift, &QAction::triggered, this, &Affine_transformation::findshift);

qDebug() << "here";
show();
qDebug() << "here";
Expand Down Expand Up @@ -234,3 +236,56 @@ void Affine_transformation::apply() {

}

void Affine_transformation::findshift() {
qDebug() << "here in";
nPhysD *my_phys=nullptr;
nPhysD *my_phys_other=nullptr;

std::array<double,6> vecForward,vecBackward;
my_phys=getPhysFromCombo(image1);
my_phys_other=getPhysFromCombo(image2);
vecForward=forward;
vecBackward=backward;
if (my_phys) {
physC imageFFT = my_phys->ft2(PHYS_FORWARD);
physC imageFFTother = my_phys_other->ft2(PHYS_FORWARD);
size_t dx=my_phys->getW();
size_t dy=my_phys->getH();

for (int i=0; i<dx*dy;i++) {
mcomplex A=imageFFT.point(i);
mcomplex B=imageFFTother.point(i);
double vreal=A.real()*B.real()+A.imag()*B.imag();
double vimag=A.imag()*B.real()-A.real()*B.imag();
mcomplex val = mcomplex(vreal, vimag);
imageFFT.set(i,val/(A.mod()*B.mod()));
}
imageFFTother = imageFFT.ft2(PHYS_BACKWARD);
double max_val = 0.0;
int maxx = 0;
int maxy = 0;
for (int i = 0; i < dy; i++) {
for (int j = 0; j < dx; j++) {
int k=i * dx + j;
double magnitude = imageFFTother.point(k).mcabs();

if (magnitude > max_val) {
max_val = magnitude;
maxx = j;
maxy = i;
}
}
}
QPolygonF poly;
poly << QPointF(100,0) << QPointF(0,0) << QPointF(0,100);
l1.setPoints(poly);
poly.translate(-maxx,-maxy);
l2.setPoints(poly);
qDebug() << maxx << maxy;
apply();

}
qDebug() << "here out";

}

1 change: 1 addition & 0 deletions plugins/Affine_transformation/Affine_transformation.h
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,7 @@ public slots:
void affine();
void bufferChanged(nPhysD*);
void resetPoints();
void findshift();
};

NEUTRINO_PLUGIN(Affine_transformation, Analysis);
Expand Down
25 changes: 19 additions & 6 deletions plugins/Affine_transformation/Affine_transformation.ui
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
<x>0</x>
<y>0</y>
<width>244</width>
<height>283</height>
<height>290</height>
</rect>
</property>
<property name="font">
Expand Down Expand Up @@ -250,7 +250,7 @@
<string>...</string>
</property>
<property name="icon">
<iconset resource="../../../build-neutrinoMaster-Qt_5_11_0_5_11_0_temporary_22340a-Debug/src/qrc/icons.qrc">
<iconset>
<normaloff>:/icons/line.png</normaloff>:/icons/line.png</iconset>
</property>
</widget>
Expand All @@ -261,7 +261,7 @@
<string>...</string>
</property>
<property name="icon">
<iconset resource="../../../build-neutrinoMaster-Qt_5_11_0_5_11_0_temporary_22340a-Debug/src/qrc/icons.qrc">
<iconset>
<normaloff>:/icons/line.png</normaloff>:/icons/line.png</iconset>
</property>
</widget>
Expand Down Expand Up @@ -371,10 +371,11 @@
</attribute>
<addaction name="actionReset"/>
<addaction name="actionRegion"/>
<addaction name="actionShift"/>
</widget>
<action name="actionReset">
<property name="icon">
<iconset resource="../../../build-neutrinoMaster-Qt_5_11_0_5_11_0_temporary_22340a-Debug/src/qrc/icons.qrc">
<iconset>
<normaloff>:/icons/remove.png</normaloff>:/icons/remove.png</iconset>
</property>
<property name="text">
Expand All @@ -386,7 +387,7 @@
</action>
<action name="actionRegion">
<property name="icon">
<iconset resource="../../../build-neutrinoMaster-Qt_5_11_0_5_11_0_temporary_22340a-Debug/src/qrc/icons.qrc">
<iconset>
<normaloff>:/icons/rect.png</normaloff>:/icons/rect.png</iconset>
</property>
<property name="text">
Expand All @@ -396,6 +397,18 @@
<string>Crop rectangle</string>
</property>
</action>
<action name="actionShift">
<property name="icon">
<iconset resource="../Ghost_fringes/GhostFringes.qrc">
<normaloff>:/icons/refresh2.png</normaloff>:/icons/refresh2.png</iconset>
</property>
<property name="text">
<string>Reset</string>
</property>
<property name="toolTip">
<string>Find shift</string>
</property>
</action>
</widget>
<tabstops>
<tabstop>image1</tabstop>
Expand All @@ -419,7 +432,7 @@
<tabstop>B12</tabstop>
</tabstops>
<resources>
<include location="../../../build-neutrinoMaster-Qt_5_11_0_5_11_0_temporary_22340a-Debug/src/qrc/icons.qrc"/>
<include location="../Ghost_fringes/GhostFringes.qrc"/>
</resources>
<connections/>
</ui>

0 comments on commit c603e61

Please sign in to comment.