##################################################################### # 获得图像矩阵 if __name__ == "__main__": # img = imread('/home/qiujiayu/图片/10_lena.jpg') csvfile = file('/home/qiujiayu/文档/3_lena.csv', 'rb') img = [] for line in csvfile: img.append(line.split(',')) img = [[float(y) for y in x]for x in img] img = np.array(img) noise_img = sp_noise(img, 0.05) # raw_input("================================") img_matlab = imread('/home/qiujiayu/图片/untitled.jpg') # 将图像矩阵归一化 # img_normalized = np.array([[[float(rgb/255.0) for rgb in y_axis] for y_axis in x_axis] for x_axis in img]) # img_nor = np.array([[float(axis/255.0) for axis in line]for line in img]) p=Pcnn_class() img_out = p.PCNN(img_arr=img, iteration_num=30) # img_out = img_out * 255.0 # print img_out # raw_input("===========================================") print "done!"
import cv2 import noise import skfuzzy as fuzz image = cv2.imread('lena.jpg') gray_image = cv2.cvtColor(image, cv2.COLOR_BGR2GRAY) noise_image = noise.sp_noise(gray_image,0.02) cv2.imwrite('noiseimg.png',noise_image) fuzz_image = fuzz.filters.fire2d(noise_image, 0, 260,1) cv2.imwrite('fireimg.png',fuzz_image)
resize = random.uniform(0.999, 1) dw = np.random.randint(-300, 300) dh = np.random.randint(-300, 300) img, boxs = rotate(os.path.join(path, name), os.path.join(path, name[:-4] + '.txt'), r=r, save_name=os.path.join('save', name), resize=resize, dw=dw, dh=dh) if random.random() > 0.8: img = gasuss_noise(img, random.uniform(0, 0.05), random.uniform(0, 0.05)) if random.random() > 0.8: img = sp_noise( img, random.uniform(0, 0.05), ) if random.random() > 0.8: num = np.random.randint(3, 5) img = cv2.blur(img, (num, num)) # if random.random() > 0.8: # contrast = random.randint(50, 100) # 对比度 # brightness = random.randint(50, 100) # 亮度 # img = cv2.addWeighted(img, contrast, img, 0, brightness) cv2.imwrite( os.path.join( output, name[:-4] + '_noise_blur_' + str(_).zfill(5) + '.jpg'), img) # 判断异常的bbox boxs = np.array(boxs).reshape(-1, 2) shape = [img.shape[1], img.shape[0]]
import cv2 import noise import skfuzzy as fuzz image = cv2.imread('lena.jpg') gray_image = cv2.cvtColor(image, cv2.COLOR_BGR2GRAY) noise_image = noise.sp_noise(gray_image, 0.02) cv2.imwrite('noiseimg.png', noise_image) fuzz_image = fuzz.filters.fire2d(noise_image, 0, 260, 1) cv2.imwrite('fireimg.png', fuzz_image)
import cv2 import noise import scipy.ndimage image = cv2.imread('lena.jpg') noise_image = noise.sp_noise(image,0.02) cv2.imwrite('noiseimg.png',noise_image) gauss_image = scipy.ndimage.filters.gaussian_filter(noise_image, sigma=2, order=0, output=None, mode='reflect', cval=0.0) cv2.imwrite('gaussimg.png',gauss_image)