日韩性视频-久久久蜜桃-www中文字幕-在线中文字幕av-亚洲欧美一区二区三区四区-撸久久-香蕉视频一区-久久无码精品丰满人妻-国产高潮av-激情福利社-日韩av网址大全-国产精品久久999-日本五十路在线-性欧美在线-久久99精品波多结衣一区-男女午夜免费视频-黑人极品ⅴideos精品欧美棵-人人妻人人澡人人爽精品欧美一区-日韩一区在线看-欧美a级在线免费观看

歡迎訪問 生活随笔!

生活随笔

當前位置: 首頁 > 编程语言 > python >内容正文

python

第5章 Python 数字图像处理(DIP) - 图像复原与重建7 - 周期噪声 余弦噪声生成方法

發布時間:2023/12/10 python 21 豆豆
生活随笔 收集整理的這篇文章主要介紹了 第5章 Python 数字图像处理(DIP) - 图像复原与重建7 - 周期噪声 余弦噪声生成方法 小編覺得挺不錯的,現在分享給大家,幫大家做個參考.

標題

      • 周期噪聲

周期噪聲

周期噪聲通常是在獲取圖像期間由電氣或機電干擾產生的

def add_sin_noise(img, scale=1, angle=0):"""add sin noise for imageparam: img: input image, 1 channel, dtype=uint8param: scale: sin scaler, smaller than 1, will enlarge, bigger than 1 will shrinkparam: angle: angle of the rotationreturn: output_img: output image is [0, 1] image which you could use as mask or any you want to"""height, width = img.shape[:2] # original image shape# convert all the angleif int(angle / 90) % 2 == 0:rotate_angle = angle % 90else:rotate_angle = 90 - (angle % 90)rotate_radian = np.radians(rotate_angle) # convert angle to radian# get new image height and widthnew_height = int(np.ceil(height * np.cos(rotate_radian) + width * np.sin(rotate_radian)))new_width = int(np.ceil(width * np.cos(rotate_radian) + height * np.sin(rotate_radian))) # if new height or new width less than orginal height or width, the output image will be not the same shape as input, here set it rightif new_height < height:new_height = heightif new_width < width:new_width = width# meshgridu = np.arange(new_width)v = np.arange(new_height)u, v = np.meshgrid(u, v)# get sin noise image, you could use scale to make some difference, better you could add some shift # noise = abs(np.sin(u * scale))noise = 1 - np.sin(u * scale)# here use opencv to get rotation, better write yourself rotation functionC1 = cv2.getRotationMatrix2D((new_width/2.0, new_height/2.0), angle, 1)new_img = cv2.warpAffine(noise, C1, (int(new_width), int(new_height)), borderValue=0)# ouput image should be the same shape as input, so caculate the offset the output image and the new image# I make new image bigger so that it will cover all output imageoffset_height = abs(new_height - height) // 2offset_width = abs(new_width - width) // 2img_dst = new_img[offset_height:offset_height + height, offset_width:offset_width+width]output_img = normalize(img_dst)return output_img def spectrum_fft(fft):"""return FFT spectrum"""return np.sqrt(np.power(fft.real, 2) + np.power(fft.imag, 2)) # 周期噪聲 img_ori = cv2.imread('DIP_Figures/DIP3E_Original_Images_CH05/Fig0507(a)(ckt-board-orig).tif', 0) #直接讀為灰度圖像# 正弦噪聲 noise = add_sin_noise(img_ori, scale=0.35, angle=-20) img = np.array(img_ori / 255, np.float32) img_noise = img + noise img_noise = np.uint8(normalize(img_noise)*255)# 頻率域中的其他特性 # FFT img_fft = np.fft.fft2(img_noise.astype(np.float32)) # 中心化 fshift = np.fft.fftshift(img_fft) # 將變換的頻率圖像四角移動到中心 # 中心化后的頻譜 spectrum_fshift = spectrum_fft(fshift) spectrum_fshift_n = np.uint8(normalize(spectrum_fshift) * 255)# 對頻譜做對數變換 spectrum_log = np.log(1 + spectrum_fshift)plt.figure(figsize=(15, 10)) plt.subplot(121), plt.imshow(img_noise, 'gray'), plt.title('With Sine noise'), plt.xticks([]),plt.yticks([]) plt.subplot(122), plt.imshow(spectrum_log, 'gray'), plt.title('Spectrum'), plt.xticks([]),plt.yticks([]) # 在圖像上加上箭頭 plt.arrow(180, 180, 25, 30, width=5,length_includes_head=True, shape='full') plt.arrow(285, 265, -25, -30, width=5,length_includes_head=True, shape='full') plt.tight_layout() plt.show()

總結

以上是生活随笔為你收集整理的第5章 Python 数字图像处理(DIP) - 图像复原与重建7 - 周期噪声 余弦噪声生成方法的全部內容,希望文章能夠幫你解決所遇到的問題。

如果覺得生活随笔網站內容還不錯,歡迎將生活随笔推薦給好友。

主站蜘蛛池模板: 午夜国产 | 日本在线播放视频 | 国产专区欧美专区 | 国产另类精品 | 美女屁股眼视频免费 | 亚洲素人在线 | 中文字幕av播放 | 国产午夜在线 | av在线一区二区三区 | 亚洲 欧美 国产 另类 | 自拍偷拍21p| 特高潮videossexhd | 天天综合网天天综合色 | 国产一区二区成人 | 91在线观看欧美日韩 | 二区三区在线视频 | 国产综合日韩 | 亚洲天堂欧美 | 91精品国产色综合久久不卡98 | 亚洲日本香蕉视频 | 少妇一级淫片免费 | 五月婷婷社区 | 成人第四色 | 国产精品久久久久久久久免费桃花 | 老司机精品视频在线播放 | 国产在线国偷精品免费看 | 中国少妇乱子伦视频播放 | 国产黄片毛片 | 中文字幕天堂网 | 69av片 | 亚洲日本va中文字幕 | 日韩精品在线免费观看视频 | 久久99精品久久久水蜜桃 | 亚洲一线二线在线观看 | 日本三级小视频 | 男女激情网址 | 少妇69xx | 天天操狠狠操 | 狠狠干b | 欧美一级淫片免费视频魅影视频 | 日本一级片在线播放 | 40到50岁中老年妇女毛片 | 欧美日日夜夜 | 色香蕉在线 | 久久影视网 | 欧美成人久久久免费播放 | 久久精品网址 | 狠狠干男人的天堂 | 真实人妻互换毛片视频 | 国产精品日韩在线观看 | 国产美女福利在线 | 在线观看免费人成视频 | 亚洲精品中文字幕乱码三区 | 九九在线观看免费高清版 | 自拍视频一区 | 国产69久久精品成人看 | 中文字幕97 | wwwxxx色| 嫩草影院在线视频 | 国产最新av| 国产精品11 | www色网站 | 日本精品一区二区三区在线观看 | 成人国产精品入口免费视频 | 黄色网址在线看 | 久色电影 | 不卡的一区二区 | 欧美丝袜脚交 | 91九色视频在线 | 亚洲午夜无码久久久久 | 亚洲一区在线播放 | 欧美午夜免费 | 亚洲av永久中文无码精品综合 | 色狠av | av网站网址 | 日韩综合在线观看 | 色大师在线观看 | 国产成人三级在线观看视频 | 琪琪色综合 | 日韩精品在线视频免费观看 | 色老太hd老太色hd | 亚洲国产欧美日韩在线 | 色多多污污 | 国产一二三区av | 五月婷婷激情小说 | 玖玖视频国产 | 久久网av | 亚洲欧美va天堂人熟伦 | 天堂在线中文在线 | 超碰自拍| 欧美第一页在线 | 亚州精品国产精品乱码不99按摩 | 黄黄的网站 | www.三级 | 亚洲综合激情五月久久 | 五月天看片| 久久国产激情 | 国产人妻人伦精品1国产 | 亚洲欧美一区二区三区四区五区 |