当前位置:网站首页>Image enhancement based on deep learning
Image enhancement based on deep learning
2022-04-21 07:30:00 【sxxblogs】
Image enhancement : Enhance the useful information in the image , It can be a distortion process , The purpose is to improve the visual effect of the image .
In the context of deep learning , Image enhancement is to enrich the sample features of the image , Make model generalization more powerful . Common ways are : rotate 、 tailoring 、 Horizontal or vertical rotation 、 Change the brightness 、 Gauss filtering 、 blurred .
The image enhancement technology involved in this paper is through opencv Realization .
import random
import pickle
import os
import cv2
import time
import numpy as np
import matplotlib.pyplot as plt
from PIL import Image, ImageDraw
import os.path as osp
def img_show(img_raw):
cv2.namedWindow("Image")
cv2.imshow('Image',img_raw)
cv2.waitKey (0)
cv2.destroyAllWindows()
return img_raw
def rota_img(raw_img,degree):
""" opencv Realization Random arbitrary angle of the image (0~360 degree ) rotate degree: Rotation Angle :return: Image after rotation """
h, w, c = raw_img.shape#(768,480,3)
center_x = w // 2
center_y = h // 2
center = (center_x, center_y)
M= cv2.getRotationMatrix2D(center, -degree, 1.)
image = cv2.warpAffine(raw_img, M, (w, h))
#mode=Image.BICUBIC
#random_angle = np.random.randint(1, 360)
#img_rota=raw_img.rotate(random_angle, mode)
return image
def reflect_img(raw_img):
''' Affine transformation : p1: Three points in the original picture p2: Three points after the radiation transformation The three points correspond to the upper left corner 、 Upper right corner 、 The lower left corner '''
h, w, c = raw_img.shape#(768,480,3)
p1 = np.float32([[0,0], [w-1,0], [0,h-1]])
p2 = np.float32([[0,h*0.3], [w*0.8,h*0.2], [w*0.15,h*0.7]])
M = cv2.getAffineTransform(p1, p2)
img = cv2.warpAffine(raw_img, M, (w,h))
return img
def random_flip(raw_img,min_ratio=0.6, max_ratio=1.0):
''' The picture to achieve random 0.6~1.0 Ratio clipping , Keep the aspect ratio unchanged '''
h, w, c = raw_img.shape
ratio = random.random()
scale = min_ratio + ratio * (max_ratio - min_ratio)
new_h = int(h*scale)
new_w = int(w*scale)
y = np.random.randint(0, h - new_h)
x = np.random.randint(0, w - new_w)
image = raw_img[y:y+new_h, x:x+new_w, :]
return image
def random_resize_img(raw_img,size=128,bias=5):
''' Press size Size clipping '''
h, w, c = raw_img.shape
size_min = min(w,h)
size_max = max(w,h)
min_size = size + np.random.randint(1, bias)
scale = float(min_size) / float(size_min)
image = cv2.resize(raw_img, dsize=(0, 0), fx=scale, fy=scale)
return image
def random_crop_and_resize(image, size=128):
''' Cut to size '''
image = random_resize_img(image)
h, w = image.shape[:2]
y = np.random.randint(0, h-size)
x = np.random.randint(0, w-size)
image = image[y:y+size, x:x+size, :]
return image
def img_noise(image,flag):
''' Noise() '''
if flag==1:
# median filtering
img_result=cv2.medianBlur(image,5)
font=cv2.FONT_HERSHEY_SIMPLEX
# Mean filtering
if flag==2:
img_result=cv2.blur(image,(5,5))
# Gauss filtering
if flag==3:
img_result=cv2.GaussianBlur(image,(7,7),0)
# Gaussian bilateral filtering
if flag==4:
img_result=cv2.bilateralFilter(image,40,75,75)
return img_result
版权声明
本文为[sxxblogs]所创,转载请带上原文链接,感谢
https://yzsam.com/2022/04/202204210620143133.html
边栏推荐
猜你喜欢

Could not initialize cudnn ,please check cudnn installation.

Oracle使用dbms_crypto实现MD5值计算

虚幻引擎编程基础(二)

Fundamentals of graphics anti aliasing

Unreal connection to MySQL

图形学基础|泛光(Bloom)
Fundamentals of graphics | cartoon shadow map based on SDF

Oracle uses DBMS_ Crypto realizes MD5 value calculation

WordPress plugin - display posts

WordPress插件-Display Posts
随机推荐
图形学基础|基于SDF的卡通阴影图
Unity通过反射创建动态类
【手部姿态估计】开源数据集-合集-RGBD-IR-Depth
MySQL简单操作语句
定义一个标准的类
Fundamentals of graphics | cartoon shadow map based on SDF
Unity List使用Find或FindAll查找特定元素以及特定元素个数
SourceTree版本回溯以及单个改动版本回溯
深度学习的图像增强
Udevd retrieves the kernel module and loads the demo
Lua程序设计--笔记
VMWare vSphere Failed to create object
如何使用u深度启动u盘清除系统登录密码
Fundamentals of graphics | area light rendering based on LTC
The use of NuMA by dpdk and the basis of performance tuning under multi NUMA architecture
Oracle生成随机数
Unity 用于投掷物品的一阶贝塞尔曲线
Unity内置地形Terrain优化
Tracking memory leaks using mtrace
WordPress超时问题解决方法