GPU-accelerated image comparison using PSNR (Peak Signal-to-Noise Ratio).
import GoldenImage
let comparison = ImageComparison()
let result = try comparison.compare(image1, image2)
print("PSNR: \(result.psnr) dB")
print("Match: \(result.isMatch)") // true if PSNR >= 120 dBThe ImageComparison type supports multiple image formats:
CGImage- Core Graphics imagesCIImage- Core Image imagesMTLTexture- Metal textures (GPU-accelerated)URL- Load and compare images from file URLsImage- SwiftUI images (macOS only)
golden-image-compare image1.png image2.pngExample output:
PSNR: 120.00 dB (images are identical or nearly identical)
≥ 120 dB- Identical or nearly identical images> 40 dB- Excellent (differences barely noticeable)30-40 dB- Good (minor differences)20-30 dB- Fair (differences visible)< 20 dB- Poor (significant differences)
MIT