User:Yimingzzz/sandbox

PhyCV is the first computer vision library which utilizes algorithms directly derived from the equations of physics governing physical phenomena. The algorithms appearing in the first release emulates the propagation of light through a physical medium with natural and engineered diffractive properties followed by coherent detection. Unlike traditional algorithms that are a sequence of hand-crafted empirical rules, physics-inspired algorithms leverage physical laws of nature as blueprints for inventing algorithms. In addition, these algorithms can, in principle, be implemented in real physical devices for fast and efficient computation in the form of analog computing. Currently PhyCV has two algorithms, Phase-Stretch Transform (PST) and Phase-Stretch Adaptive Gradient-Field Extractor (PAGE). Both algorithms have CPU and GPU versions. PhyCV is now available on GitHub and can be installed from pip.

History
Phase-Stretch Transform (PST) and Phase-Stretch Adaptive Gradient-field Extractor (PAGE) were inspired by the physics of the photonic time stretch (a hardware technique for ultrafast and single-shot data acquisition). The edge detection algorithm PST was open-sourced in 2016 and as of mid 2022 has 800+ stars and 200+ forks on GitHub. The directional edge detection algorithm PAGE was open-sourced in Feburary, 2022. PhyCV was originally developed and open-sourced by Jalali-Lab @ UCLA in May 2022. In PhyCV, the original open-sourced code of PST and PAGE is significantly refactored and improved to be modular, more efficient, GPU-accelerated and object-oriented.

Phase-Stretch Transform (PST)
Phase-Stretch Transform (PST) is a computationally efficient edge and texture detection algorithm with exceptional performance in visually impaired images. The algorithm transforms the image by emulating propagation of light through a device with engineered diffractive property followed by coherent detection. It has been applied in improving the resolution of MRI image, extracting blood vessels in retina images , dolphin identification , and waste water treatment , single molecule biological imaging , and classification of UAV using micro Doppler imaging.

Phase-Stretch Adaptive Gradient-Field Extractor (PAGE)
Phase-Stretch Adaptive Gradient-field Extractor (PAGE) is a physics-inspired algorithm for detecting edges and their orientations in digital images at various scales. The algorithm is based on the diffraction equations of optics. Metaphorically speaking, PAGE emulates the physics of birefringent (orientation-dependent) diffractive propagation through a physical device with a specific diffractive structure. The propagation converts a real-valued image into a complex function. Related information is contained in the real and imaginary components of the output. The output represents the phase of the complex function.

Modular Code Architecture
The code in PhyCV has a modular design which faithfully follows the physical process from which the algorithm was originated. Both PST and PAGE modules in the PhyCV library emulate the propagation of the input signal (original digital image) through a device with engineered diffractive property followed by coherent (phase) detection. The dispersive propagation applies a phase kernel to the frequency domain of the original image. This process has three steps in general, loading the image, initializing the kernel and applying the kernel. In the implementation of PhyCV, each algorithm is represented as a class in Python and each class has methods that simulate the steps described above. The modular code architecture follows the physics behind the algorithm. Please refer to the source code on GitHub for more details.

GPU Acceleration
PhyCV supports GPU acceleration. The GPU versions of PST and PAGE are built on PyTorch accelerated by the CUDA toolkit. The acceleration is beneficial for applying the algorithms in real-time image video processing and other deep learning tasks. The running time PhyCV algorithms on CPU and GPU for videos at different resolutions are shown below.

Installation and Examples
Please refer to the GitHub README file for a detailed technical documentation.