# dkimageapp **Repository Path**: weihaitong/dkimageapp ## Basic Information - **Project Name**: dkimageapp - **Description**: dkimageapp是61Duke于2020年整合工作与学习研发关于图像处理的实用工具Python依赖库模块,该模块统一规范的API接口,承载个人未来工作中开发有关图像处理实际应用。该模块由算法科学家61Duke独家研发,提供图像裁剪、合并、图像格式转换、色调占比提取、颜色相似度、图像定位和图像检索等功能。dkimageapp模块为各个项目和业务提供支持。 - **Primary Language**: Python - **License**: MIT - **Default Branch**: master - **Homepage**: None - **GVP Project**: No ## Statistics - **Stars**: 1 - **Forks**: 0 - **Created**: 2020-12-30 - **Last Updated**: 2022-06-08 ## Categories & Tags **Categories**: Uncategorized **Tags**: None ## README ========== dkimageapp ========== .. image:: https://img.shields.io/pypi/v/dkimageapp.svg :target: https://pypi.python.org/pypi/dkimageapp .. image:: https://img.shields.io/travis/61Duke/dkimageapp.svg :target: https://travis-ci.org/61Duke/dkimageapp .. image:: https://readthedocs.org/projects/dkimageapp/badge/?version=latest :target: https://dkimageapp.readthedocs.io/en/latest/?badge=latest :alt: Documentation Status dkimageapp是61Duke于2020年整合工作与学习研发关于图像处理的实用工具Python依赖库模块,该模块统一规范的API接口, 承载个人未来工作中开发有关图像处理实际应用。该模块由算法科学家61Duke独家研发,提供图像裁剪、合并、图像格式转换、 色调占比提取、颜色相似度、图像定位和图像检索等功能。dkimageapp模块为各个项目和业务提供支持。 * Free software: MIT license 文档 -------- 导入dkimageapp库:: import dkimageapp 图像合并 ~~~~~~~~~~~ 图像上加入图标和文字:: dkimageapp.core.addition_icon_autograph( source_image_path="imgs/IMG_2229.JPG", output_path="source_output.png", icon_path="imgs/icon.jpg", autograph="@61Duke", autograph_method="right_down", icon_method="right_down_circle" ) 图像色彩 ~~~~~~~~~~~ 提取图像主色调:: dominant = dkimageapp.core.colour_dominant(image_path="imgs/IMG_2229.JPG") print(dominant) # (0.51, (35, 18, 26)) 提取图像色调占比:: palette = dkimageapp.core.colour_ratio(image_path="imgs/IMG_2229.JPG") print(palette) # [(0.51, (35, 18, 26)), (0.19, (121, 41, 59)), (0.09, (142, 129, 110)), (0.07, (209, 129, 118)), (0.05, (214, 35, 62)), (0.04, (131, 102, 77)), (0.02, (225, 42, 115)), (0.02, (207, 188, 148))] 提取颜色与颜色的相似度:: similarity = dkimageapp.core.colour_similarity(base_rgb=(255, 0, 0), compare_rgb=(255, 5, 50)) print(similarity) # 0.4480129357712845 图像定位 ~~~~~~~~~~~ 图像GPS信息:: gps = dkimageapp.core.location_gps(image_path="imgs/IMG_2229.JPG") print(gps) """ { "GPS": { "GPSLatitudeRef": "N", "GPSLatitude": 18.292461111111113, "GPSLongitudeRef": "E", "GPSLongitude": 109.52616944444445, "GPSAltitudeRef": "0", "GPSAltitude": "41477/8571", "GPSAddress": "海南省三亚市吉阳区河东区街道迎宾路329号三亚千古情景区" }, "date": "2019:12:20 14:29:37" } """ 图像裁剪 ~~~~~~~~~~~ 视频分割成音频、视频添加音频功能依靠 ffmpeg。 FFmpeg是一套可以用来记录、转换数字音频、视频,并能将其转化为流的开源计算机程序。采用LGPL或GPL许可证。它提供了录制、转换以及流化音视频的完整解决方案。它包含了非常先进的音频/视频编解码库libavcodec,为了保证高可移植性和编解码质量,libavcodec里很多code都是从头开发的。 下载有命令行可以使用。 将GIF动图切割成一帧一帧图像:: dkimageapp.core.crop_gif2images( source_image_path="imgs/test.gif", output_folder="source_output" ) 图像坐标部分裁剪:: dkimageapp.core.crop_part_image( source_image_path="imgs/IMG_2229.JPG", output_path="source_output.png", box=(300, 200, 700, 800) ) 图像拼接 ~~~~~~~~~~~ 将一帧一帧图像和成GIF动图:: dkimageapp.core.stitch_images2gif( source_images_path=[ "imgs/20191017185607410.png", "imgs/20191017185634484.png", "imgs/icon.jpg", "imgs/IMG_2229.JPG", "imgs/IMG_2994.JPG" ], output_path="source_output.gif" ) 图像按照指定规格拼接:: dkimageapp.core.stitch_images( source_images_path=[ "imgs/20191017185607410.png", "imgs/20191017185634484.png", "imgs/icon.jpg", "imgs/IMG_2229.JPG", "imgs/IMG_2994.JPG" ], output_path="output.png", layout=(4, 2), each_image_shape=(0, 0) ) 图像检索 ~~~~~~~~~~~ 自动编码机:: nearest_images = dkimageapp.core.retrieval_images_by_autoencoder( fit_images_path=[ "imgs/20191017185607410.png", "imgs/20191017185634484.png", "imgs/icon.jpg", "imgs/IMG_2229.JPG", "imgs/IMG_2994.JPG" ], target_images_path=["122.JPG", "017.JPG"], scale=28, epochs=15, batch_size=32, n_neigh=5, shuffle=True ) print(nearest_images) """ >>> { ... "122.JPG": [ ... (1.0, "data/124.JPG"), ... (0.021841750088447576, "data/535.JPG"), ... (0.013354248283854897, "data/605.JPG"), ... (0.009994627751588991, "data/402.JPG"), ... (0.0, "data/134.JPG") ... ], ... "017.JPG": [ ... (0.11133096949872578, "data/510.JPG"), ... (0.03817764172216209, "data/471.JPG"), ... (0.02644454978659949, "data/IMG_2044.JPG"), ... (0.001042320143904596, "data/130.JPG"), ... (0.0, "data/472.JPG") ... ] >>> } """ 资源 ------ 制作微信国旗头像,别再@微信官方 自动编码器(卷积神经网络CNN)构建一个简单的图像检索系统: * https://github.com/nathanhubens/Unsupervised-Image-Retrieval * https://towardsdatascience.com/build-a-simple-image-retrieval-system-with-an-autoencoder-673a262b7921 Credits ------- This package was created with Cookiecutter_ and the `audreyr/cookiecutter-pypackage`_ project template. .. _Cookiecutter: https://github.com/audreyr/cookiecutter .. _`audreyr/cookiecutter-pypackage`: https://github.com/audreyr/cookiecutter-pypackage