A React application that reduces the color palette of images using Principal Component Analysis (PCA) and K-means clustering algorithms.
- Upload and process images to reduce their color palette
- Adjustable number of target colors (2-512)
- Real-time progress tracking with percentage completion
- Side-by-side comparison of original and processed images
- Visual representation of the reduced color palette
- Count of unique colors in original and processed images
- Download processed images in PNG format
- Responsive design for mobile and desktop
- Dark mode support
- React 18
- TypeScript
- Vite
- Tailwind CSS
- Radix UI (for accessible components)
- Lucide React (for icons)
- Font Awesome (for social media icons)
- shadcn/ui components
- Node.js (v18 or higher recommended)
- npm or yarn
-
Clone the repository:
git clone https://github.com/yourusername/color-reduction-pca.git
-
Navigate to the project directory:
cd color-reduction-pca
-
Install dependencies:
npm install # or yarn install
-
Start the development server:
npm run dev # or yarn dev
-
Open your browser and navigate to
http://localhost:5173
- Click the "Upload Image" button to select an image from your computer
- Use the slider to select the desired number of colors (2-256)
- Click "Process Image" to start the color reduction
- Wait for the processing to complete
- View the results and compare the original and processed images
- Download the processed image if desired
- Fork the repository
- Create your feature branch (
git checkout -b feature/amazing-feature
) - Commit your changes (
git commit -m 'Add some amazing feature'
) - Push to the branch (
git push origin feature/amazing-feature
) - Open a Pull Request
This project is licensed under the MIT License - see the LICENSE file for details.
The application uses two main algorithms to reduce the color palette:
-
K-means Clustering: Groups similar colors together by:
- Randomly selecting initial centroids
- Assigning colors to nearest centroids
- Recalculating centroids based on cluster means
- Repeating until convergence or max iterations reached
-
Principal Component Analysis (PCA):
- Reduces dimensionality of color data
- Implemented using power iteration method
- Helps in finding main color variations
- Modern web browser with WebGL support
- Sufficient RAM for processing large images
- Node.js v18 or higher
- npm v7 or higher or yarn v1.22 or higher
- Chrome (latest)
- Firefox (latest)
- Safari (latest)
- Edge (latest)