chasank/Image-Rectification のインストールと画像補正の実行(画像補正)(Python を使用)(Windows 上)

chasank/Image-Rectification をインストールし, 画像補正を行う.

画像補正

画像補正は,画像を射影変換することにより,斜め方向からの撮影画像を正面画像に変換する. 意図しないカメラ回転(ロール、ピッチ、ヨー)を含む画像を正面画像に補正できる.

また,AIの事前学習は,通常,正面画像で行われることが多く,画像補正を使うことで,AIの推論をより精度よく行うことができると期待できる.

文献

Chaudhury, Krishnendu, Stephen DiVerdi, and Sergey Ioffe. "Auto-rectification of user photos." 2014 IEEE International Conference on Image Processing (ICIP). IEEE, 2014.

資料PDFファイル, パワーポイントファイル

サイト内の関連ページ

関連する外部ページ

GitHub のページ: https://github.com/chsasank/Image-Rectification

1. Google Colab へのリンク

Google Colaboratory のページ:

次のリンクをクリックすると,Google Colaboratoryノートブックが開く. そして,Google アカウントでログインすると,Google Colaboratory のノートブック内のコード等を編集したり再実行したりができる.編集した場合でも,他の人に影響が出たりということはない.そして,編集後のものを,各自の Google ドライブ内に保存することもできる.

https://colab.research.google.com/drive/11VNfE_9fEZ3IDAh-jSwVkrRVE6ZGJ4iM?usp=sharing

2. 前準備

Python 3.10,Git のインストール(Windows 上)

Pythonは,プログラミング言語の1つ. Gitは,分散型のバージョン管理システム.

手順

  1. Windows で,コマンドプロンプト管理者権限で起動する(例:Windowsキーを押し,「cmd」と入力し,「管理者として実行」を選択)

    次のコマンドを実行

    次のコマンドは,Python ランチャーとPython 3.10とGitをインストールし,Gitパスを通すものである.

    次のコマンドでインストールされるGitは 「git for Windows」と呼ばれるものであり, Git,MinGW などから構成されている.

    winget install --scope machine Python.Launcher
    winget install --scope machine Python.Python.3.10
    winget install --scope machine Git.Git
    powershell -command "$oldpath = [System.Environment]::GetEnvironmentVariable(\"Path\", \"Machine\"); $oldpath += \";c:\Program Files\Git\cmd\"; [System.Environment]::SetEnvironmentVariable(\"Path\", $oldpath, \"Machine\")"
    

関連する外部ページ

サイト内の関連ページ

関連項目Python, Git バージョン管理システム, Git の利用

3. chasank/Image-Rectification のインストール

  1. Windows で,コマンドプロンプト管理者権限で起動する(例:Windowsキーを押し,「cmd」と入力し,「管理者として実行」を選択)
  2. pip更新と,chasank/Image-Rectification のインストール

    *python -m pip install ...」は,Python パッケージをインストールするためのコマンド.

    python -m pip install -U --ignore-installed pip
    cd /d c:%HOMEPATH%
    rmdir /s /q Image-Rectification
    git clone --recursive https://github.com/chsasank/Image-Rectification
    
  3. 同封の画像ファイル shelf.jpg を使って実行してみる.

    次のコマンドを実行

    cd /d c:%HOMEPATH%
    cd Image-Rectification
    del results\shelf_warped.png
    python rectification.py results\shelf.jpg
    
  4. 実行の結果,result\shelf_warped.png ができる.

    results\shelf.jpg と result\shelf_warped.png