Chris Huang
    • Create new note
    • Create a note from template
      • Sharing URL Link copied
      • /edit
      • View mode
        • Edit mode
        • View mode
        • Book mode
        • Slide mode
        Edit mode View mode Book mode Slide mode
      • Customize slides
      • Note Permission
      • Read
        • Only me
        • Signed-in users
        • Everyone
        Only me Signed-in users Everyone
      • Write
        • Only me
        • Signed-in users
        • Everyone
        Only me Signed-in users Everyone
      • Engagement control Commenting, Suggest edit, Emoji Reply
      • Invitee
    • Publish Note

      Share your work with the world Congratulations! 🎉 Your note is out in the world Publish Note

      Your note will be visible on your profile and discoverable by anyone.
      Your note is now live.
      This note is visible on your profile and discoverable online.
      Everyone on the web can find and read all notes of this public team.
      See published notes
      Unpublish note
      Please check the box to agree to the Community Guidelines.
      View profile
    • Commenting
      Permission
      Disabled Forbidden Owners Signed-in users Everyone
    • Enable
    • Permission
      • Forbidden
      • Owners
      • Signed-in users
      • Everyone
    • Suggest edit
      Permission
      Disabled Forbidden Owners Signed-in users Everyone
    • Enable
    • Permission
      • Forbidden
      • Owners
      • Signed-in users
    • Emoji Reply
    • Enable
    • Versions and GitHub Sync
    • Note settings
    • Engagement control
    • Transfer ownership
    • Delete this note
    • Save as template
    • Insert from template
    • Import from
      • Dropbox
      • Google Drive
      • Gist
      • Clipboard
    • Export to
      • Dropbox
      • Google Drive
      • Gist
    • Download
      • Markdown
      • HTML
      • Raw HTML
Menu Note settings Sharing URL Create Help
Create Create new note Create a note from template
Menu
Options
Versions and GitHub Sync Engagement control Transfer ownership Delete this note
Import from
Dropbox Google Drive Gist Clipboard
Export to
Dropbox Google Drive Gist
Download
Markdown HTML Raw HTML
Back
Sharing URL Link copied
/edit
View mode
  • Edit mode
  • View mode
  • Book mode
  • Slide mode
Edit mode View mode Book mode Slide mode
Customize slides
Note Permission
Read
Only me
  • Only me
  • Signed-in users
  • Everyone
Only me Signed-in users Everyone
Write
Only me
  • Only me
  • Signed-in users
  • Everyone
Only me Signed-in users Everyone
Engagement control Commenting, Suggest edit, Emoji Reply
Invitee
Publish Note

Share your work with the world Congratulations! 🎉 Your note is out in the world Publish Note

Your note will be visible on your profile and discoverable by anyone.
Your note is now live.
This note is visible on your profile and discoverable online.
Everyone on the web can find and read all notes of this public team.
See published notes
Unpublish note
Please check the box to agree to the Community Guidelines.
View profile
Engagement control
Commenting
Permission
Disabled Forbidden Owners Signed-in users Everyone
Enable
Permission
  • Forbidden
  • Owners
  • Signed-in users
  • Everyone
Suggest edit
Permission
Disabled Forbidden Owners Signed-in users Everyone
Enable
Permission
  • Forbidden
  • Owners
  • Signed-in users
Emoji Reply
Enable
Import from Dropbox Google Drive Gist Clipboard
   owned this note    owned this note      
Published Linked with GitHub
Subscribed
  • Any changes
    Be notified of any changes
  • Mention me
    Be notified of mention me
  • Unsubscribe
Subscribe
# 前言 目前在電腦視覺中大多應用都是使用深度學習,但我認為對於一個研究電腦視覺領域的人來說,且現在許多科技廠仍會使用此技術進行檢測,所以傳統影像處理技還是非常重要的。 雖然在大學和碩士期間也會用影像處理技術對影像做處理,但也只是非常簡單的處理,如二值化、灰階、旋轉等。不過,除了這些,影像處理還有非常多的技術可以學,因此從這篇是我學好影像處理和打好基礎的第一篇。 這是我的學習紀錄,所有範例都是跟著[數位影像處理](https://www.books.com.tw/products/0010923809)這本書的教學及查詢網路上的資料,並使用我自己的方法整理,以及加上自己的看法。 ## 影像形成模型(3-4) **定義**: ```f(x,y)=i(x,y)・r(x,y)```,其中i(x,y)為打光函數、r(x,y)反射函數 生活中有許多光源,而影像形成模型是用來模擬這些生活中常見的光源。光源主要可分成兩種: - 環境光源:光線四面八方投射,形成均勻的照明,如太陽、市內照明 - 點光源:光線投射集中在特定局部區域,如檯燈等 反射函數的數值介於```0<r(x,y)<1```,0代表光線被物件完全吸收;1代表光線被物件表面反射。 **範例** 模擬點光源照明後所形成的影像,使用高斯函數進行點光源的模擬,其中```(x0,y0)```為平均值,用來控制打光的中心點;```sigma```為標準差,控制打光的範圍(半徑)。 ```python= def ImageFormationModel(img, x0, y0, sigma): img_copy = img.copy() nr, nc = img_copy.shape[:2] illumination = np.zeros([nr, nc], dtype='float32') # 打光函數 for x in range(nr): for y in range(nc): illumination[x, y] = np.exp(-(((x-x0)**2+(y-y0)**2)/(2*sigma**2))) for c in range(img.shape[2]): for x in range(nr): for y in range(nc): val = illumination[x, y]*img[x,y,c] img_copy[x,y,c] = val return img_copy ``` 結果如下圖所示 ![](https://hackmd.io/_uploads/H1WQDED1T.png) <br> [Source Code Please Visit](https://github.com/ChrisCodeNation/Digital-Image-Processing/blob/main/3-4%20影像形成模型.ipynb) ## 影像的取樣(3-5-1) 影像取樣的概念有點類似Pooling,只是不是取最大值或平均值,而是依照取樣率(Sampling rate)作為取樣的間隔擷取像素值。取樣的間隔越大,影像畫素越少,解析度越低;間隔越小,畫素越多,解析度越高。 ```python= def Down_sampling(img, sampling_rate): nr, nc = img.shape[:2] # 取樣後的大小 nr_s, nc_s = nr//sampling_rate, nc//sampling_rate # 取樣後的影像 result = np.zeros((nr_s, nc_s)) for x in range(nr_s): for y in range(nc_s): result[x,y] = img[x*sampling_rate, y*sampling_rate] return result ``` 結果如下圖所示 ![lenna](https://hackmd.io/_uploads/H1ty8Vvyp.png) <br> [Source Code Please Visit](https://github.com/ChrisCodeNation/Digital-Image-Processing/blob/main/3-5-1%20取樣.ipynb) ## 影像的量化(3-5-2) 量化(Quantization)的概念就是將影像像素點的區間轉換成單個特定值的過程。以灰階影像來說,通常為8bits,灰階數有256種;而使用5bits量化時,只會有32種灰階;使用1bit量化時,只會有2種灰階,也就是0或255。 ```python= def quantization(img, bits): new_img = img.copy() nr, nc = img.shape[:2] # 幾種灰階 eg. 2bits有4種灰階 level = 2**bits # 灰階的間隔範圍 256/4= 64, 0-64;64-128;128-192;192-256 interval = 256/bits gray_level_interval = 255/(level-1) # look up table table = np.zeros(256, np.uint8) # 建立look up table for k in range(256): for l in range(level): if k >= l*interval and k < (l+1)*interval: table[k] = round(l*gray_level_interval) # 查表 for x in range(nr): for y in range(nc): new_img[x,y] = table[img[x,y]] return new_img ``` 上面的概念是先建立一個lookup table,根據每個位置決定是哪一種灰階值。接著就能根據原始影像的(x,y)位置的像素值去查表,並找到對應的灰階值。 結果下圖所示 ![quantization](https://hackmd.io/_uploads/Hy2h64Dy6.png) <br> [Source Code Please Visit](https://github.com/ChrisCodeNation/Digital-Image-Processing/blob/main/3-5-2%20量化.ipynb)

Import from clipboard

Paste your markdown or webpage here...

