顯示具有 1071530 標籤的文章。 顯示所有文章
顯示具有 1071530 標籤的文章。 顯示所有文章

2021年6月9日 星期三

s1071530 影像處理作業7

 

  • 作業題目:
    • 請撰寫一個程式,利用數學型態學影像處理運算(erode(), dilate()等函式),計算出所附圖像(共三張)每張圖像中圍棋個數。

  • 使用環境:
    • window 10
    • python 3.9
    • numpy 1.18.5
    • opencv-python 4.4.0.46
  • 方法:

1.    Read the image

2.    Convert the image to gray scale picture

3.    Image binarization

4.    Use cv2.getStructuringElement() to get the kernel

5.    Erode the binarization picture

6.    Dilate the eroded picture

7.    Use cv2.findContours() to get how many contours

8.    Use cv2.drawContours() to draw contours on the image

9.    Save the image

 

  • 結果:
img_5702:

原圖



偵測圖片



erode


dilate


img_5703:


原圖


偵測圖片


erode


dilate


img_5704:


原圖


偵測圖片


erode


dilate



3張圖片偵測棋子數:
















2021年6月7日 星期一

s1071530 影像處理作業8

 作業說明:

請寫一個程式將附圖二值化後輸出黑白圖像。目的是將文字與背景分離。

執行結果:

原圖



Otsu

moving average(n=900 b=0.7)




2021年6月6日 星期日

s1071530 影像處理作業6

 一、作業說明 

附件中為三張利用將高度以色彩視覺化後的圖片。

請設計一個基於Run-Length的壓縮法方,對圖檔作無失真壓縮後儲存成新檔案。部落格上應敘述你的壓縮方法,提供壓縮檔之格式,並計算三張圖的平均壓縮率(compression ratio)。


二、作業環境
  • window 10
  • python 3.9
  • opencv-python 4.4.0.46


三、實作方法



因此我先算出共有幾種顏色,並打算把顏色id與rgb值對應

Bin檔我先存入圖片高寬,再來就是共有幾種顏色,顏色id與rgb值對應(假設存入4個數字16 255 0 34 那麼意思是rgb值255 0 34對應的顏色編號是16),再來就是比照上面圖片每一列run length值(不過每一列長度都不同因此前面有那一列的長度值 格式:長度 run length)

 

還原的話就按照上述格式取出資料來還原


四、結果

還原結果

img1.jpg


img2.jpg


img3.jpg




參考資料:https://www.youtube.com/watch?v=ssn7gjgljXQ





2021年5月17日 星期一

s1071530 影像處理作業5

 

  • 作業題目:
    • 附件中的讀.row晶片設計的高度檔案,設計人員無法直接看到相關資訊。利用你所學的Color顏色的知識與處理技術,撰寫一個程式來讀取附件中的讀.row 檔案,將高度資料以圖片(顏色)視覺化呈現出來,讓設計人員可以看到高度相關資訊。

  • 使用環境:
    • window 10
    • python 3.9
    • opencv-python 4.4.0.46
  • 方法 :
    • Step1.  讀入圖片

    • Step2.  將-99999的值改為np.nan

    • Step3.  用np.nanmax and np.nanmin得出最大值跟最小值

    • Step4.  分5個層紅橙黃綠藍

    • Step5.  數值根據層來填顏色BGR分別填
    • Step6.  最後將BGR三個channel合併成新圖片
  • 執行結果:
02.raw


08.raw


10.raw


2021年5月16日 星期日

s1071530 影像處理作業 4

  • 作業題目:
    • 利用你所學的Color顏色的知識與技術,撰寫一個程式來偵測一張輸入照片中的皮膚區域並將其標示出。

  • 使用環境:
    • window 10
    • python 3.9
    • opencv-python 4.4.0.46
  • 方法 :
    • Step1.  讀入圖片

    • Step2.  轉成hsv另存成另一張圖片

    • Step3.  分離channel  BGR HSV

    • Step4.  用R>95 and G>40 and B>20 and MAX(R,G,B)-MIN(R,G,B)>15 and ABS(R-G)>15 and R>G and R>B and 0<=H and H<=20 and S>=48 and V>=50來篩選

    • Step5.  篩選到的把G跟R都改成0
    • Step6.  最後將BGR三個channel合併成新圖片
  • 執行結果:
原圖:


結果:



2021年5月1日 星期六

s1071530 影像處理作業 3

 

  • 作業題目:
    • 請撰寫一個程式,讀取一張 256 色灰階圖像。
    •  (1)計算輸入圖的離散傅立葉轉換結果,並將頻譜大小與相位角度各以灰階 256 色圖像 方式呈現出。 
    • (2)對圖像利用 Gaussian Low-Pass filter 處理,輸出平滑後圖像。(程式利用課本的 frequency filter 步驟者可得滿分!)
  • 使用環境:
    • window 10
    • python 3.9
    • numpy 1.18.5
    • opencv-python 4.4.0.46
  • 方法 :
    • Step1.  Input image f(x,y) of size MxN

    • Step2.  Form a zero-padded image fp (x,y) of size PxQ, where P=2xM, Q=2xN

    • Step3.  Multiply fp (x,y) by (−1)^(x+y) to center its transform

    • Step4.  Compute DFT F(u,v) of the image

    • Step5.  輸出相位跟頻譜

    • Step6.  Generate Gaussian low pass filter in frequency domain and Form the       product G(u,v)=F(u,v)H(u,v)

    • Step7.  Idft Obtain the processed image

    • Step8.  Obtain g(x,y) by extracting the M×N region from the lefttop quadrant of gp          (x,y)

    • Step9.  Save the smoothed image

  • 執行結果:
    • 原圖


    • 灰階


    • 頻譜


    • 相位


    • 截止半徑(D0) = 30


    • D0 = 30 平滑後


    • 截止半徑(D0) = 50


    • D0 = 50 平滑後


    • 截止半徑(D0) = 80


    • D0 = 80 平滑後