You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
244 lines
10 KiB
244 lines
10 KiB
#import cv2
|
|
from flip_image_horizontal import horizontal
|
|
from flip_image_cross import cross
|
|
from flip_image_vertical import vertical
|
|
from image_enhancement import enhancement
|
|
from histogram_equalization import h_e
|
|
from edge_detection_Roberts import roberts
|
|
from edge_detection_Sobel import sobel
|
|
from edge_detection_Laplacian import laplacian
|
|
from edge_detection_Canny import canny
|
|
from houghlinesp import hlp
|
|
from open_operation import open
|
|
from close_operation import close
|
|
from image_erosion import erosion
|
|
from image_dilation import dilation
|
|
from affine_transformation import at
|
|
from bilinear_interpolation import bi
|
|
from salt_and_pepper_noise import add_salt_pepper
|
|
from image_panning import panning
|
|
from image_rotation import rotation
|
|
from linear_transformations import lt
|
|
from mean_filter import mf
|
|
from selective_filter import sf
|
|
from sort_statistical_class_filter import sscf
|
|
from style_migration_candy import candy
|
|
from style_migration_composition_vii import composition_vii
|
|
from style_migration_feathers import feathers
|
|
from style_migration_la_muse import la_muse
|
|
from style_migration_mosaic import mosaic
|
|
from style_migration_starry_night import starry_night
|
|
from style_migration_the_scream import the_scream
|
|
from style_migration_the_wave import the_wave
|
|
from style_migration_udnie import udnie
|
|
from grabcut import grabcut
|
|
#image_path='1.jpg'
|
|
def helplist():
|
|
print("输入enhance,对图像进行增强")
|
|
print("输入edge,对图像进行边缘检测")
|
|
print("输入operation,对图像进行运算")
|
|
print("输入filter,对图像施加滤波器")
|
|
print("输入noise,对图像添加椒盐噪声")
|
|
print("输入geometric,对图像进行几何变换")
|
|
print("输入morphology,对图像进行数字形态学上的处理")
|
|
print("输入hough,对图像进行直线检测")
|
|
print("输入style,对图像进行风格迁移")
|
|
print("输入background,对证件照的背景色进行替换")
|
|
|
|
if __name__ == '__main__':
|
|
print("本项目支持对图像进行各种处理")
|
|
print("输入 help 查看目录,输入 quit 退出程序")
|
|
cmd = input()
|
|
while(cmd != 'quit'):
|
|
if (cmd == 'enhance'):
|
|
print("请输入增强类型:")
|
|
print("edge:基于边缘检测的图像增强")
|
|
print("histogram:直方图均衡化")
|
|
a = input()
|
|
if(a == 'edge'):
|
|
print("请输入要增强的图片所在路径:")
|
|
b = input()
|
|
enhancement(b)
|
|
if(a == 'histogram'):
|
|
print("请输入要增强的图片所在路径:")
|
|
b = input()
|
|
h_e(b)
|
|
if (cmd == 'edge'):
|
|
print("请选择边缘检测的类型:")
|
|
print("roberts:Roberts算子")
|
|
print("sobel:Sobel算子")
|
|
print("laplacian:Laplacian算子")
|
|
print("canny:Canny边缘检测")
|
|
a = input()
|
|
if(a == 'roberts'):
|
|
print("请输入要进行边缘检测的图片所在路径:")
|
|
b = input()
|
|
roberts(b)
|
|
if(a == 'sobel'):
|
|
print("请输入要进行边缘检测的图片所在路径:")
|
|
b = input()
|
|
sobel(b)
|
|
if(a == 'laplacian'):
|
|
print("请输入要进行边缘检测的图片所在路径:")
|
|
b = input()
|
|
laplacian(b)
|
|
if(a == 'canny'):
|
|
print("请输入要进行边缘检测的图片所在路径:")
|
|
b = input()
|
|
canny(b)
|
|
if(cmd == 'operation'):
|
|
print("请选择要进行哪种运算:")
|
|
print("open:开运算")
|
|
print("close:闭运算:")
|
|
a = input()
|
|
if(a == 'open'):
|
|
print("请输入要进行开运算的图片所在路径:")
|
|
b = input()
|
|
open(b)
|
|
if(a == 'close'):
|
|
print("请输入要进行闭运算的图片所在路径:")
|
|
b = input()
|
|
close(b)
|
|
if(cmd == 'filter'):
|
|
print("请选择滤波器类型:")
|
|
print("mean:均值类滤波器")
|
|
print("selective:选择性滤波器")
|
|
print("sort:排序统计类滤波器")
|
|
a = input()
|
|
if(a == 'mean'):
|
|
print("请输入要施加均值类滤波器的图片所在路径:")
|
|
b = input()
|
|
mf(b)
|
|
if(a == 'selective'):
|
|
print("请输入要施加选择性滤波器的图片所在路径以及阈值:")
|
|
b,c = input().split()
|
|
sf(b,c)
|
|
if(a == 'sort'):
|
|
print("请输入要施加排序统计类滤波器的图片所在路径:")
|
|
b = input()
|
|
sscf(b)
|
|
if(cmd == 'noise'):
|
|
print("请输入要添加椒盐噪声的图片所在路径:")
|
|
a = input()
|
|
add_salt_pepper(a)
|
|
if(cmd == 'geometric'):
|
|
print("请选择要进行的几何变换类型:")
|
|
print("flip:翻转")
|
|
print("bilinear:放缩")
|
|
print("panning:平移")
|
|
print("rotation:旋转")
|
|
print("linear:线性变换")
|
|
print("affine:仿射变换")
|
|
a = input()
|
|
if(a == 'flip'):
|
|
print("请选择要进行翻转的类型:")
|
|
print("horizontal:水平翻转")
|
|
print("vertical:垂直翻转")
|
|
print("cross:对角翻转")
|
|
b = input()
|
|
if(b == 'horizontal'):
|
|
print("请输入要进行水平翻转的图片所在路径:")
|
|
c = input()
|
|
horizontal(c)
|
|
if(b == 'vertical'):
|
|
print("请输入要进行垂直翻转的图片所在路径:")
|
|
c = input()
|
|
vertical(c)
|
|
if(b == 'cross'):
|
|
print("请输入要进行对角翻转的图片所在路径:")
|
|
c = input()
|
|
cross(c)
|
|
if(a == 'bilinear'):
|
|
print("请输入要改变大小的图片所在路径以及改变后x,y相较于原图的比例:")
|
|
b, c, d = input().split()
|
|
bi(b,c,d)
|
|
if(a == 'panning'):
|
|
print("请输入要进行平移的图片所在路径以及x,y轴移动的数值:")
|
|
b,c,d = input().split()
|
|
panning(b,c,d)
|
|
if(a == 'rotation'):
|
|
print("请输入要进行旋转的图片所在路径、旋转中心坐标、角度以及缩放因子:")
|
|
b,c,d,e = input().split()
|
|
rotation(b,c,d,e)
|
|
if(a == 'linear'):
|
|
print("请输入要进行线性变换的图片所在路径以及a,b,c,d的值:")
|
|
b,c,d,e,f = input().split()
|
|
lt(b,c,d,e,f)
|
|
if(a == 'affine'):
|
|
print("请输入要进行仿射变换的图片所在路径:")
|
|
b = input()
|
|
at(b)
|
|
if(cmd == 'morphology'):
|
|
print("请选择要进行的数字形态学操作:")
|
|
print("erosion:腐蚀")
|
|
print("dilation:膨胀")
|
|
a = input()
|
|
if(a == 'erosion'):
|
|
print("请输入要进行腐蚀操作的图片所在路径以及结构元的大小:")
|
|
b,c = input().split()
|
|
erosion(b,c)
|
|
if(a == 'dilation'):
|
|
print("请输入要进行膨胀操作的图片所在路径以及结构元的大小:")
|
|
b,c = input().split()
|
|
dilation(b,c)
|
|
if(cmd == 'hough'):
|
|
print("请输入要进行直线检测的图片所在路径:")
|
|
b = input()
|
|
hlp(b)
|
|
if(cmd == 'style'):
|
|
print("请选择要进行哪种风格迁移:")
|
|
print("candy:糖果风格")
|
|
print("composition:抽象油画风格")
|
|
print("feather:羽毛风格")
|
|
print("muse:缪斯风格")
|
|
print("mosaic:马赛克风格")
|
|
print("starry:星夜风格")
|
|
print("scream:呐喊风格")
|
|
print("wave:波浪风格")
|
|
print("udnie:udnie风格")
|
|
b = input()
|
|
if(b == 'candy'):
|
|
print("请输入要进行糖果风格迁移的图片所在路径")
|
|
c = input()
|
|
candy(c)
|
|
if(b == 'composition'):
|
|
print("请输入要进行抽象油画风格迁移的图片所在路径")
|
|
c = input()
|
|
composition_vii(c)
|
|
if(b == 'feather'):
|
|
print("请输入要进行羽毛风格迁移的图片所在路径")
|
|
c = input()
|
|
feathers(c)
|
|
if(b == 'muse'):
|
|
print("请输入要进行缪斯风格迁移的图片所在路径")
|
|
c = input()
|
|
la_muse(c)
|
|
if(b == 'mosaic'):
|
|
print("请输入要进行马赛克风格迁移的图片所在路径")
|
|
c = input()
|
|
mosaic(c)
|
|
if(b == 'starry'):
|
|
print("请输入要进行星夜风格迁移的图片所在路径")
|
|
c = input()
|
|
starry_night(c)
|
|
if(b == 'scream'):
|
|
print("请输入要进行呐喊风格迁移的图片所在路径")
|
|
c = input()
|
|
the_scream(c)
|
|
if(b == 'wave'):
|
|
print("请输入要进行波浪风格迁移的图片所在路径")
|
|
c = input()
|
|
the_wave(c)
|
|
if(b == 'udnie'):
|
|
print("请输入要进行udnie风格迁移的图片所在路径")
|
|
c = input()
|
|
udnie(c)
|
|
if(cmd == 'background'):
|
|
print("请输入要替换背景色的证件照片所在路径以及要替换的颜色")
|
|
print("蓝色:blue, 红色:red, 白色:white, 蓝白渐变色:bw, 浅灰色:lg")
|
|
b, c = input().split()
|
|
grabcut(b, c)
|
|
if(cmd == 'help'):
|
|
helplist()
|
|
cmd = input("输入 help 查看目录,输入 quit 退出\n")
|