
水下图像增强与复原传统算法包含对应论文章包含十多种算法算法研究用途。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,size15):img_minnp.min(img,axis2)kernelcv2.getStructuringElement(cv2.MORPH_RECT,(size,size))dark_channelcv2.erode(img_min,kernel)returndark_channeldefestimate_atmospheric_light(img,dark_channel):flat_dark_channeldark_channel.flatten()flat_imgimg.reshape(-1,3)indicesnp.argsort(flat_dark_channel)[-int(0.001*flat_dark_channel.size):]atmospheric_lightnp.median(flat_img[indices],axis0)returnatmospheric_lightdeftransmission_map(img,atmospheric_light,omega0.95):normalized_imgimg/atmospheric_light dark_channeldark_channel_prior(normalized_img)transmission1-omega*dark_channelreturntransmissiondefrecover_image(img,atmospheric_light,transmission,t00.1):transmissionnp.maximum(transmission,t0)recovered(img-atmospheric_light)/transmission[:,:,np.newaxis]atmospheric_light recoverednp.clip(recovered,0,255).astype(np.uint8)returnrecovered# 示例imgcv2.imread(underwater_image.jpg)dark_channeldark_channel_prior(img)atmospheric_lightestimate_atmospheric_light(img,dark_channel)transmissiontransmission_map(img,atmospheric_light)recovered_imgrecover_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):retinexnp.log10(img)-np.log10(cv2.GaussianBlur(img,(0,0),sigma))returnretinexdefmulti_scale_retinex(img,sigma_list):retinexnp.zeros_like(img)forsigmainsigma_list:retinexsingle_scale_retinex(img,sigma)retinexretinex/len(sigma_list)returnretinexdefcolor_restoration(img,alpha,beta):img_sumnp.sum(img,axis2,keepdimsTrue)color_restoredbeta*(np.log10(alpha*img)-np.log10(img_sum))returncolor_restoreddefmsrcp(img,sigma_list):imgnp.float64(img)1.0img_retinexmulti_scale_retinex(img,sigma_list)color_restoredcolor_restoration(img,125,46.0)img_msrcp255*(img_retinex*color_restored)img_msrcpnp.clip(img_msrcp,0,255).astype(np.uint8)returnimg_msrcp# 示例imgcv2.imread(underwater_image.jpg)sigma_list[15,80,200]enhanced_imgmsrcp(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):imgimg.astype(np.float32)/255.0img_correctednp.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_correctednp.clip(img_corrected,0,1)*255.0img_correctedimg_corrected.astype(np.uint8)returnimg_corrected# 示例imgcv2.imread(underwater_image.jpg)enhanced_imgcolor_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_yuvcv2.cvtColor(img,cv2.COLOR_BGR2YUV)img_yuv[:,:,0]cv2.equalizeHist(img_yuv[:,:,0])enhanced_imgcv2.cvtColor(img_yuv,cv2.COLOR_YUV2BGR)returnenhanced_img# 示例imgcv2.imread(underwater_image.jpg)enhanced_imghistogram_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,gamma2.2):look_up_tablenp.array([(i/255.0)**(1/gamma)*255foriinrange(256)],dtypenp.uint8)enhanced_imgcv2.LUT(img,look_up_table)returnenhanced_img# 示例imgcv2.imread(underwater_image.jpg)enhanced_imggamma_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):resultcv2.cvtColor(img,cv2.COLOR_BGR2LAB)avg_anp.average(result[:,:,1])avg_bnp.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)resultcv2.cvtColor(result,cv2.COLOR_LAB2BGR)returnresult# 示例imgcv2.imread(underwater_image.jpg)enhanced_imgwhite_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_limit2.0,tile_grid_size(8,8)):img_yuvcv2.cvtColor(img,cv2.COLOR_BGR2YUV)clahecv2.createCLAHE(clipLimitclip_limit,tileGridSizetile_grid_size)img_yuv[:,:,0]clahe.apply(img_yuv[:,:,0])enhanced_imgcv2.cvtColor(img_yuv,cv2.COLOR_YUV2BGR)returnenhanced_img# 示例imgcv2.imread(underwater_image.jpg)enhanced_imgclahe(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,d050,r10.5,rh2.0,c4.0,h2.0,l0.5):img_floatimg.astype(np.float32)/255.0img_lognp.log1p(img_float)img_fftnp.fft.fft2(img_log)img_fft_shiftnp.fft.fftshift(img_fft)M,Nimg.shape[:2]Dnp.sqrt((np.arange(M)-M//2)**2(np.arange(N)-N//2)**2).reshape(M,1)Dnp.repeat(D,N,axis1)H(rh-r1)*(1-np.exp(-c*(D**2/d0**2)))r1 img_filterednp.real(np.fft.ifft2(np.fft.ifftshift(img_fft_shift*H)))img_expnp.expm1(img_filtered)img_expnp.clip(img_exp,0,1)*255.0img_expimg_exp.astype(np.uint8)returnimg_exp# 示例imgcv2.imread(underwater_image.jpg,cv2.IMREAD_GRAYSCALE)enhanced_imghomomorphic_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,t00.1,w0.95,max_dist0.1):imgimg.astype(np.float32)/255.0dark_channelnp.min(img,axis2)atmospheric_lightnp.max(img,axis(0,1))transmission1-w*dark_channel transmissionnp.maximum(transmission,t0)img_dehazed(img-atmospheric_light)/transmission[:,:,np.newaxis]atmospheric_light img_dehazednp.clip(img_dehazed,0,1)*255.0img_dehazedimg_dehazed.astype(np.uint8)returnimg_dehazed# 示例imgcv2.imread(underwater_image.jpg)enhanced_imgdehazing(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):sourcesource.astype(np.float32)/255.0targettarget.astype(np.float32)/255.0source_meannp.mean(source,axis(0,1))source_stdnp.std(source,axis(0,1))target_meannp.mean(target,axis(0,1))target_stdnp.std(target,axis(0,1))img_normalized(source-source_mean)/source_std img_transferimg_normalized*target_stdtarget_mean img_transfernp.clip(img_transfer,0,1)*255.0img_transferimg_transfer.astype(np.uint8)returnimg_transfer# 示例sourcecv2.imread(reference_image.jpg)targetcv2.imread(underwater_image.jpg)enhanced_imgcolor_transfer(source,target)cv2.imshow(Original,target)cv2.imshow(Enhanced,enhanced_img)cv2.waitKey(0)cv2.destroyAllWindows()总结以上介绍了十种常用的水下图像增强与复原的传统算法每种算法都有其特定的应用场景和优势。