水下图像增强与复原传统算法,包含对应论文章,包含十多种算法,算法研究用途。python语言。 文章仅供参考!![]()
好的,水下图像增强与复原是一个重要的研究领域,旨在改善水下图像的质量,使其更接近真实场景。以下是十种常用的水下图像增强与复原的传统算法,以及它们的简要介绍和对应的论文。这些算法主要使用Python语言实现。
1. Dark Channel Prior (DCP)
简介:Dark Channel Prior是一种基于大气散射模型的图像去雾算法,可以应用于水下图像增强。
论文:He, K., Sun, J., & Tang, X. (2009). Single image haze removal using dark channel prior. IEEE Transactions on Pattern Analysis and Machine Intelligence, 33(12), 2341-2353.
Python 实现:
importcv2importnumpyasnpdefdark_channel_prior(img,size=15):img_min=np.min(img,axis=2)kernel=cv2.getStructuringElement(cv2.MORPH_RECT,(size,size))dark_channel=cv2.erode(img_min,kernel)returndark_channeldefestimate_atmospheric_light(img,dark_channel):flat_dark_channel=dark_channel.flatten()flat_img=img.reshape(-1,3)indices=np.argsort(flat_dark_channel)[-int(0.001*flat_dark_channel.size):]atmospheric_light=np.median(flat_img[indices],axis=0)returnatmospheric_lightdeftransmission_map(img,atmospheric_light,omega=0.95):normalized_img=img/atmospheric_light dark_channel=dark_channel_prior(normalized_img)transmission=1-omega*dark_channelreturntransmissiondefrecover_image(img,atmospheric_light,transmission,t0=0.1):transmission=np.maximum(transmission,t0)recovered=(img-atmospheric_light)/transmission[:,:,np.newaxis]+atmospheric_light recovered=np.clip(recovered,0,255).astype(np.uint8)returnrecovered# 示例img=cv2.imread('underwater_image.jpg')dark_channel=dark_channel_prior(img)atmospheric_light=estimate_atmospheric_light(img,dark_channel)transmission=transmission_map(img,atmospheric_light)recovered_img=recover_image(img,atmospheric_light,transmission)cv2.imshow('Original',img)cv2.imshow('Enhanced',recovered_img)cv2.waitKey(0)cv2.destroyAllWindows()2. Retinex Theory
简介:Retinex理论基于人眼视觉系统,通过分解图像的光照和反射成分来增强图像。
论文:Land, E. H., & McCann, J. J. (1971). Lightness and retinex theory. Journal of the Optical Society of America, 61(1), 1-11.
Python 实现:
importcv2importnumpyasnpdefsingle_scale_retinex(img,sigma):retinex=np.log10(img)-np.log10(cv2.GaussianBlur(img,(0,0),sigma))returnretinexdefmulti_scale_retinex(img,sigma_list):retinex=np.zeros_like(img)forsigmainsigma_list:retinex+=single_scale_retinex(img,sigma)retinex=retinex/len(sigma_list)returnretinexdefcolor_restoration(img,alpha,beta):img_sum=np.sum(img,axis=2,keepdims=True)color_restored=beta*(np.log10(alpha*img)-np.log10(img_sum))returncolor_restoreddefmsrcp(img,sigma_list):img=np.float64(img)+1.0img_retinex=multi_scale_retinex(img,sigma_list)color_restored=color_restoration(img,125,46.0)img_msrcp=255*(img_retinex*color_restored)img_msrcp=np.clip(img_msrcp,0,255).astype(np.uint8)returnimg_msrcp# 示例img=cv2.imread('underwater_image.jpg')sigma_list=[15,80,200]enhanced_img=msrcp(img,sigma_list)cv2.imshow('Original',img)cv2.imshow('Enhanced',enhanced_img)cv2.waitKey(0)cv2.destroyAllWindows()3. Color Correction
简介:通过调整图像的颜色通道来改善水下图像的色彩。
论文:Cheng, D., Guo, P., Zhang, W., & Zuo, W. (2015). Underwater image enhancement by wavelength compensation and dehazing. IEEE Transactions on Image Processing, 24(12), 5614-5628.
Python 实现:
importcv2importnumpyasnpdefcolor_correction(img):img=img.astype(np.float32)/255.0img_corrected=np.zeros_like(img)img_corrected[:,:,0]=0.7*img[:,:,0]+0.3*img[:,:,1]img_corrected[:,:,1]=0.7*img[:,:,1]+0.3*img[:,:,2]img_corrected[:,:,2]=0.7*img[:,:,2]+0.3*img[:,:,0]img_corrected=np.clip(img_corrected,0,1)*255.0img_corrected=img_corrected.astype(np.uint8)returnimg_corrected# 示例img=cv2.imread('underwater_image.jpg')enhanced_img=color_correction(img)cv2.imshow('Original',img)cv2.imshow('Enhanced',enhanced_img)cv2.waitKey(0)cv2.destroyAllWindows()4. Histogram Equalization
简介:通过直方图均衡化来增强图像的对比度。
论文:Pizer, S. M., Amburn, E. P., Austin, J. D., Cromartie, R., Geselowitz, A., Greer, T., … & Zimmerman, J. B. (1987). Adaptive histogram equalization and its variations. Computer vision, graphics, and image processing, 39(3), 355-368.
Python 实现:
importcv2importnumpyasnpdefhistogram_equalization(img):img_yuv=cv2.cvtColor(img,cv2.COLOR_BGR2YUV)img_yuv[:,:,0]=cv2.equalizeHist(img_yuv[:,:,0])enhanced_img=cv2.cvtColor(img_yuv,cv2.COLOR_YUV2BGR)returnenhanced_img# 示例img=cv2.imread('underwater_image.jpg')enhanced_img=histogram_equalization(img)cv2.imshow('Original',img)cv2.imshow('Enhanced',enhanced_img)cv2.waitKey(0)cv2.destroyAllWindows()5. Gamma Correction
简介:通过伽玛校正来调整图像的亮度和对比度。
论文:Wang, Z., Bovik, A. C., Sheikh, H. R., & Simoncelli, E. P. (2004). Image quality assessment: From error visibility to structural similarity. IEEE Transactions on Image Processing, 13(4), 600-612.
Python 实现:
importcv2importnumpyasnpdefgamma_correction(img,gamma=2.2):look_up_table=np.array([(i/255.0)**(1/gamma)*255foriinrange(256)],dtype=np.uint8)enhanced_img=cv2.LUT(img,look_up_table)returnenhanced_img# 示例img=cv2.imread('underwater_image.jpg')enhanced_img=gamma_correction(img)cv2.imshow('Original',img)cv2.imshow('Enhanced',enhanced_img)cv2.waitKey(0)cv2.destroyAllWindows()6. White Balance
简介:通过白平衡调整来校正图像的色温。
论文:Gijsenij, A., & Gevers, T. (2011). Computational color constancy: Survey and experiments. IEEE Transactions on Image Processing, 20(9), 2475-2489.
Python 实现:
importcv2importnumpyasnpdefwhite_balance(img):result=cv2.cvtColor(img,cv2.COLOR_BGR2LAB)avg_a=np.average(result[:,:,1])avg_b=np.average(result[:,:,2])result[:,:,1]=result[:,:,1]-((avg_a-128)*(result[:,:,0]/255.0)*1.1)result[:,:,2]=result[:,:,2]-((avg_b-128)*(result[:,:,0]/255.0)*1.1)result=cv2.cvtColor(result,cv2.COLOR_LAB2BGR)returnresult# 示例img=cv2.imread('underwater_image.jpg')enhanced_img=white_balance(img)cv2.imshow('Original',img)cv2.imshow('Enhanced',enhanced_img)cv2.waitKey(0)cv2.destroyAllWindows()7. Contrast Limited Adaptive Histogram Equalization (CLAHE)
简介:通过局部直方图均衡化来增强图像的对比度,同时限制对比度的过度增强。
论文:Zuiderveld, K. (1994). Contrast limited adaptive histogram equalization. In Graphics gems IV (pp. 474-485). Academic Press Professional, Inc.
Python 实现:
importcv2importnumpyasnpdefclahe(img,clip_limit=2.0,tile_grid_size=(8,8)):img_yuv=cv2.cvtColor(img,cv2.COLOR_BGR2YUV)clahe=cv2.createCLAHE(clipLimit=clip_limit,tileGridSize=tile_grid_size)img_yuv[:,:,0]=clahe.apply(img_yuv[:,:,0])enhanced_img=cv2.cvtColor(img_yuv,cv2.COLOR_YUV2BGR)returnenhanced_img# 示例img=cv2.imread('underwater_image.jpg')enhanced_img=clahe(img)cv2.imshow('Original',img)cv2.imshow('Enhanced',enhanced_img)cv2.waitKey(0)cv2.destroyAllWindows()8. Homomorphic Filtering
简介:通过同态滤波来减少图像中的光照变化。
论文:Gonzalez, R. C., & Woods, R. E. (2008). Digital image processing (3rd ed.). Pearson Prentice Hall.
Python 实现:
importcv2importnumpyasnpimportmatplotlib.pyplotaspltdefhomomorphic_filtering(img,d0=50,r1=0.5,rh=2.0,c=4.0,h=2.0,l=0.5):img_float=img.astype(np.float32)/255.0img_log=np.log1p(img_float)img_fft=np.fft.fft2(img_log)img_fft_shift=np.fft.fftshift(img_fft)M,N=img.shape[:2]D=np.sqrt((np.arange(M)-M//2)**2+(np.arange(N)-N//2)**2).reshape(M,1)D=np.repeat(D,N,axis=1)H=(rh-r1)*(1-np.exp(-c*(D**2/d0**2)))+r1 img_filtered=np.real(np.fft.ifft2(np.fft.ifftshift(img_fft_shift*H)))img_exp=np.expm1(img_filtered)img_exp=np.clip(img_exp,0,1)*255.0img_exp=img_exp.astype(np.uint8)returnimg_exp# 示例img=cv2.imread('underwater_image.jpg',cv2.IMREAD_GRAYSCALE)enhanced_img=homomorphic_filtering(img)cv2.imshow('Original',img)cv2.imshow('Enhanced',enhanced_img)cv2.waitKey(0)cv2.destroyAllWindows()9. Dehazing
简介:通过去雾算法来减少水下图像中的模糊和散射。
论文:Tarel, J. P., & Hautière, N. (2009). Fast visibility restoration from a single color or gray level image. In 2009 IEEE 12th International Conference on Computer Vision (pp. 2201-2208). IEEE.
Python 实现:
importcv2importnumpyasnpdefdehazing(img,t0=0.1,w=0.95,max_dist=0.1):img=img.astype(np.float32)/255.0dark_channel=np.min(img,axis=2)atmospheric_light=np.max(img,axis=(0,1))transmission=1-w*dark_channel transmission=np.maximum(transmission,t0)img_dehazed=(img-atmospheric_light)/transmission[:,:,np.newaxis]+atmospheric_light img_dehazed=np.clip(img_dehazed,0,1)*255.0img_dehazed=img_dehazed.astype(np.uint8)returnimg_dehazed# 示例img=cv2.imread('underwater_image.jpg')enhanced_img=dehazing(img)cv2.imshow('Original',img)cv2.imshow('Enhanced',enhanced_img)cv2.waitKey(0)cv2.destroyAllWindows()10. Color Transfer
简介:通过颜色迁移将参考图像的颜色风格应用到目标图像上。
论文:Pitié, F., Kokaram, A. C., & Dahyot, R. F. (2007). Automated colour grading using colour distribution transfer. Computer Vision and Image Understanding, 107(1-2), 123-137.
Python 实现:
importcv2importnumpyasnpdefcolor_transfer(source,target):source=source.astype(np.float32)/255.0target=target.astype(np.float32)/255.0source_mean=np.mean(source,axis=(0,1))source_std=np.std(source,axis=(0,1))target_mean=np.mean(target,axis=(0,1))target_std=np.std(target,axis=(0,1))img_normalized=(source-source_mean)/source_std img_transfer=img_normalized*target_std+target_mean img_transfer=np.clip(img_transfer,0,1)*255.0img_transfer=img_transfer.astype(np.uint8)returnimg_transfer# 示例source=cv2.imread('reference_image.jpg')target=cv2.imread('underwater_image.jpg')enhanced_img=color_transfer(source,target)cv2.imshow('Original',target)cv2.imshow('Enhanced',enhanced_img)cv2.waitKey(0)cv2.destroyAllWindows()总结
以上介绍了十种常用的水下图像增强与复原的传统算法,每种算法都有其特定的应用场景和优势。