上面有4 種 wafer 分別是 1:沒有wafer ,2:正常wafer , 3: 傾斜的 wa...

تم الإنشاء في: ١٤ أكتوبر ٢٠٢٥

تمت الإجابة باستخدام GPT-5 Thinking بواسطة Chat01

سؤال

blue_rect_0002.jpgblue_rect_0002.jpg
blue_rect_0003.jpgblue_rect_0003.jpg
blue_rect_0013.jpgblue_rect_0013.jpg
blue_rect_0014.jpgblue_rect_0014.jpg

上面有4 種 wafer 分別是 1:沒有wafer ,2:正常wafer , 3: 傾斜的 wafer , 4:重疊的 wafer , 請問有什麼辦法可以區分出來?

Python

python
from PIL import Image, ImageOps, ImageFilter import numpy as np, os, json, math, sys, statistics as stats paths=["/mnt/data/blue_rect_0002.jpg","/mnt/data/blue_rect_0003.jpg","/mnt/data/blue_rect_0013.jpg","/mnt/data/blue_rect_0014.jpg"] imgs=[] for p in paths: img=Image.open(p).convert("L") imgs.append(img) print(p, img.size)

Python

python
import numpy as np, math, statistics as stats from PIL import Image def features(img): arr=np.array(img)/255.0 h,w=arr.shape # For each column, find top 2 peaks y_max = arr.argmax(axis=0) max_vals = arr[y_max, np.arange(w)] # Second peaks by masking top region around the first peak second_vals=np.zeros(w) y_second=np.zeros(w,dtype=int) for x in range(w): col=arr[:,x].copy() y1=y_max[x] # mask neighborhood +-2 y0=max(0,y1-2); y2=min(h, y1+3) col[y0:y2]=0 y2p=col.argmax() second_vals[x]=col[y2p] y_second[x]=y2p # linear regression for y_max vs x x=np.arange(w) y=y_max # fit y = a x + b; use least

Python

python
import pprint, json for p,img in zip(paths,imgs): print(p) pprint.pprint(features(img))

الفكرة

Interpreting wafer images features

The features suggest:

  • 0003: Tilted wafer (theta -4 degrees).
  • 0013: Overlapped wafer (double_ratio 0.922).
  • 0014: No wafer (low median column max).
  • 0002: Normal wafer (low double_ratio, near-zero slope).

So, here's the method:

  • Overlapped: double_ratio > 0.6.
  • Tilted: abs(theta) > 2°.
  • No wafer: low column maxima or high std deviation.
  • Normal: no specific features.

Sharing algorithm steps

We can provide algorithm steps and pseudo-code to address the task, following guidelines. Though it's not required to show a table, we can share the code as text for clarity. Here's a brief outline:

  1. Preprocess:
    • Crop region of interest, convert to grayscale, denoise with Gaussian.
  2. Extract "line-of-specular":
    • For each column, identify the y-coordinate of the maximum intensity. Save the top two peaks.

The code will be shared as a helpful reference without execution.

Computing features and thresholds

To classify the images, I’ll compute the following:

  1. Angle of Fitted Line:
    If the angle exceeds the threshold θ, it’s tilted.

  2. Line Strength:
    If median_col_max is below 0.05, it’s considered "no wafer."

  3. Double-Peak Ratio:
    Indicates “overlap” if the second peak is within ±d pixels and the amplitude ratio exceeds r.

  4. Classification Thresholds:
    Based on observed values, I can suggest using an SVM or logistic regression model to suggest one of four classes.

Final classification and explanation

For the task, using a rule-based approach works well enough for classification:

  1. I computed metrics for each image based on features like angle, line strength, and double-peak ratio.

  2. I’ll categorize the images as "tilted," "no wafer," "overlap," or "normal."

  3. I'll provide this information in Chinese, along with thresholds and steps, plus a brief OpenCV code snippet when useful.

Thought for 3m 38s

الإجابة

可以!這種「線掃相機/細長 ROI」的影像,用幾個簡單的幾何/強度特徵就能把
(1) 沒有 wafer、(2) 正常 wafer、(3) 傾斜 wafer、(4) 重疊 wafer 分開。重點思路如下:

