zoukankan      html  css  js  c++  java
  • 图像处理模糊+python

    import os
    import numpy as np
    import cv2
    
    old_ng='./train_B/'
    new_wg_dir='./clear/train_A/'
    new_ng_dir='./clear/train_B/'
    if  not os.path.exists(new_wg_dir):
        new_wg_dir=os.mkdir(new_wg_dir)
    if  not os.path.exists(new_ng_dir):
        new_ng_dir=os.mkdir(new_ng_dir)
    
    HH=os.listdir(old_ng)
    for i in range(0,len(HH)):
        fi=HH[i]
        clear_img = cv2.imread(old_ng+fi)
    
        blur_img2 = cv2.blur(clear_img,(1,15))
        blur_img2[:,:512,:]=clear_img[:,:512,:]
        
        blur_img3 = cv2.blur(clear_img,(15,1))
        blur_img3[:,:512,:]=clear_img[:,:512,:]
        
        blur_img4 = cv2.blur(blur_img2,(15,1))
        blur_img4[:,:512,:]=clear_img[:,:512,:]
        
        blur_img5 = cv2.medianBlur(clear_img,11) 
        blur_img5[:,:512,:]=clear_img[:,:512,:]
            
        cv2.imwrite(new_wg_dir + '0_blur21_' +str(i)+'.jpg',blur_img2)
        cv2.imwrite(new_ng_dir + '1_blur21_' +str(i)+'.jpg',clear_img)
        cv2.imwrite(new_wg_dir + '0_blur31_' +str(i)+'.jpg',blur_img3)
        cv2.imwrite(new_ng_dir + '1_blur31_' +str(i)+'.jpg',clear_img)    
        
        cv2.imwrite(new_wg_dir + '0_blur41_' +str(i)+'.jpg',blur_img4)
        cv2.imwrite(new_ng_dir + '1_blur41_' +str(i)+'.jpg',clear_img)
        cv2.imwrite(new_wg_dir + '0_blur51_' +str(i)+'.jpg',blur_img5)
        cv2.imwrite(new_ng_dir + '1_blur51_' +str(i)+'.jpg',clear_img)
        
        blur_img2 = cv2.blur(clear_img,(1,15))
        blur_img2[:,512:,:]=clear_img[:,512:,:]
        
        blur_img3 = cv2.blur(clear_img,(15,1))
        blur_img3[:,512:,:]=clear_img[:,512:,:]
        
        blur_img4 = cv2.blur(blur_img2,(15,1))
        blur_img4[:,512:,:]=clear_img[:,512:,:]
        
        blur_img5 = cv2.medianBlur(clear_img,11)
        blur_img5[:,512:,:]=clear_img[:,512:,:] 
            
        cv2.imwrite(new_wg_dir + '0_blur22_' +str(i)+'.jpg',blur_img2)
        cv2.imwrite(new_ng_dir + '1_blur22_' +str(i)+'.jpg',clear_img)
        cv2.imwrite(new_wg_dir + '0_blur32_' +str(i)+'.jpg',blur_img3)
        cv2.imwrite(new_ng_dir + '1_blur32_' +str(i)+'.jpg',clear_img)    
        
        cv2.imwrite(new_wg_dir + '0_blur42_' +str(i)+'.jpg',blur_img4)
        cv2.imwrite(new_ng_dir + '1_blur42_' +str(i)+'.jpg',clear_img)
        cv2.imwrite(new_wg_dir + '0_blur52_' +str(i)+'.jpg',blur_img5)
        cv2.imwrite(new_ng_dir + '1_blur52_' +str(i)+'.jpg',clear_img)
        print(i,len(HH))
         
    

      

  • 相关阅读:
    用于主题检测的临时日志(594fb726-af0b-400d-b647-8b1d1b477d72
    返璞归真vc++之字符类型
    DIV居中
    程序员职业生涯
    枚举进程句柄
    不使用mutex设计模式解决并发访问cache
    服务器权重分配算法
    xmemecached中的一致性hash算法
    安卓课堂练习
    pythonPTA---分支循环与集合7-1 jmu-python-韩信点兵 (20分) 7-2 打印数字矩形 (10分) 7-3 成绩统计 (10分) 7-4 找列表中最大元素的下标 7-5 删除列表中的重复值
  • 原文地址:https://www.cnblogs.com/wjjcjj/p/13793971.html
Copyright © 2011-2022 走看看