Advanced permission required

Your current role can only read. Ask the system administrator to acquire write and comment permission.

This team is disabled

Sorry, this team is disabled. You can't edit this note.

This note is locked

Sorry, only owner can edit this note.

Reach the limit

Sorry, you've reached the max length this note can be.
Please reduce the content or divide it to more notes, thank you!

Import from Gist

Import from Snippet

or

Export to Snippet

Are you sure?

Do you really want to delete this note?
All users will lose their connection.

Create a note from template

Create a note from template

Oops...
This template has been removed or transferred.
Upgrade
All
  • All
  • Team
No template.

Create a template

Upgrade

Delete template

Do you really want to delete this template?
Turn this template into a regular note and keep its content, versions, and comments.

This page need refresh

You have an incompatible client version.
Refresh to update.
New version available!
See releases notes here
Refresh to enjoy new features.
Your user state has changed.
Refresh to load new user state.

Sign in

Forgot password

or

By clicking below, you agree to our terms of service.

Sign in via Facebook Sign in via Twitter Sign in via GitHub Sign in via Dropbox Sign in with Wallet
Wallet ( )
Connect another wallet

New to HackMD? Sign up

Help

  • English
  • 中文
  • Français
  • Deutsch
  • 日本語
  • Español
  • Català
  • Ελληνικά
  • Português
  • italiano
  • Türkçe
  • Русский
  • Nederlands
  • hrvatski jezik
  • język polski
  • Українська
  • हिन्दी
  • svenska
  • Esperanto
  • dansk

Documents

Help & Tutorial

How to use Book mode

Slide Example

API Docs

Edit in VSCode

Install browser extension

Contacts

Feedback

Discord

Send us email

Resources

Releases

Pricing

Blog

Policy

Terms

Privacy

Cheatsheet

Syntax Example Reference
# Header Header 基本排版
- Unordered List
  • Unordered List
1. Ordered List
  1. Ordered List
- [ ] Todo List
  • Todo List
> Blockquote
Blockquote
**Bold font** Bold font
*Italics font* Italics font
~~Strikethrough~~ Strikethrough
19^th^ 19th
H~2~O H2O
++Inserted text++ Inserted text
==Marked text== Marked text
[link text](https:// "title") Link
![image alt](https:// "title") Image
`Code` Code 在筆記中貼入程式碼
```javascript
var i = 0;
```
var i = 0;
:smile: :smile: Emoji list
{%youtube youtube_id %} Externals
$L^aT_eX$ LaTeX
:::info
This is a alert area.
:::

This is a alert area.

Versions and GitHub Sync
Get Full History Access

  • Edit version name
  • Delete

revision author avatar     named on  

More Less

Note content is identical to the latest version.
Compare
    Choose a version
    No search result
    Version not found
Sign in to link this note to GitHub
Learn more
This note is not linked with GitHub
 

Feedback

Submission failed, please try again

Thanks for your support.

On a scale of 0-10, how likely is it that you would recommend HackMD to your friends, family or business associates?

Please give us some advice and help us improve HackMD.

 

Thanks for your feedback

Remove version name

Do you want to remove this version name and description?

Transfer ownership

Transfer to
    Warning: is a public team. If you transfer note to this team, everyone on the web can find and read this note.

      Link with GitHub

      Please authorize HackMD on GitHub
      • Please sign in to GitHub and install the HackMD app on your GitHub repo.
      • HackMD links with GitHub through a GitHub App. You can choose which repo to install our App.
      Learn more  Sign in to GitHub

      Push the note to GitHub Push to GitHub Pull a file from GitHub

        Authorize again
       

      Choose which file to push to

      Select repo
      Refresh Authorize more repos
      Select branch
      Select file
      Select branch
      Choose version(s) to push
      • Save a new version and push
      • Choose from existing versions
      Include title and tags
      Available push count

      Pull from GitHub

       
      File from GitHub
      File from HackMD

      GitHub Link Settings

      File linked

      Linked by
      File path
      Last synced branch
      Available push count

      Danger Zone

      Unlink
      You will no longer receive notification when GitHub file changes after unlink.

      Syncing

      Push failed

      Push successfully