01: //----------------------------------------------------------------- 02: // ip_clstr.cpp: 03: // パターン分類: クラスタリング手法 04: // Last Update: <2004/12/22 22:19:09 A.Murakami> 05: //----------------------------------------------------------------- 06: #include <stdio.h> 07: #include <windows.h> 08: #include "wingui.h" 09: #include "ipcommon.h" 10: #include "clustering.h" 11: //----------------------------------------------------------------- 12: #define CLSTR_R 20 // クラスタ半径 13: //----------------------------------------------------------------- 14: void toOrg(); 15: void NNmethod(); 16: void Tree(); 17: void Kmean(); 18: //----------------------------------------------------------------- 19: // メニューへの追加内容 20: //----------------------------------------------------------------- 21: MenuInfo MI[] = { 22: {"元画像",toOrg}, 23: {"Clustering(NN)",NNmethod}, 24: {"Clustering(Tree)",Tree}, 25: {"Clustering(K-mean)",Kmean}, 26: {NULL,NULL} 27: }; 28: //----------------------------------------------------------------- 29: // 初期化 30: //----------------------------------------------------------------- 31: void IP_init(){} 32: //----------------------------------------------------------------- 33: // 元画像の表示 34: //----------------------------------------------------------------- 35: void toOrg() { CopyMemory(lpBMP,lpOrgBMP,iLength*iHeight); } 36: //----------------------------------------------------------------- 37: // NN法によるクラスタリング 38: //----------------------------------------------------------------- 39: void NNmethod() 40: { 41: // 濃淡画像の取得 42: LPBYTE iGray=GetGray(COLOR_G); //GetGray(); 43: clustering_NNmethod(iGray,CLSTR_R,CLUT_DALL); 44: //-------------------------------------------------- 45: // iGray: 入力/表示画像 46: // CLSTR_R: 初期クラスタ半径, 47: // 表示オプション: 48: // CLUT_DALL: クラスタ中心, 全パターン, 49: // クラスタ-パターン間の距離の表示 50: // CLUT_DCENT: クラスタ中心のみ表示 51: // CLUT_DALLPOINT: クラスタ中心, 全パターンの表示 52: //-------------------------------------------------- 53: // 表示用 54: GrayToColor(iGray,lpBMP); 55: // 後片付け 56: GlobalFree(iGray); 57: } 58: //----------------------------------------------------------------- 59: // 階層的クラスタリング 60: //----------------------------------------------------------------- 61: void Tree() 62: { 63: // 濃淡画像の取得 64: LPBYTE iGray=GetGray(COLOR_G); 65: clustering_Tree(iGray,CLSTR_R,CLUT_DCENT); 66: //-------------------------------------------------- 67: // iGray: 入力/表示画像 68: // CLSTR_R: 最小クラスタ間距離 69: //-------------------------------------------------- 70: // 表示用 71: GrayToColor(iGray,lpBMP); 72: // 後片付け 73: GlobalFree(iGray); 74: } 75: //----------------------------------------------------------------- 76: // K-平均法によるクラスタリング 77: //----------------------------------------------------------------- 78: void Kmean() 79: { 80: // 濃淡画像の取得 81: LPBYTE iGray=GetGray(COLOR_G); 82: clustering_Kmean(iGray,CLSTR_R,50,CLUT_DCENT); 83: //-------------------------------------------------- 84: // iGray: 入力/表示画像 85: // CLSTR_R: 初期クラスタ半径 86: // 50: K-number(K個の初期クラスタを与える) 87: //-------------------------------------------------- 88: // 表示用 89: GrayToColor(iGray,lpBMP); 90: // 後片付け 91: GlobalFree(iGray); 92: }