Denoise Image
Remove noise from images while preserving important details and edges.
/api/image/denoise
Request Parameters
Parameter | Type | Required | Description |
---|---|---|---|
file | File | Yes | The image file to denoise. Supported formats: JPEG, PNG, WebP, BMP, TIFF. |
strength | Integer | No | The strength of the denoising effect. Higher values remove more noise but may blur details. Range: 1-20. Default: 10 . |
Response
Returns the denoised image in the same format as the input file.
Example Request
// example.sh
curl -X POST "https://oyyi.xyz/api/image/denoise" -H "accept: application/json" \
-H "Content-Type: multipart/form-data" \
-F "file=@noisy_image.jpg" \
-F "strength=10" \
--output denoised.jpg
Example with Python
// denoise.py
import requests
url = "https://oyyi.xyz/api/image/denoise"
files = {
'file': open('noisy_image.jpg', 'rb')
}
data = {
'strength': 10
}
response = requests.post(url, files=files, data=data)
# Save the denoised image
with open('denoised.jpg', 'wb') as f:
f.write(response.content)
Example with JavaScript
// denoise.js
// Using fetch API
const formData = new FormData();
formData.append('file', fileInput.files[0]);
formData.append('strength', '10');
fetch('https://oyyi.xyz/api/image/denoise', {
method: 'POST',
body: formData
})
.then(response => response.blob())
.then(blob => {
// Create a URL for the blob
const url = URL.createObjectURL(blob);
// Create a link to download the image
const a = document.createElement('a');
a.href = url;
a.download = 'denoised.jpg';
a.click();
// Clean up by revoking the URL
URL.revokeObjectURL(url);
})
.catch(error => console.error('Error:', error));
Denoising Methods
Non-Local Means (NLM)
Advanced algorithm that compares similar patches across the image. Excellent at preserving details while removing noise. Best for most use cases but more computationally intensive.
Total Variation (TV)
Minimizes variations between pixels while preserving edges. Good for removing noise while maintaining sharp edges. Can create a slightly cartoon-like appearance.
Bilateral
Edge-preserving smoothing filter that considers both spatial proximity and color similarity. Good balance between noise removal and detail preservation.
Gaussian
Simple blur-based denoising. Fast but less effective at preserving details. Good for images with minimal noise or when a slight blur is acceptable.
Median
Replaces each pixel with the median value of neighboring pixels. Excellent for removing salt-and-pepper noise while preserving edges.
How It Works
Image denoising works by identifying and removing random variations in pixel values while attempting to preserve important image features:
- Non-Local Means: Compares patches across the entire image to find similar patterns, then averages them to reduce noise while preserving unique details.
- Total Variation: Minimizes the total variation of the image (the sum of the gradients) while maintaining fidelity to the original image.
- Bilateral Filter: Combines domain and range filtering to smooth images while preserving edges by considering both spatial proximity and pixel value similarity.
- Gaussian Filter: Applies a weighted average of surrounding pixels, with weights decreasing with distance according to a Gaussian distribution.
- Median Filter: Replaces each pixel with the median value of neighboring pixels, which effectively removes outliers (noise) without affecting edges.
The strength parameter controls the intensity of the denoising effect, with higher values removing more noise but potentially blurring more details.
Strength Examples
Low Strength (1-5)
Subtle noise reduction, preserves most details
Medium Strength (6-12)
Balanced noise reduction, good for most uses
High Strength (13-20)
Strong noise reduction, may blur fine details
Error Responses
Status Code | Description |
---|---|
400 | Bad request. Missing required parameters, invalid strength value, invalid method, or invalid file format. |
413 | Payload too large. The file size exceeds the maximum allowed limit. |
500 | Internal server error. Something went wrong on the server. |
Notes
- The Non-Local Means method is generally the most effective for preserving details while removing noise, but it is also the most computationally intensive.
- The Median filter is particularly effective for salt-and-pepper noise (random black and white pixels).
- Setting preserve_details to true is recommended for images where fine details are important, such as portraits or architectural photography.
- For images with severe noise, you may need to use a higher strength value, but be aware that this may result in some loss of detail.
- The maximum file size allowed is 10MB.
- Processing time increases with image size and varies depending on the denoising method used.
- This operation preserves the alpha channel (transparency) if present in the original image.
Use Cases
- Improving low-light or high-ISO photography with visible noise
- Enhancing scanned documents or old photographs
- Cleaning up images for professional presentations or publications
- Preparing images for further processing or analysis
- Improving the quality of compressed or degraded images
- Enhancing medical or scientific imagery
- Preparing images for printing where noise would be more visible