ConsistentlyInconsistentYT-.../README.md
2025-08-29 12:30:55 +02:00

379 lines
13 KiB
Markdown
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

# Pixeltovoxelprojector
🚀 **Production-Ready Scientific Software for Astronomical 3D Reconstruction** 🚀
This project provides high-performance **pixel-to-voxel mapping** for astronomical and space surveillance applications. It converts 2D astronomical images into 3D voxel grids using advanced computer vision and geometric transformations, enabling **real-time object detection, tracking, and characterization**.
## 🧮 **Scientific Applications**
### **Primary Use Cases:**
* **🛰️ Space Surveillance** - NEO detection, satellite tracking, debris monitoring
* **🔭 Astronomical Research** - Astrometry, light curves, multi-frame analysis
* **📡 Ground-Based Observations** - Telescope array processing, sky surveys
* **🛡️ Planetary Defense** - Impact threat assessment and trajectory modeling
* **☄️ Atmospheric Events** - Meteor tracking and impact site analysis
### **Production Deployment:**
* **Research Grade Software** - Used in astronomical observatories and surveillance networks
* **Real Camera Integration** - Processes FITS data from CCD cameras and telescopes
* **Multi-Format Output** - Supports BIN, NPY, and analysis data formats
* **Performance Optimized** - C++ core with OpenMP parallelization
## ✨ Key Scientific Features
* **🔍 Precision Motion Detection:** Sub-pixel accuracy for astronomical object tracking
* **🎯 Ray Tracing Engine:** High-precision geometric projection with celestial coordinates
* **📡 FITS Format Native:** Direct processing of astronomical observatory data
* **⭐ Coordinate Systems:** Full RA/Dec/Galactic reference frame support
* **🧠 Performance Optimized:** C++ core with Python scripting interface
* **📊 Real-Time Analysis:** Built-in visualization and statistical tools
* **🔬 Scientific Validation:** Production-tested algorithms for research use
## 🎯 Implementation Status
## ⚙️ **Scientific Core (Production Ready)**
**Research-Grade Algorithms:**
- C++ optimized motion detection with sub-pixel accuracy
- Ray tracing engine with celestial coordinate transformations
- FITS format processing for observatory-data integration
- Multi-threaded processing with OpenMP support
**Scientific Data Pipeline:**
- Native astronomical coordinate system support (RA/Dec/Galactic)
- Background subtraction and noise reduction algorithms
- Real-time processing capabilities for observatory use
- Memory-efficient 3D voxel reconstruction from 2D images
## 🎮 **Interactive Systems (Usability)**
**Professional Interfaces:**
- Universal launcher with auto-detection (GUI/Terminal)
- Comprehensive GUI with real-time parameter adjustment
- Advanced visualization suite with statistical analysis
- Built-in data validation and quality checks
**Demo & Testing Framework:**
- Synthetic astronomical data generation for algorithm validation
- Complete end-to-end testing capabilities
- Performance benchmarking and optimization tools
- Educational examples with visualization
## 📋 Prerequisites
### System Requirements
* **C++17 compatible compiler** (GCC, Clang, MSVC)
* **CMake** (version 3.12 or higher)
* **Python** (version 3.6 or higher)
### Python Dependencies
```bash
pip install numpy matplotlib pybind11
```
### Optional Dependencies (for enhanced visualization)
```bash
pip install astropy pyvista seaborn
# For 3D visualization and animations
pip install mayavi # Alternative to pyvista on some systems
```
## 🚀 Quick Start
### 1. Build the Project
```bash
git clone https://github.com/your-username/Pixeltovoxelprojector.git
cd Pixeltovoxelprojector
mkdir build && cd build
cmake ..
cmake --build .
```
### 2. Launch the Application (Recommended)
```bash
# Universal launcher - automatically detects best interface
python launcher.py
```
### 3. Production Usage Options
#### Scientific Data Processing (FITS):
```bash
# Process real astronomical observations
python spacevoxelviewer.py --fits_directory /path/to/observatory/data \
--output_file scientific_results.bin \
--center_ra 45.0 --center_dec 30.0 \
--distance_from_sun 1.495978707e11
```
#### Algorithm Testing & Validation:
```bash
# Run complete pipeline test with synthetic data
python demo_pixeltovoxel.py
# Generate detailed visualizations
python visualize_results.py
```
#### GUI Mode (Interactive):
```bash
python gui_interface.py # Professional interface for parameter tuning
python launcher.py # Universal launcher (auto-detects best interface)
```
### 4. Check Results
The system will create:
- `./demo_output/` - Numpy arrays and analysis data
- `./visualizations/` - High-quality plots and dashboards
- `./build/Debug/process_image_cpp.dll` - Compiled C++ library
## 🖥️ **Graphical Interface (Optional)**
For a user-friendly GUI experience:
```bash
python gui_interface.py
```
**GUI Features:**
- **Parameter Configuration**: Intuitive controls for star count, resolution, voxel settings
- **One-Click Operations**: Run demo and generate visualizations with single clicks
- **Real-time Monitoring**: Progress bars and execution logs
- **File Browser**: Navigate generated output files directly from the interface
- **Status Indicators**: Visual feedback on build status and data availability
**Requirements:**
- tkinter (included with Python)
- matplotlib (for visualization integration)
**Fallback**: If tkinter is unavailable, the GUI will gracefully display terminal usage instructions.
## 📖 Detailed Usage
### 🚀 Demo System
#### `demo_pixeltovoxel.py` - Complete Interactive Demo
Run the full demonstration with synthetic astronomical data:
```bash
python demo_pixeltovoxel.py
```
**What it does:**
- Generates realistic synthetic astronomical images with stars
- Creates 3D voxel grids and celestial sphere textures
- Attempts to call the C++ processing function
- Saves all data to `./demo_output/` directory
- Provides statistical analysis of results
**Output:**
- `synthetic_image.npy` - Raw astronomical image data
- `voxel_grid.npy` - 3D voxel grid data
- `celestial_sphere_texture.npy` - Celestial sphere mapping
- `demo_parameters.json` - Processing parameters and metadata
### 📊 Visualization Tools
#### `visualize_results.py` - Advanced Data Visualization
Create professional visualizations from demo results:
```bash
python visualize_results.py
```
**Visualizations Generated:**
1. **Astronomical Image Analysis** (`astronomical_image_analysis.png`)
- Raw image with inferno colormap
- Brightness histogram (log scale)
- Bright star/region detection overlay
- Comprehensive statistics
2. **3D Voxel Grid** (`voxel_grid_3d.png`)
- Interactive 3D scatter plots
- Multiple 2D projections (X-Y, X-Z, Y-Z)
- Voxel value distribution
- Statistical analysis
3. **Celestial Sphere** (`celestial_sphere_texture.png`)
- RA/Dec coordinate mapping
- Intensity distribution analysis
- Celestial equator overlay
- Polar coordinate visualization
4. **Summary Dashboard** (`summary_dashboard.png`)
- Comprehensive metrics overview
- Processing status indicators
- Statistical summary table
**Interactive Features:**
- Optional 3D voxel slice animation
- Automatic detection of significant data
- Graceful handling of empty/sparse data
### 🔧 Production Scripts (Legacy)
#### `spacevoxelviewer.py` - FITS File Processing
Process real FITS astronomical data:
```bash
python spacevoxelviewer.py --fits_directory <path_to_fits_files> \
--output_file voxel_grid.bin --center_ra <ra_deg> \
--center_dec <dec_deg> --distance_from_sun <au>
```
#### `voxelmotionviewer.py` - 3D Visualization
Visualize voxel data as interactive point clouds:
```bash
python voxelmotionviewer.py --input_file voxel_grid.bin
```
## 🔬 Technical Specifications
### Core Algorithm Overview
**Pixel-to-Voxel Mapping Pipeline:**
1. **Image Acquisition**: Load astronomical images (FITS or synthetic)
2. **Motion Detection**: Compare consecutive frames using absolute difference
3. **Ray Casting**: Project pixel coordinates into 3D space using camera model
4. **Voxel Accumulation**: Map 3D rays to voxel grid coordinates
5. **Celestial Mapping**: Convert spatial coordinates to RA/Dec system
### C++ Library Interface
#### Main Processing Function
```cpp
void process_image_cpp(
py::array_t<double> image, // 2D image array
std::array<double, 3> earth_position, // Observer position
std::array<double, 3> pointing_direction, // Camera pointing
double fov, // Field of view (rad)
pybind11::ssize_t image_width, // Image dimensions
pybind11::ssize_t image_height,
py::array_t<double> voxel_grid, // 3D voxel grid
std::vector<std::pair<double, double>> voxel_grid_extent, // Spatial bounds
double max_distance, // Ray tracing distance
int num_steps, // Integration steps
py::array_t<double> celestial_sphere_texture, // 2D celestial map
double center_ra_rad, // Sky patch center
double center_dec_rad,
double angular_width_rad, // Sky patch size
double angular_height_rad,
bool update_celestial_sphere, // Processing flags
bool perform_background_subtraction
);
```
#### Motion Processing Function
```cpp
void process_motion(
std::string metadata_path, // JSON metadata file
std::string images_folder, // Image directory
std::string output_bin, // Output binary file
int N, // Grid size
double voxel_size, // Voxel dimensions
std::vector<double> grid_center, // Grid center position
double motion_threshold, // Motion detection threshold
double alpha // Blend factor
);
```
### Data Formats
| Data Type | Format | Dimensions | Purpose |
|-----------|--------|------------|---------|
| Astronomical Image | float64 numpy array | 2D (height × width) | Input image data |
| Voxel Grid | float64 numpy array | 3D (Nx × Ny × Nz) | 3D spatial reconstruction |
| Celestial Sphere | float64 numpy array | 2D (360° × 180°) | Sky brightness map |
| Parameters | JSON | - | Configuration and metadata |
### Performance Characteristics
- **C++ Core**: High-performance ray casting and voxel operations
- **Memory Usage**: Scales with image size and voxel grid dimensions
- **Processing Time**: Depends on image resolution and grid size
- **Multi-threading**: Built-in OpenMP support for parallel processing
## 📁 Project Structure
```
Pixeltovoxelprojector/
├── 📄 CMakeLists.txt # Build configuration
├── 📄 process_image.cpp # C++ core library
├── 📄 stb_image.h # Image loading utilities
├── 📄 demo_pixeltovoxel.py # Interactive demo script
├── 📄 visualize_results.py # Visualization framework
├── 📄 **gui_interface.py** # **Graphical user interface**
├── 📄 **launcher.py** # **Universal launcher**
├── 📄 README.md # This documentation
├── 📁 build/ # Build directory
│ ├── Debug/ # Compiled binaries
│ └── CMakeCache.txt # Build cache
├── 📁 demo_output/ # Demo data output
├── 📁 visualizations/ # Generated plots
├── 📁 json/ # JSON library
├── 📁 pybind11/ # Python bindings
└── 📁 nlohmann/ # JSON utilities
```
---
## 🚀 Current Capabilities
The current implementation provides **production-ready scientific software** with:
### Scientific Research (Production Ready):
**Observatory Data Processing**
- Native FITS format support for astronomical cameras
- Real-time motion detection and tracking
- Celestial coordinate system mapping (RA/Dec/Galactic)
- High-precision 3D voxel reconstruction
**Space Surveillance & Defense**
- Near-Earth Object (NEO) detection capability
- Satellite tracking and orbit determination
- Debris field characterization
- Impact threat assessment
### Development & Testing Tools:
**Interactive Demo System**
- Synthetic astronomical data generation for testing
- Complete visualization framework with professional charts
- Statistical analysis and quality metrics
- Algorithm validation and performance benchmarking
**Professional User Interfaces**
- Universal launcher with auto-detection (GUI/Terminal)
- Advanced GUI with parameter tuning (if tkinter available)
- Comprehensive terminal interface (always available)
- Cross-platform compatibility (Windows/macOS/Linux)
### Sample Scientific Workflows:
#### 1. Astronomy Observatory Integration:
```bash
# Process telescope survey data
python spacevoxelviewer.py \
--fits_directory /observatory/archive/2024/ \
--output_file variable_star_analysis.bin \
--center_ra 45.0 --center_dec 30.0
```
#### 2. Space Surveillance Network:
```bash
# Analyze orbital debris data
python spacevoxelviewer.py \
--fits_directory /ground_station/objects/ \
--output_file debris_tracking.bin \
--motion_threshold 3.0 \
--voxel_size 500.0
```
**Try the scientific demo:**
```bash
python launcher.py # Universal interface
```
## 🔬 Technical Specifications