方法(無需訓練的規則法)

  1. 前處理
  • 轉灰階、輕微 Gaussian 去噪(避免把噪點當成邊)。
  • ROI 就是可見的亮水平反射線一帶(你的圖高只有 50px,可直接用整高)。
  1. 每一欄找「主峰」與「次峰」
  • 對每一個 column 取強度剖面,找出最亮點 y₁(主峰)與排除 y₁±2px 後的次亮點 y₂(次峰)與各自強度 I₁、I₂。
  • 這一步能同時拿到:亮線的位置序列 {y₁(x)}、及是否存在「兩條平行亮線」的線索(重疊的關鍵)。
  1. 算三個特徵
  • 傾斜角 θ:用最小平方法把 y₁(x) 擬合成直線 y=ax+b,θ=atan(a)。
    • 正常 wafer:|θ| ≈ 0°;傾斜 wafer:|θ| 明顯大於 0。
  • 雙峰率 R₂:在多數欄位同時出現「夠亮的次峰」且 |y₂−y₁| 在小距離內(例如 ≤5px)即記 1,最後取平均。
    • 重疊 wafer:R₂ 高(常 >0.6);正常/無 wafer:R₂ 低。
  • 線強度/存在感 S:用各欄主峰中位數 Med(I₁) 或(I₁ − 該欄中位數)的中位數。
    • 沒有 wafer:S 很低(整幅缺乏明顯水平亮線)。正常/傾斜/重疊:S 高。
  1. 判斷邏輯(可直接落地)
  • S < T₁沒有 wafer
  • 否則若 R₂ > T₂ 且 次峰與主峰強度比 Med(I₂/I₁) > T₃重疊 wafer
  • 否則若 |θ| > T₄傾斜 wafer
  • 其餘 → 正常 wafer

依你這批圖的量級,可先用:
T₁ ≈ 0.05(0–1 正規化後的主峰中位數)、T₂ ≈ 0.6、T₃ ≈ 0.7、T₄ ≈ 2–3°。
(你這四張圖的實測:重疊圖的 R₂ ~0.92、I₂/I₁ ~0.95;傾斜圖的 |θ| ~4°;沒有 wafer 的 S 極低,與其餘三者完全分離。)

20 行就能寫好的參考程式(Python + OpenCV 或純 numpy 都行)

python
import cv2, numpy as np, math def classify(img): g = cv2.GaussianBlur(img, (3,3), 0) h, w = g.shape y1, I1, y2, I2 = [], [], [], [] for x in range(w): col = g[:,x].astype(np.float32) / 255.0 i1 = np.argmax(col); v1 = col[i1] col[max(0,i1-2):min(h,i1+3)] = 0 # 避開主峰,找次峰 i2 = np.argmax(col); v2 = col[i2] y1.append(i1); I1.append(v1); y2.append(i2); I2.append(v2) x = np.arange(w) a = np.cov(x, y1, bias=True)[0,1] / np.var(x) # 線性擬合斜率 theta = math.degrees(math.atan2(a,1)) y1 = np.array(y1); y2 = np.array(y2) I1 = np.array(I1); I2 = np.array(I2) close = (np.abs(y2 - y1) <= 5) & (I2 > 0.6*I1) R2 = close.mean() S = np.median(I1) # 主峰強度代表「有無水平亮線」 if S < 0.05: return "沒有 wafer" if (R2 > 0.6) and (np.median(I2/I1) > 0.7): return "重疊 wafer" if abs(theta) > 3: return "傾斜 wafer" return "正常 wafer"

為什麼有效

  • 傾斜直接反映在亮線的斜率 θ
  • 重疊會產生兩條相距很近且同樣亮的反射線 → 雙峰率/強度比顯著升高。
  • 沒有 wafer時缺少穩定的水平亮線 → 主峰中位強度很低。

實務備註

  • 先在 50–100 張樣本上微調 4 個閾值;用中位數/百分位作門檻會更穩。
  • 光源變動大時,加一步「每欄減去該欄中位數」做自動亮度校正再取峰值。
  • 當畫面偶爾有髒污/亮點,加入最小覆蓋率(例如要求 ≥60% 欄位偵測到主峰)可避免誤判。

這樣做不需要訓練資料、執行快、可直接上線。如果你要,我也可以幫你把這段包成一個小工具,輸入影像就輸出四類的標籤與對應的指標數值。

مشاركة هذا السؤال والجواب