Normalize
Automatically enhance image contrast by stretching the histogram to use the full dynamic range. Normalize adjusts brightness and contrast to improve visibility and overall image quality without manual adjustments.
Installation
To install the Image plugin:
Usage
Basic Usage
Options
| Option | Alias | Type | Default | Description |
|---|---|---|---|---|
--output <path> | -o | string | <input>-normalized.<ext> | Output file path |
--quality <quality> | -q | number | 90 | Output quality (1-100) for lossy formats |
--dry-run | boolean | false | Show what would be done without executing | |
--verbose | -v | boolean | false | Show detailed processing information |
--help | boolean | false | Display help information |
How Normalize Works
Normalization enhances contrast through histogram stretching:
- Analyze Histogram: Examines the distribution of pixel values
- Find Range: Identifies darkest and brightest pixels
- Stretch Histogram: Maps darkest pixel to black (0) and brightest to white (255)
- Redistribute Values: All other pixels are proportionally adjusted
Formula
For each pixel:
normalized_value = (original_value - min_value) × (255 / (max_value - min_value))
Effect
- Darkest pixel → Black (0)
- Brightest pixel → White (255)
- Mid-tones → Spread across full range
- Contrast → Maximum possible for image content
Examples
1. Basic Contrast Enhancement
Enhance a dull, low-contrast image:
mediaproc image normalize flat-image.jpg
Result: Outputs flat-image-normalized.jpg with improved contrast and visibility.
2. Fix Underexposed Photo
Brighten a too-dark image:
mediaproc image normalize dark-photo.png
Effect: Dark image is brightened and contrast is enhanced automatically.
3. Fix Overexposed Photo
Improve washed-out, too-bright image:
mediaproc image normalize washed-out.jpg -o corrected.jpg
Benefit: Recovers detail in bright areas and improves overall contrast.
4. Enhance Scanned Document
Improve scanned document readability:
mediaproc image normalize scan.jpg -q 100
Quality: High quality output preserves text clarity.
5. Batch Processing
Normalize multiple old photos:
mediaproc image normalize "old-photos/*.jpg"
Output: Creates *-normalized.jpg for each input with consistent enhancement.
6. Poor Lighting Correction
Fix images with bad lighting:
mediaproc image normalize poorly-lit.png
Result: Compensates for poor lighting conditions automatically.
7. Custom Quality
Normalize with specific output quality:
mediaproc image normalize photo.jpg -q 95 -o enhanced.jpg
Control: High quality for important images.
8. Medical Imaging
Enhance medical scans:
mediaproc image normalize xray.png
Application: Improves visibility of diagnostic features.
9. Surveillance Footage
Enhance low-light surveillance images:
mediaproc image normalize security-cam.jpg
Security: Better visibility in poor lighting conditions.
10. Product Photography
Standardize product photo exposure:
mediaproc image normalize product.jpg -o web-ready.jpg
Consistency: Uniform appearance across product catalog.
11. Preview Before Processing
Check normalization effect:
mediaproc image normalize test.jpg --dry-run
Safety: Verify operation before creating output file.
12. Artistic Photography
Create high-contrast artistic look:
mediaproc image normalize artistic.jpg
Style: Maximum contrast for dramatic effect.
13. Microscope Images
Enhance microscope photography:
mediaproc image normalize microscope-sample.png -q 100
Scientific: Better visualization of specimen details.
14. Astronomical Images
Improve star field visibility:
mediaproc image normalize starfield.jpg
Astronomy: Reveal faint stars and nebulae.
15. Verbose Processing
See detailed processing information:
mediaproc image normalize photo.jpg --verbose
Debugging: Shows dimensions, format, and processing details.
When to Use Normalize
Perfect For
- Underexposed Images: Too dark, need brightening
- Overexposed Images: Too bright, washed out
- Low Contrast: Flat, dull appearance
- Poor Lighting: Images shot in bad lighting conditions
- Scanned Documents: Improve readability
- Old Photos: Restore faded photographs
- Batch Corrections: Consistent enhancement across multiple images
May Not Help
- Well-Exposed Images: Already have good contrast
- Intentional Low-Key: Dark, moody photography
- Intentional High-Key: Bright, ethereal aesthetic
- Extremely Damaged: Severe over/underexposure may lose detail
Technical Details
Histogram Stretching
The algorithm:
- Find minimum pixel value (darkest):
min = 15 - Find maximum pixel value (brightest):
max = 240 - Calculate range:
range = 240 - 15 = 225 - Stretch to full range (0-255):
- Old min (15) → New 0
- Old max (240) → New 255
- Mid-values proportionally adjusted
Per-Channel Processing
For RGB images:
- Red, Green, and Blue channels normalized independently
- Preserves color relationships
- Avoids color shifts
- Maintains white balance
Alpha Channel
Transparency is preserved:
- Alpha channel not normalized
- Transparent areas remain transparent
- Only RGB channels affected
Performance
Normalization is very fast:
- Small image (less than 1MP): ~10-20ms
- Medium image (5MP): ~30-50ms
- Large image (20MP): ~100-150ms
- Very efficient, single-pass algorithm
Combining with Other Commands
Normalize + Sharpen
Enhance contrast then sharpen details:
# Normalize first
mediaproc image normalize dull-photo.jpg -o normalized.jpg
# Then sharpen
mediaproc image sharpen normalized.jpg
Benefit: Improved contrast allows more effective sharpening.
Normalize + Auto-Enhance
Combine automatic adjustments:
# Normalize contrast
mediaproc image normalize photo.jpg -o step1.jpg
# Auto-enhance colors
mediaproc image auto-enhance step1.jpg
Result: Comprehensive automatic enhancement.
Grayscale + Normalize
Convert to grayscale then enhance:
# Convert to grayscale
mediaproc image grayscale color-photo.jpg -o gray.jpg
# Normalize contrast
mediaproc image normalize gray.jpg
Effect: High-contrast black and white image.
Normalize + Median Filter
Remove noise then enhance:
# Remove noise first
mediaproc image median noisy.jpg -s 5 -o clean.jpg
# Then normalize
mediaproc image normalize clean.jpg
Workflow: Clean image before enhancement for best results.
Comparison with Other Adjustments
Normalize vs Auto-Enhance
Normalize:
- Only adjusts contrast (histogram stretching)
- No color adjustments
- No saturation changes
- Simple, fast algorithm
- Predictable results
Auto-Enhance:
- Adjusts contrast
- Adjusts colors
- Adjusts saturation
- More complex algorithm
- May vary by image content
Normalize vs Manual Adjustments
Normalize:
- Automatic, no user input
- Consistent across batch
- Fast to apply
- Maximum possible contrast
Manual (Linear, Modulate):
- User controls exact values
- Customized per image
- More time required
- Can create subtle effects
Use Cases
1. Old Photo Restoration
Restore faded photographs:
mediaproc image normalize vintage-photo.jpg
Restoration: Recovers original contrast and visibility.
2. Document Scanning
Improve scanned document quality:
mediaproc image normalize scanned-page.png -q 100
Readability: Better text clarity and contrast.
3. Low-Light Photography
Fix dark, underexposed photos:
mediaproc image normalize night-shot.jpg
Recovery: Brighten and reveal details in shadows.
4. Overcast Photography
Enhance flat, gray-day images:
mediaproc image normalize overcast-landscape.jpg
Improvement: Add punch to dull, flat lighting.
5. Medical Imaging
Enhance diagnostic images:
mediaproc image normalize mri-scan.png
Clinical: Better visualization for diagnosis.
6. Scientific Photography
Improve microscope and lab images:
mediaproc image normalize lab-sample.jpg
Research: Enhanced detail visibility.
7. Product Photography
Standardize product image exposure:
mediaproc image normalize "products/*.jpg"
E-commerce: Consistent appearance across catalog.
8. Real Estate Photography
Enhance interior shots:
mediaproc image normalize room-photo.jpg
Marketing: Better presentation of spaces.
9. Surveillance Enhancement
Improve security camera footage:
mediaproc image normalize security-frame.jpg
Security: Better identification capabilities.
10. Art Digitization
Enhance scanned artwork:
mediaproc image normalize art-scan.jpg -q 100
Preservation: Accurate digital representation.
Best Practices
1. Test First
Always test on representative image:
# Test on one image
mediaproc image normalize sample.jpg
# If good, process all
mediaproc image normalize "all/*.jpg"
2. Use Dry Run
Preview before processing:
mediaproc image normalize photo.jpg --dry-run
Check output path and settings.
3. Check Original Quality
Normalize works best when:
- Image has detail in shadows and highlights
- Not extremely over/underexposed
- Has some contrast to enhance
4. Preserve Originals
Always keep original files:
# Outputs to new file by default
mediaproc image normalize original.jpg
# Creates: original-normalized.jpg
5. Combine with Sharpening
Follow enhancement with selective sharpening:
mediaproc image normalize dull.jpg -o enhanced.jpg
mediaproc image sharpen enhanced.jpg
6. Use High Quality for Finals
For final output, use high quality:
mediaproc image normalize photo.jpg -q 95
7. Batch Process Carefully
Test settings on samples before batch:
# Test
mediaproc image normalize sample.jpg
# Then batch
mediaproc image normalize "photos/*.jpg"
Troubleshooting
Issue: No Visible Change
Problem: Image looks the same after normalization
Possible Causes:
- Image already well-exposed
- Image already uses full dynamic range
- Very flat, uniform image content
Solution: Check histogram or try manual adjustments:
# If normalize doesn't help, try manual contrast
mediaproc image linear photo.jpg -a 1.2
Issue: Too Much Contrast
Problem: Result is too contrasty, looks harsh
Possible Cause: Image had limited dynamic range
Solution: Use subtler manual adjustments:
# Instead of normalize
mediaproc image linear photo.jpg -a 1.1 -b 0.1
Issue: Color Shifts
Problem: Colors look different after normalization
Cause: Channels normalized independently may affect color balance
Solution: Use modulate for color preservation:
# Adjust brightness without normalizing
mediaproc image modulate photo.jpg -b 1.2
Issue: Lost Detail
Problem: Highlights blown out or shadows crushed
Cause: Extreme values stretched too far
Solution: Use gentler adjustment:
# Manual brightness instead
mediaproc image modulate photo.jpg -b 1.3
Issue: Batch Results Inconsistent
Problem: Different images have varying results
Cause: Each image normalized to its own range
Solution: This is expected - each image optimized independently. For consistency, use manual settings:
# Consistent adjustment across all
mediaproc image linear "photos/*.jpg" -a 1.2 -b 0.1
Performance Considerations
Processing Speed
Normalize is very fast:
- Faster than complex auto-enhance
- Single-pass algorithm
- Minimal computation per pixel
- Suitable for large batches
Memory Usage
Low memory requirements:
- Small images: under 50MB
- Large images: under 200MB
- No significant overhead
Batch Processing
# Efficient batch processing
mediaproc image normalize "photos/*.jpg"
Processes files sequentially with automatic memory management.
Related Commands
- auto-enhance - Comprehensive automatic adjustments
- linear - Manual brightness and contrast control
- modulate - Adjust brightness, saturation, hue
- sharpen - Enhance details after normalization
- median - Remove noise before normalization