GithubHelp home page GithubHelp logo

image-enhancement's Introduction

Image Enhancement

目的

本次的作業目的就是希望能使影像銳化,在不用函式庫的情況下達到銳化效果。

實作流程

實作

原始圖

將原始圖轉灰階圖

ref1

對(1)做二階微分(Laplacian)

因為Mask是3*3的,所以我們使用getpixel()依序抓取原圖九個pixel值,如下所示:

Pixel[0] Pixel[1] Pixel[2]
Pixel[3] Pixel[4] Pixel[5]
Pixel[6] Pixel[7] Pixel[8]

那Laplacian的Mask如下所示:

-1 -1 -1
-1 8 -1
-1 -1 -1

讓兩者去做運算後把得到的result值回傳

把回傳過來的pixel依序填入Laplacian裡

因為對影像找edges使用Laplacian雖然可以讓edge的寬度=1pixel,但是它同時也讓平坦區的noise放大,所以改用一階微分來找edges。

讓(1)原始圖和(2)Laplacian相加得到影像銳化的圖

使原始圖的每一個pixel和Laplacian_Image的每一個pixel相加,得到影像銳化。

對影像找edges使用Laplacian雖然可以讓edge的寬度=1pixel,但是它同時也讓平坦區的noise放大,所以改用一階微分來找edges。

對(1)原始圖做一階微分(sobel)

雖然一階微分有方向性,但是在影像處理不管方向,所以取絕對值。那Sobel同時要對x,y做處理,所以我們的Mask有兩個:

使原始圖和兩個Mask做運算後取絕對值相加後回傳result值

把回傳的pixel值依序填入Sobel裡,得到下圖

我們可以觀察到使用一階微分找edge真的會讓edge的寬度加大。

讓(4)模糊化

模糊化的Mask如下所示:

使原始圖和Mask做運算後回傳result值

把回傳的result值依序填入Blur裡後得到下圖

對(5)模糊影像作標準化在乘(2)Laplacian

將Blur的每個pixel除上255做標準化再乘Laplacian_img的每個pixel,再依序填入Normal得到下圖:

讓(6)和原始圖(灰階圖)相加得到銳利化效果

ref2

實作結果

原始圖

ref3

經過銳化處理後

ref2

實作心得

這次的作業非常有趣,以往如果要做銳利化肯定是到photoshop去做,現在即使不用opencv的function直接得到銳利效果,也可以一步一步手刻程式碼將效果實作出來,不僅可以真正去理解它是如何實作,

更可以驗證上課所學,例如:使用二階微分去找edge

,雖然寬度只有1pixel但是也真的把平坦區的

Noise同時放大,所以我們更傾向用一階微分去找edge。

image-enhancement's People

Contributors

louis8ok1 avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.