Skip to content
Snippets Groups Projects
Commit e742ce84 authored by Elijah Andrews's avatar Elijah Andrews
Browse files

Added packaged version of bubble analysis GUI.

parent 46e3a611
Branches main
No related tags found
No related merge requests found
Showing
with 1073 additions and 0 deletions
# Bubble Analysis GUI
`bubble_analysis_gui.py` is a GUI program written with PyQt5 that allows a series of readings to be inspected and analysed easily. A demonstration can be found [here](https://xorg.us/2018-07-18_12-07-23.mp4).
#### Instructions
1) On running the script a file selection prompt will appear. Select the folder that contains the index.csv file.
2) Find as many readings in your data that contain the same geometry and have a common coordinate (for example a constant y). Navigate to an empty frame (no bubble) and click 'Add Frame' under 'Calibration'. If you select incorrect frames you can restart by clicking 'Clear Frames'. When you have selected a series of frames click 'Calibrate'. This will take a moment to run and will result in a 'mm/px' value being shown in the 'Calibration' status box.
3) You can navigate through your data with the navigation buttons provided or slide the slider to advance through the frames.
4) You can click on a frame to take measurements, left click once at the start of your measurement and again at the end. A red line will appear and the status box at the bottom of the window will show details about your measurement. The angle noted is measured from the positive horizontal (x) direction anti-clockwise (Note: the order in which you choose your points is important in angle measurement). Right clicking will clear your measurement.
5) There are numerous other options for debugging and information.
#### Recording Data
To use this analysis tool data must be recorded in the correct format.
- index.csv must be a CSV file with headers "x", "y", "idx" (names are not important but order is).
- Each position index should have its own directory containing movies.
It is suggested to view the existing data as a reference.
\ No newline at end of file
This diff is collapsed.
packaged-code/pacakged-gui/icon.png

192 KiB

python ./bubble_analysis_gui.py
PAUSE
\ No newline at end of file
import math
import matplotlib.pyplot as plt
import numpy as np
import skimage.transform as tf
from skimage.registration import phase_cross_correlation
from skimage.filters import sobel, threshold_triangle
from skimage.restoration import denoise_bilateral
import util.plotting_utils as pu
import util.file_utils as fu
def calculate_offset(frame_1, frame_2, plot_compared_frames=False):
"""
Calculates a required offset of frame_1 in direction dir such that it maps onto frame_2 as closely as possible.
:param frame_1: Frame to be moved.
:param frame_2: Frame to be mapped onto.
:param plot_compared_frames: Whether to plot the final frame comparison.
:return: Offset required in direction.
"""
frame_1 = denoise_bilateral(frame_1, channel_axis=None, bins=2, mode='reflect', sigma_spatial=2.5)
frame_2 = denoise_bilateral(frame_2, channel_axis=None, bins=2, mode='reflect', sigma_spatial=2.5)
frame_1 = sobel(frame_1, mask=np.ones(frame_1.shape, dtype=bool))
frame_2 = sobel(frame_2, mask=np.ones(frame_1.shape, dtype=bool))
# thresh_1 = threshold_triangle(frame_1)
# thresh_2 = threshold_triangle(frame_2)
# thresh = (thresh_1 + thresh_2) / 2
# frame_1 = frame_1 > thresh
# frame_2 = frame_2 > thresh
offset, error, _ = phase_cross_correlation(frame_1, frame_2, normalization=None)
if plot_compared_frames:
tform = tf.SimilarityTransform(translation=[offset[1], offset[0]])
pu.plot_frame(tf.warp(frame_1, tform), show_immediately=False)
pu.plot_frame(frame_2, show_immediately=False)
plt.show()
return offset
if __name__ == '__main__':
# cal_dir = "../../../Data/SidewaysSeries/w2.2h2.7/"
# print(calculate_mm_per_pixel(cal_dir, plot_compared_frames=True))
# mraw_1 = fu.get_mraw_from_dir("../../../../Data/SlotSweeps/w1h3/movie_S0013/")
# mraw_2 = fu.get_mraw_from_dir("../../../../Data/SlotSweeps/w1h3/movie_S0001/")
mraw_1 = fu.get_mraw_from_dir("C:/Users/eda1g15/OneDrive - University of Southampton/Research/Porous Materials/Data/~25VF/Purer water between 3 degassed again/movie_C001H001S0001/")
mraw_2 = fu.get_mraw_from_dir("C:/Users/eda1g15/OneDrive - University of Southampton/Research/Porous Materials/Data/~25VF/Purer water between 3 degassed again/movie_C001H001S0002/")
print(calculate_offset(mraw_1[0], mraw_2[0], True))
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment