資源簡介
圖像超分辨率技術源碼;
基于深度學習的圖像超分辨率重建的流程如下[2]:
1.首先找到一組原始圖像Image1;
2.將這組圖片降低分辨率為一組圖像Image2
3.通過各種神經網絡結構,將Image2超分辨率重建為Image3(Image3和Image1分辨率一樣)
4.通過PSNR等方法比較Image1和Image3,驗證超分辨率重建的效果,根據效果調節神經網絡中的節點和參數
5.反復執行以上直到第4步的結果比較滿意
The process of image super-resolution reconstruction based on deep learning is as follows [2]:
1. First find a set of original images image1;
2. Reduce the resolution of this group of pictures to a group of image2
3. Through various neural network structures, the super-resolution of image2 is reconstructed into image3 (the resolution of image3 is the same as that of image1)
4. Compare image1 and image3 by PSNR and other methods to verify the effect of super-resolution reconstruction, and adjust the nodes and parameters of neural network according to the effect
5. Repeat the above until the result of step 4 is satisfactory)
代碼片段和文件信息
import?os
import?sys
import?glob
import?numpy?as?np
from?PIL?import?Image
import?pdb
#?Artifically?expands?the?dataset?by?a?factor?of?19?by?scaling?and?then?rotating?every?image
def?main():
??if?len(sys.argv)?==?2:
????data?=?prepare_data(sys.argv[1])
??else:
????print(“Missing?argument:?You?must?specify?a?folder?with?images?to?expand“)
????return
??for?i?in?xrange(len(data)):
????scale(data[i])
????rotate(data[i])
def?prepare_data(dataset):
??filenames?=?os.listdir(dataset)
??data_dir?=?os.path.join(os.getcwd()?dataset)
??data?=?glob.glob(os.path.join(data_dir?“*.bmp“))
??return?data
def?scale(file):
??image?=?Image.open(file)
??width?height?=?image.size
??scales?=?[0.9?0.8?0.7?0.6]
??for?scale?in?scales:
????new_width?new_height?=?int(width?*?scale)?int(height?*?scale)
????new_image?=?image.resize((new_width?new_height)?Image.ANTIALIAS)
????new_path?=?‘{}-{}.bmp‘.format(file[:-4]?scale)
????new_image.save(new_path)
def?rotate(file):
??image?=?Image.open(file)
??rotations?=?[90?180?270]
??for?rotation?in?rotations:
????new_image?=?image.rotate(rotation?expand=True)
????new_path?=?‘{}-{}.bmp‘.format(file[:-4]?rotation)
????new_image.save(new_path)
if?__name__?==?‘__main__‘:
??main()
??
?屬性????????????大小?????日期????時間???名稱
-----------?---------??----------?-----??----
?????文件???????1228??2019-06-06?13:37??圖像超分辨率\expand_data.py
?????文件???????1763??2019-06-06?13:37??圖像超分辨率\main.py
?????文件???????8973??2019-06-06?13:43??圖像超分辨率\model.py
?????文件???????9726??2019-06-06?13:45??圖像超分辨率\utils.py
?????目錄??????????0??2019-06-06?13:39??圖像超分辨率
-----------?---------??----------?-----??----
????????????????21690????????????????????5
- 上一篇:《Python神經網絡編程》源代碼
- 下一篇:NetAnalyze 建立網絡
評論
共有 條評論