- 博客(30)
- 收藏
- 关注
原创 White Patch(maxRGB)白平衡算法python实现
改进的white patch方法求原始图像每个通道的累计直方图,取累计到某一个值 p*n 时对应的图像像素值作为其中p为百分值,实验中取为1%-5%,n为图像的像素点数。import numpy as npimport cv2image = cv2.imread('1.jpeg')top = image.shape[0]*image.shape[1]*0.01b,g,r = cv2.split(image)rgbmax = [0,0,0]for i in range(image.sha
2021-11-15 20:21:00
4342
4
原创 Gray World白平衡算法python实现
import numpy as npimport cv2image = cv2.imread('1.jpeg')b,g,r = cv2.split(image)b_avg = cv2.mean(b)[0]g_avg = cv2.mean(g)[0]r_avg = cv2.mean(r)[0]avg = (b_avg+g_avg+r_avg)/3b_k = avg/b_avgg_k = avg/g_avgr_k = avg/r_avgb = (b*b_k).clip(0,255.
2021-11-15 16:59:26
3367
1
原创 图像匹配 欧氏距离 直方图匹配 python
基于两幅图像间欧氏距离和直方图匹配的图像匹配python# 创建GUI窗口打开图像 并显示在窗口中import tkinter as tk # 导入GUI界面函数库from tkinter import *import tkinter.filedialogfrom PIL import Image, ImageTk # 导入图像处理函数库from os import listdirimport numpy as npimport cv2path = r'C:/U
2020-05-09 11:05:20
1459
2
原创 PIL中的Image和numpy中的数组array相互转换
1. PIL image转换成array img = np.asarray(image)需要注意的是,如果出现read-only错误,并不是转换的错误,一般是你读取的图片的时候,默认选择的是"r","rb"模式有关。修正的办法: 手动修改图片的读取状态 img.flags.writeable = True # 将数组改为读写模式2. array转换成ima...
2020-03-16 12:57:29
430
原创 批量随机gamma
from PIL import Image as PImagefrom os import listdirimport numpy as npimport randomimport cv2#Load images in filefolderdef loadImages(path): imagesList = listdir(path) loadedImages = ...
2020-03-08 15:28:19
297
原创 服务器
mkdir foldername : 创建名为filename的文件夹touch filename.py : 创建名为filename的python文件rm filename.py : 删除名为filename的python文件删除文件:rmdir1、可使用rmdir命令删除一个目录。必须离开目录,并且目录必须为空目录,不然提示删除失败。2、当...
2020-02-28 12:56:30
162
原创 anaconda+pycharm+tensorflow
SublimeText的代码补齐不友好(是我太菜),转战PyCharmimport tensorflow as tf提示无tensorflow这个moudle解决方法:File->Setting->Project : <项目名> -> Project Interpreter ->Project Interpreter 复选框 ->Show A...
2020-02-23 16:04:35
229
原创 图像匹配
在图像超分辨率任务中,要计算test result与原图的psnr等,需要result和原图按按顺序一一对应,即在原图文件夹中与在RESULT文件夹中,两幅图的名称相同。但经过神经网络得到的test resullt的图片顺序比较随机,因此需要对其重新排序命名。该程序效果是把source_path中的图重命名为与result_path中的相同,并将其转移到trans_path中。使用的图像匹配算...
2020-01-11 17:42:42
380
原创 根据图像尺寸移动文件
#-*- coding:utf-8 -*-from PIL import Imageimport osimport shutilsource_path=r"/home/song/桌面/newtest/origin"long_path=r"/home/song/桌面/newtest/long"thin_path=r"/home/song/桌面/newtest/thin"files ...
2020-01-10 22:56:28
195
原创 双系统ubuntu挂载硬盘
windows10 + ubuntu16.04双系统3T机械硬盘,1T分给windows,2T给ubuntu在windows系统中创建“压缩卷”并“新建简单卷”,之后在ubuntu系统的磁盘管理中中将该新建卷格式化即可。效果:在windows系统“我的电脑”中不会出现分给ubuntu系统的盘符,可以避免在windows系统中误删分配给ubuntu系统的硬盘存储内容。PS:挂载失败,...
2020-01-10 01:29:13
720
原创 git
初始化一个 Git 仓库,使用git init 命令。添加文件到 Git 仓库,分两步:· 第一步,使用命令git add将文件从工作区添加到暂存区,可反复多次使用,添加多个文件;· 第二步,使用命令git commit, 完成。$ git add README.md$ git commit -m "add a README file"$ git status$ git ...
2019-12-28 22:26:15
139
原创 ubuntu常用命令
耳机pavucontrol========================================================================依赖sudo apt-get -f install========================================================================查看显卡占用watch -...
2019-12-10 17:38:19
134
原创 mse+psnr+ssim 批量
from skimage.measure import compare_ssim, compare_mse, compare_psnrimport cv2import osimport numpy as npcnt=0HD_path=r"C:\Users\Song\Desktop\test\HD"LC_path=r"C:\Users\Song\Desktop\test\LC"HD...
2019-12-10 13:32:58
725
原创 批量psnr
import osimport cv2import numpy as npimport mathdef _psnr(img1, img2): mse = np.mean( (img1/255. - img2/255.) ** 2 ) if mse < 1.0e-10: return 100 PIXEL_MAX = 1 return 20 * m...
2019-12-09 23:36:22
531
原创 批量放缩(下采样)
(1) 等比例放缩from PIL import Imageimport osscale = 1.0/3cnt=1source_path=r"C:\Users\HD"result_path=r"C:\Users\tresult"files = os.listdir(source_path)files.sort(key=lambda x: int(x.split('.')[0]...
2019-12-02 23:35:26
354
原创 批量修改图像gamma值
import cv2import osimport numpy as npdef adjust_gamma(image, gamma=1.0): invGamma = 1.0/gamma table = [] for i in range(256): table.append(((i / 255.0) ** invGamma) * 255) ...
2019-12-02 21:05:20
1175
原创 测试tensorflow是否用Gpu加速
方法一:import tensorflow.compat.v1 as tftf.disable_v2_behavior()a = tf.constant([1.0, 2.0, 3.0, 4.0, 5.0, 6.0], shape=[2, 3], name='a')b = tf.constant([1.0, 2.0, 3.0, 4.0, 5.0, 6.0], shape=[3, 2], ...
2019-12-01 20:35:04
2722
原创 win10 caffe-cpu安装
网上教程看了一堆,神仙打架,cmake,vs,matlab,anaconda巴拉巴拉一大堆。最后使用的方法如下:安装对应python3.5版本的anaconda打开caffe-windows官网地址:https://github.com/BVLC/caffe/tree/windows下载对应版本的caffe版本下载后将caffe/python/caffe文件夹复制到anacon...
2019-11-30 21:17:23
610
原创 检测tf是否使用GPU
测试tensorflow是否使用GPUimport tensorflow as tfversion = tf.__version__gpu_ok = tf.test.is_gpu_available()print("tf version:",version,"\nuse GPU",gpu_ok)========================================...
2019-11-26 21:13:36
1767
转载 提取pdf中的图片 python
转载自https://blog.youkuaiyun.com/qq_15969343/article/details/81673302import fitzimport timeimport reimport osdef pdf2pic(path, pic_path): ''' # 从pdf中提取图片 :param path: pdf的路径 :param pic...
2018-08-21 21:28:06
2950
1
原创 python + opencv提取图片中的人脸
机器学习需要大量的数据,从多渠道获得原始数据后,需要将图片中的人脸提取出来做训练集。代码如下#-*-coding:utf8-*-import osimport cv2import timeimport shutil def getAllPath(dirpath, *suffix): PathArray = [] for r, ds, fs in os.walk...
2018-08-15 09:47:51
9041
原创 python中的路径
1.r"D:\example\test.txt"2."D:\\example\\test.txt"3."D:/example/test.txt"
2018-08-09 10:30:07
199
原创 爬虫:根据关键词爬取图片
因为要训练神经网络,需要很大的数据集,使用爬虫从网上爬取了上万张图片。此程序参考了爬虫怎么根据一个关键词爬取上千张网络图片,代码如下#-*- coding:utf-8 -*-import reimport requestsimport tracebackimport os def dowmloadPic(html,keyword,startNum): kv =...
2018-08-04 11:28:48
2469
原创 leetcode回文数isPalindrome
首先想到的是将数字转换成字符串,再比较字符串是否相同的方法。class Solution: def isPalindrome(self, x): """ :type x: int :rtype: bool """ array = str(x) transArray = a...
2018-07-23 13:08:53
511
原创 leetcode两数之和python
在编写leecode上的算法第一题“两数之和”时,遇到了一些问题,如下:1.参数丢失>>>Solution.twosum([2,3,4,5],8)TypeError: twosum() missing 1 required positional argument: 'target'原因:没有创建对象解决:>>>a = Solution()...
2018-07-22 18:36:05
672
空空如也
空空如也
TA创建的收藏夹 TA关注的收藏夹
TA关注的人
RSS订阅