關於我自己

我的相片
累計超過15年的工作經驗,包括10年的設備製造業經驗,超過6年的光電零組件製造業經驗;10年的海外工作經驗,其中至今有5年以上的派駐經驗。 1.專注AOI檢測於10年以上(從光機設計、圖像分析、設備挑選、處理速度) 2.機器學習推論-onnx整合傳統演算法從瑕疵抓取、分析、分類 3.遷移式機器學習模式(工業應用、醫療應用) 4.整合:Python推論引擎、C++運算能力、C#友善介面 彈性使用 5.擅長利用專家模型推進專案,並熟悉使用OpenVINO、TensorRT、ONNXRUNTIME框架進行有效的實作與測試。

2011年10月7日 星期五

邊緣檢測-Prewitt 算子

http://blog.csdn.net/wqvbjhc/article/details/6065497

Prewitt 算子采用以下算子分別計算一階 x 方向和 y 方向的圖像差分:



-101
-101
-101
-1-1-1
000
111



  1. #include   
  2. // Prewitt 算子  
  3. // 1. pImageData   圖像數據  
  4. // 2. nWidth       圖像寬度  
  5. // 3. nHeight      圖像高度  
  6. // 4. nWidthStep   圖像行大小  
  7. bool Prewitt(unsigned char *pImageData, int nWidth, int nHeight, int nWidthStep)  
  8. {  
  9.     int i = 0;  
  10.     int j = 0;  
  11.     int dx = 0;  
  12.     int dy = 0;  
  13.     int nValue = 0;  
  14.     unsigned char *pLine[3] = { NULL, NULL, NULL };  
  15.     for (j = 1; j < nHeight - 1; j++)  
  16.     {  
  17.         pLine[0] = pImageData + nWidthStep * (j - 1);  
  18.         pLine[1] = pImageData + nWidthStep * j;  
  19.         pLine[2] = pImageData + nWidthStep * (j + 1);  
  20.         for (i = 1; i < nWidth - 1; i++)  
  21.         {  
  22.             dx =  
  23.                 pLine[0][i+1] - pLine[0][i-1] +  
  24.                 pLine[1][i+1] - pLine[1][i-1] +  
  25.                 pLine[2][i+1] - pLine[2][i-1];  
  26.             dy =  
  27.                 pLine[2][i-1] - pLine[0][i-1] +  
  28.                 pLine[2][i]   - pLine[0][i]   +  
  29.                 pLine[2][i+1] - pLine[0][i+1];  
  30.             nValue = (int) sqrt((float) (dx * dx + dy * dy));  
  31.             if (nValue > 0xFF)  
  32.             {  
  33.                 nValue = 0xFF;  
  34.             }  
  35.             pLine[0][i-1] = (unsigned char) nValue;  
  36.         }  
  37.     }  
  38.     return true;  
  39. }  

沒有留言: