A sophisticated web application for mixing and manipulating Fourier Transform components of images. This tool allows you to load multiple images, analyze their frequency domain representations, and create novel images by combining different Fourier components (magnitude, phase, real, and imaginary parts) from various source images.
- Multi-Image Processing: Load up to 4 images simultaneously and process them in parallel
- Fourier Transform Analysis: View and manipulate magnitude, phase, real, and imaginary components of images
- Component Mixing: Combine Fourier components from different images using adjustable weights
- Two Mixing Modes:
- Magnitude/Phase Mode: Mix magnitude and phase components separately
- Real/Imaginary Mode: Mix real and imaginary components separately
- Region-Based Filtering: Apply mixing to specific frequency regions (inner/outer)
- Dual Output Ports: Generate two different output images with different mixing configurations
- Real-Time Visualization: View component changes with adjustable brightness and contrast
- Asynchronous Processing: Non-blocking image processing with progress tracking
- Auto-Resizing: Automatically resize images to match dimensions ("One Size" rule)
backend_api.py: Main API interface coordinating all backend operationsserver.py: Flask REST API server handling HTTP requests- Classes:
ImageProcessor: Handles image loading, FFT computation, and component extractionFourierMixer: Mixes Fourier components from multiple images with advanced filteringComponentVisualizer: Visualizes Fourier components with normalization
- React 19 with modern hooks
- Zustand for state management
- Tailwind CSS for styling
- Vite for fast development and building
- Modular Component Architecture:
ImageViewer: Display and control image componentsLayout: Main layout and sidebar for controlsUI: Reusable UI components (sliders, progress bars)
- Python 3.8+
- Node.js 16+ and npm
- pip (Python package manager)
- Navigate to the backend directory:
cd backend- Create a virtual environment (recommended):
python -m venv venv
# Windows
venv\Scripts\activate
# Linux/Mac
source venv/bin/activate- Install Python dependencies:
pip install -r requirements.txt- Navigate to the frontend directory:
cd frontend/ft-mixer-frontend- Install Node dependencies:
npm installFrom the backend directory:
python server.pyThe Flask server will start on http://localhost:5000
From the frontend/ft-mixer-frontend directory:
npm run devThe Vite development server will start on http://localhost:5173
Open your browser and navigate to http://localhost:5173
- Click on any of the 4 input slots
- Upload an image file (PNG, JPG, etc.)
- Images are automatically converted to grayscale and resized to match dimensions
For each input image, you can view:
- Original: The original color image
- Greyscale: Grayscale conversion
- Magnitude: Amplitude of frequency components
- Phase: Phase angle of frequency components
- Real: Real part of complex Fourier transform
- Imaginary: Imaginary part of complex Fourier transform
-
Select Mixing Mode:
- Magnitude/Phase: Mix magnitude and phase independently
- Real/Imaginary: Mix real and imaginary parts independently
-
Adjust Component Weights (0.0 to 1.0):
- Set weights for each component from each input image
- Higher weight = more influence from that component
-
Configure Region Filtering (optional):
- Enable region-based filtering
- Choose between unified or per-image regions
- Select inner/outer region for each component
- Adjust region position and size
-
Select Output Port (1 or 2):
- Choose which output slot to render the result
-
Click "Mix Images":
- Processing happens asynchronously
- Progress bar shows mixing status
- Result appears in the selected output port
- Brightness/Contrast Control: Adjust visualization parameters for each component
- Multiple Mixing Configurations: Use two output ports to compare different mixing settings
- Progress Tracking: Monitor long-running operations
- Cancellable Operations: Stop processing if needed
POST /upload/<slot_id>
Body: multipart/form-data with 'file' field
Returns: Processed grayscale image data
GET /view/<slot_id>/<component_type>
Parameters:
- slot_id: 0-3 (input slot)
- component_type: Original, Greyscale, Magnitude, Phase, Real, Imaginary
Returns: Component visualization as base64 image
POST /mix
Body: JSON with mixing configuration
{
"mode": "magnitude_phase" | "real_imaginary",
"weights": { "magnitude": [...], "phase": [...], ... },
"region": { ... },
"target_output_port": 1 | 2
}
Returns: Operation status
GET /output/<port_id>
Parameters: port_id (1 or 2)
Returns: Mixed output image
GET /progress
Returns: Current processing progress (0-100)
POST /cancel
Returns: Cancellation status
Image-Mixer/
โโโ backend/
โ โโโ backend_api.py # Main API interface
โ โโโ server.py # Flask REST server
โ โโโ requirements.txt # Python dependencies
โ โโโ classes/
โ โ โโโ image_processor.py # Image loading and FFT
โ โ โโโ fourier_mixer.py # Component mixing logic
โ โ โโโ component_visualizer.py # Visualization utilities
โ โโโ tests/ # Unit and integration tests
โโโ frontend/
โ โโโ ft-mixer-frontend/
โ โโโ src/
โ โ โโโ components/ # React components
โ โ โโโ store/ # Zustand state management
โ โ โโโ utils/ # API client utilities
โ โโโ package.json # Node dependencies
โ โโโ vite.config.js # Vite configuration
โโโ README.md
Run backend tests:
cd backend
python -m pytest tests/Available test suites:
test_image_processor.py: Image loading and FFT operationstest_fourier_mixer.py: Component mixing logictest_component_visualizer.py: Visualization functionstest_async_operations.py: Asynchronous processingtest_integration.py: End-to-end workflowstest_verification.py: System verification
- NumPy: Numerical computations and FFT
- Pillow (PIL): Image loading and manipulation
- SciPy: Advanced signal processing
- Matplotlib: Visualization support
- Flask: Web framework
- Flask-CORS: Cross-origin resource sharing
- React 19: UI framework
- Zustand: State management
- Vite: Build tool and dev server
- Tailwind CSS: Utility-first CSS framework
- Lucide React: Icon library
The application leverages the 2D Fourier Transform to decompose images into their frequency components:
- Forward FFT: Converts spatial domain image to frequency domain
- Component Extraction: Separates magnitude, phase, real, and imaginary parts
- Component Mixing: Combines components from different images using weighted averages
- Inverse FFT: Reconstructs spatial domain image from mixed components
- Load images and compute their FFTs
- Extract desired components (magnitude/phase or real/imaginary)
- Apply weights to each component from each image
- Optionally filter by frequency regions
- Combine weighted components
- Perform inverse FFT to generate output image
- Normalize and convert to displayable format
- Inner Region: Low frequency components (smooth features)
- Outer Region: High frequency components (edges and details)
- Allows selective mixing of different frequency bands from different images
Contributions are welcome! Please follow these guidelines:
- Fork the repository
- Create a feature branch
- Make your changes with clear commit messages
- Add tests for new functionality
- Submit a pull request
This project is open source and available for educational and research purposes.
- Port 5000 already in use: Change port in
server.py - Module import errors: Ensure virtual environment is activated and dependencies installed
- Image loading fails: Check file permissions and supported formats
- CORS errors: Verify backend is running and CORS is properly configured
- API connection failed: Check backend URL in
api.js - Build errors: Clear
node_modulesand reinstall dependencies
- Images different sizes: The app auto-resizes, but ensure images are reasonable dimensions
- Slow processing: Large images take longer to process; consider resizing before upload
- Memory errors: Reduce image size or number of simultaneous operations
For issues, questions, or contributions, please open an issue on the project repository.
Happy Image Mixing! ๐จโจ