你的位置:首页 > 软件开发 > Java > 一种分割地图的并行分割算法。

一种分割地图的并行分割算法。

发布时间:2017-11-14 00:00:24
问题:7个国家首都与中国的首都连线,线段的交于中国地图上,记为7个点,这几个点彼此互不影响,互不重合,按照各自国家所占的贸易比例,同时进行分割地图。思路:利用深度,广度遍历均可。 1 package hccc01; 2 3 import java.awt.image.Buffe ...

问题:7个国家首都与中国的首都连线,线段的交于中国地图上,记为7个点,这几个点彼此互不影响,互不重合,按照各自国家所占的贸易比例,同时进行分割地图。

思路:利用深度,广度遍历均可。

一种分割地图的并行分割算法。一种分割地图的并行分割算法。
 1 package hccc01; 2  3 import java.awt.image.BufferedImage; 4 import java.io.File; 5 import java.io.IOException; 6 import java.util.ArrayList; 7 import java.util.Map; 8  9 import javax.imageio.ImageIO; 10  11 public class tree_map { 12  static ArrayList<String> list = tree_map1.getList(); 13  static Map<String, Integer> map = tree_map1.getMap(); 14  // 俄罗斯(255, 175, 175) 149697 2.7% 4686 173577 15  static ArrayList<String> A = new ArrayList<String>() { 16   { 17    add("351,210"); 18   } 19  }; 20  static int n_a = 0; 21  // 土耳其(255, 255, 0) 51664 0.2% 347 22  static ArrayList<String> B = new ArrayList<String>() { 23   { 24    add("279,299"); 25   } 26  }; 27  static int n_b = 0; 28  29  // 美国(255, 200, 0) 2689245 46.4% 80539 30  static ArrayList<String> C = new ArrayList<String>() { 31   { 32    add("244,317"); 33   } 34  }; 35  static int n_c = 0; 36  37  // 韩国(0, 255, 0) 778850 13.5% 23432 38  static ArrayList<String> D = new ArrayList<String>() { 39   { 40    add("784,322"); 41   } 42  }; 43  static int n_d = 0; 44  45  // 巴西(0, 255, 255) 1003099 17.3% 30028 46  static ArrayList<String> E = new ArrayList<String>() { 47   { 48    add("341,465"); 49   } 50  }; 51  static int n_e = 0; 52  // 澳大利亚(0, 0, 255) 1132923 19.6% 34021 53  static ArrayList<String> F = new ArrayList<String>() { 54   { 55    add("816,482"); 56   } 57  }; 58  static int n_f = 0; 59  60  // 坦桑利亚(255, 0, 255) 11501 0.3% 520 61  static ArrayList<String> G = new ArrayList<String>() { 62   { 63    add("459,512"); 64   } 65  }; 66  static int n_g = 0; 67  68  public static void main(String[] args) { 69   int n = 0; 70   for (; n < 60338; n++) { 71    // A点扩散 72    aSpread(n); 73    // B点扩散 74    bSpread(n); 75    cSpread(n); 76    dSpread(n); 77    eSpread(n); 78    fSpread(n); 79    gSpread(n); 80   } 81  82   // 扩散生成图片 83   create(); 84   // for (String in : map.keySet()) { 85   // // map.keySet()返回的是所有key的值 86   // Integer str = map.get(in);// 得到每个key多对用value的值 87   // if (-65536==(str)) { 88   // System.out.println(str); 89   // } 90   // } 91   System.out.print("over"); 92  } 93  94  private static void gSpread(int n) { 95   if (n_g < 500) { 96    int pixel = 0; 97    int Xg = Integer.parseInt((G.get(n).split(","))[0]); 98    int Yg = Integer.parseInt((G.get(n).split(","))[1]); 99    String G1 = (Xg + 1) + "" + "," + Yg + "";100    String G2 = Xg + "" + "," + (Yg + 1) + "";101    String G3 = (Xg - 1) + "" + "," + Yg + "";102    String G4 = Xg + "" + "," + (Yg - 1) + "";103    String G5 = (Xg + 1) + "" + "," + (Yg + 1) + "";104    String G6 = (Xg + 1) + "" + "," + (Yg - 1) + "";105    String G7 = Xg + "" + "," + Yg + "";106    String G8 = (Xg - 1) + "" + "," + (Yg - 1) + "";107    String G9 = (Xg - 1) + "" + "," + (Yg + 1) + "";108    // 资源池包含G点,则进行染色,否则不做处理109    if (list.contains(G1)) {110     pixel = tree_map1.getPixel(255, 0, 255);111     map.put(G1, pixel);112     list.remove(G1);113     G.add(G1);114     n_g += 1;115    }116    if (list.contains(G2)) {117     pixel = tree_map1.getPixel(255, 0, 255);118     map.put(G2, pixel);119     list.remove(G2);120     G.add(G2);121     n_g += 1;122    }123    if (list.contains(G3)) {124     pixel = tree_map1.getPixel(255, 0, 255);125     map.put(G3, pixel);126     list.remove(G3);127     G.add(G3);128     n_g += 1;129    }130    if (list.contains(G4)) {131     pixel = tree_map1.getPixel(255, 0, 255);132     map.put(G4, pixel);133     list.remove(G4);134     G.add(G4);135     n_g += 1;136    }137    if (list.contains(G5)) {138     pixel = tree_map1.getPixel(255, 0, 255);139     map.put(G5, pixel);140     list.remove(G5);141     G.add(G5);142     n_g += 1;143    }144    if (list.contains(G6)) {145     pixel = tree_map1.getPixel(255, 0, 255);146     map.put(G6, pixel);147     list.remove(G6);148     G.add(G6);149     n_g += 1;150    }151    if (list.contains(G7)) {152     pixel = tree_map1.getPixel(255, 0, 255);153     map.put(G7, pixel);154     list.remove(G7);155     G.add(G7);156     n_g += 1;157    }158    if (list.contains(G8)) {159     pixel = tree_map1.getPixel(255, 0, 255);160     map.put(G8, pixel);161     list.remove(G8);162     G.add(G8);163     n_g += 1;164    }165    if (list.contains(G9)) {166     pixel = tree_map1.getPixel(255, 0, 255);167     map.put(G9, pixel);168     list.remove(G9);169     G.add(G9);170     n_g += 1;171    }172   }173  }174 175  private static void fSpread(int n) {176   if (n_f < 40897) {177    int pixel = 0;178    int Xf = Integer.parseInt((F.get(n).split(","))[0]);179    int Yf = Integer.parseInt((F.get(n).split(","))[1]);180    String F1 = (Xf + 1) + "" + "," + Yf + "";181    String F2 = Xf + "" + "," + (Yf + 1) + "";182    String F3 = (Xf - 1) + "" + "," + Yf + "";183    String F4 = Xf + "" + "," + (Yf - 1) + "";184    String F5 = (Xf + 1) + "" + "," + (Yf + 1) + "";185    String F6 = (Xf + 1) + "" + "," + (Yf - 1) + "";186    String F7 = Xf + "" + "," + Yf + "";187    String F8 = (Xf - 1) + "" + "," + (Yf - 1) + "";188    String F9 = (Xf - 1) + "" + "," + (Yf + 1) + "";189    // 资源池包含F点,则进行染色,否则不做处理190    if (list.contains(F1)) {191     pixel = tree_map1.getPixel(0, 0, 255);192     map.put(F1, pixel);193     list.remove(F1);194     F.add(F1);195     n_f += 1;196    }197    if (list.contains(F2)) {198     pixel = tree_map1.getPixel(0, 0, 255);199     map.put(F2, pixel);200     list.remove(F2);201     F.add(F2);202     n_f += 1;203    }204    if (list.contains(F3)) {205     pixel = tree_map1.getPixel(0, 0, 255);206     map.put(F3, pixel);207     list.remove(F3);208     F.add(F3);209     n_f += 1;210    }211    if (list.contains(F4)) {212     pixel = tree_map1.getPixel(0, 0, 255);213     map.put(F4, pixel);214     list.remove(F4);215     F.add(F4);216     n_f += 1;217    }218    if (list.contains(F5)) {219     pixel = tree_map1.getPixel(0, 0, 255);220     map.put(F5, pixel);221     list.remove(F5);222     F.add(F5);223     n_f += 1;224    }225    if (list.contains(F6)) {226     pixel = tree_map1.getPixel(0, 0, 255);227     map.put(F6, pixel);228     list.remove(F6);229     F.add(F6);230     n_f += 1;231    }232    if (list.contains(F7)) {233     pixel = tree_map1.getPixel(0, 0, 255);234     map.put(F7, pixel);235     list.remove(F7);236     F.add(F7);237     n_f += 1;238    }239    if (list.contains(F8)) {240     pixel = tree_map1.getPixel(0, 0, 255);241     map.put(F8, pixel);242     list.remove(F8);243     F.add(F8);244     n_f += 1;245    }246    if (list.contains(F9)) {247     pixel = tree_map1.getPixel(0, 0, 255);248     map.put(F9, pixel);249     list.remove(F9);250     F.add(F9);251     n_f += 1;252    }253   }254  }255 256  private static void eSpread(int n) {257   if (n_e < 40876) {258    int pixel = 0;259    int Xe = Integer.parseInt((E.get(n).split(","))[0]);260    int Ye = Integer.parseInt((E.get(n).split(","))[1]);261    String E1 = (Xe + 1) + "" + "," + Ye + "";262    String E2 = Xe + "" + "," + (Ye + 1) + "";263    String E3 = (Xe - 1) + "" + "," + Ye + "";264    String E4 = Xe + "" + "," + (Ye - 1) + "";265    String E5 = (Xe + 1) + "" + "," + (Ye + 1) + "";266    String E6 = (Xe + 1) + "" + "," + (Ye - 1) + "";267    String E7 = Xe + "" + "," + Ye + "";268    String E8 = (Xe - 1) + "" + "," + (Ye - 1) + "";269    String E9 = (Xe - 1) + "" + "," + (Ye + 1) + "";270    // 资源池包含E点,则进行染色,否则不做处理271    if (list.contains(E1)) {272     pixel = tree_map1.getPixel(0, 255, 255);273     map.put(E1, pixel);274     list.remove(E1);275     E.add(E1);276     n_e += 1;277    }278    if (list.contains(E2)) {279     pixel = tree_map1.getPixel(0, 255, 255);280     map.put(E2, pixel);281     list.remove(E2);282     E.add(E2);283     n_e += 1;284    }285    if (list.contains(E3)) {286     pixel = tree_map1.getPixel(0, 255, 255);287     map.put(E3, pixel);288     list.remove(E3);289     E.add(E3);290     n_e += 1;291    }292    if (list.contains(E4)) {293     pixel = tree_map1.getPixel(0, 255, 255);294     map.put(E4, pixel);295     list.remove(E4);296     E.add(E4);297     n_e += 1;298    }299    if (list.contains(E5)) {300     pixel = tree_map1.getPixel(0, 255, 255);301     map.put(E5, pixel);302     list.remove(E5);303     E.add(E5);304     n_e += 1;305    }306    if (list.contains(E6)) {307     pixel = tree_map1.getPixel(0, 255, 255);308     map.put(E6, pixel);309     list.remove(E6);310     E.add(E6);311     n_e += 1;312    }313    if (list.contains(E7)) {314     pixel = tree_map1.getPixel(0, 255, 255);315     map.put(E7, pixel);316     list.remove(E7);317     E.add(E7);318     n_e += 1;319    }320    if (list.contains(E8)) {321     pixel = tree_map1.getPixel(0, 255, 255);322     map.put(E8, pixel);323     list.remove(E8);324     E.add(E8);325     n_e += 1;326    }327    if (list.contains(E9)) {328     pixel = tree_map1.getPixel(0, 255, 255);329     map.put(E9, pixel);330     list.remove(E9);331     E.add(E9);332     n_e += 1;333    }334   }335  }336 337  private static void dSpread(int n) {338   if (n_d < 45204) {339    int pixel = 0;340    int Xd = Integer.parseInt((D.get(n).split(","))[0]);341    int Yd = Integer.parseInt((D.get(n).split(","))[1]);342    String D1 = (Xd + 1) + "" + "," + Yd + "";343    String D2 = Xd + "" + "," + (Yd + 1) + "";344    String D3 = (Xd - 1) + "" + "," + Yd + "";345    String D4 = Xd + "" + "," + (Yd - 1) + "";346    String D5 = (Xd + 1) + "" + "," + (Yd + 1) + "";347    String D6 = (Xd + 1) + "" + "," + (Yd - 1) + "";348    String D7 = Xd + "" + "," + Yd + "";349    String D8 = (Xd - 1) + "" + "," + (Yd - 1) + "";350    String D9 = (Xd - 1) + "" + "," + (Yd + 1) + "";351    // 资源池包含D点,则进行染色,否则不做处理352    if (list.contains(D1)) {353     pixel = tree_map1.getPixel(0, 255, 0);354     map.put(D1, pixel);355     list.remove(D1);356     D.add(D1);357     n_d += 1;358    }359    if (list.contains(D2)) {360     pixel = tree_map1.getPixel(0, 255, 0);361     map.put(D2, pixel);362     list.remove(D2);363     D.add(D2);364     n_d += 1;365    }366    if (list.contains(D3)) {367     pixel = tree_map1.getPixel(0, 255, 0);368     map.put(D3, pixel);369     list.remove(D3);370     D.add(D3);371     n_d += 1;372    }373    if (list.contains(D4)) {374     pixel = tree_map1.getPixel(0, 255, 0);375     map.put(D4, pixel);376     list.remove(D4);377     D.add(D4);378     n_d += 1;379    }380    if (list.contains(D5)) {381     pixel = tree_map1.getPixel(0, 255, 0);382     map.put(D5, pixel);383     list.remove(D5);384     D.add(D5);385     n_d += 1;386    }387    if (list.contains(D6)) {388     pixel = tree_map1.getPixel(0, 255, 0);389     map.put(D6, pixel);390     list.remove(D6);391     D.add(D6);392     n_d += 1;393    }394    if (list.contains(D7)) {395     pixel = tree_map1.getPixel(0, 255, 0);396     map.put(D7, pixel);397     list.remove(D7);398     D.add(D7);399     n_d += 1;400    }401    if (list.contains(D8)) {402     pixel = tree_map1.getPixel(0, 255, 0);403     map.put(D8, pixel);404     list.remove(D8);405     D.add(D8);406     n_d += 1;407    }408    if (list.contains(D9)) {409     pixel = tree_map1.getPixel(0, 255, 0);410     map.put(D9, pixel);411     list.remove(D9);412     D.add(D9);413     n_d += 1;414    }415   }416  }417 418  private static void cSpread(int n) {419   if (n_c < 37000) {420    int pixel = 0;421    int Xc = Integer.parseInt((C.get(n).split(","))[0]);422    int Yc = Integer.parseInt((C.get(n).split(","))[1]);423    String C1 = (Xc + 1) + "" + "," + Yc + "";424    String C2 = Xc + "" + "," + (Yc + 1) + "";425    String C3 = (Xc - 1) + "" + "," + Yc + "";426    String C4 = Xc + "" + "," + (Yc - 1) + "";427    String C5 = (Xc + 1) + "" + "," + (Yc + 1) + "";428    String C6 = (Xc + 1) + "" + "," + (Yc - 1) + "";429    String C7 = Xc + "" + "," + Yc + "";430    String C8 = (Xc - 1) + "" + "," + (Yc - 1) + "";431    String C9 = (Xc - 1) + "" + "," + (Yc + 1) + "";432    // 资源池包含C点,则进行染色,否则不做处理433    if (list.contains(C1)) {434     pixel = tree_map1.getPixel(255, 200, 0);435     map.put(C1, pixel);436     list.remove(C1);437     C.add(C1);438     n_c += 1;439    }440    if (list.contains(C2)) {441     pixel = tree_map1.getPixel(255, 200, 0);442     map.put(C2, pixel);443     list.remove(C2);444     C.add(C2);445     n_c += 1;446    }447    if (list.contains(C3)) {448     pixel = tree_map1.getPixel(255, 200, 0);449     map.put(C3, pixel);450     list.remove(C3);451     C.add(C3);452     n_c += 1;453    }454    if (list.contains(C4)) {455     pixel = tree_map1.getPixel(255, 200, 0);456     map.put(C4, pixel);457     list.remove(C4);458     C.add(C4);459     n_c += 1;460    }461    if (list.contains(C5)) {462     pixel = tree_map1.getPixel(255, 200, 0);463     map.put(C5, pixel);464     list.remove(C5);465     C.add(C5);466     n_c += 1;467    }468    if (list.contains(C6)) {469     pixel = tree_map1.getPixel(255, 200, 0);470     map.put(C6, pixel);471     list.remove(C6);472     C.add(C6);473     n_c += 1;474    }475    if (list.contains(C7)) {476     pixel = tree_map1.getPixel(255, 200, 0);477     map.put(C7, pixel);478     list.remove(C7);479     C.add(C7);480     n_c += 1;481    }482    if (list.contains(C8)) {483     pixel = tree_map1.getPixel(255, 200, 0);484     map.put(C8, pixel);485     list.remove(C8);486     C.add(C8);487     n_c += 1;488    }489    if (list.contains(C9)) {490     pixel = tree_map1.getPixel(255, 200, 0);491     map.put(C9, pixel);492     list.remove(C9);493     C.add(C9);494     n_c += 1;495    }496   }497  }498 499  // }500 501  private static void bSpread(int n) {502   if (n_b < 3277) {503    int pixel = 0;504    int Xb = Integer.parseInt((B.get(n).split(","))[0]);505    int Yb = Integer.parseInt((B.get(n).split(","))[1]);506    String B1 = (Xb + 1) + "" + "," + Yb + "";507    String B2 = Xb + "" + "," + (Yb + 1) + "";508    String B3 = (Xb - 1) + "" + "," + Yb + "";509    String B4 = Xb + "" + "," + (Yb - 1) + "";510    String B5 = (Xb + 1) + "" + "," + (Yb + 1) + "";511    String B6 = (Xb + 1) + "" + "," + (Yb - 1) + "";512    String B7 = Xb + "" + "," + Yb + "";513    String B8 = (Xb - 1) + "" + "," + (Yb - 1) + "";514    String B9 = (Xb - 1) + "" + "," + (Yb + 1) + "";515    // 资源池包含B点,则进行染色,否则不做处理516    if (list.contains(B1)) {517     pixel = tree_map1.getPixel(255, 255, 0);518     map.put(B1, pixel);519     list.remove(B1);520     B.add(B1);521     n_b += 1;522    }523    if (list.contains(B2)) {524     pixel = tree_map1.getPixel(255, 255, 0);525     map.put(B2, pixel);526     list.remove(B2);527     B.add(B2);528     n_b += 1;529    }530    if (list.contains(B3)) {531     pixel = tree_map1.getPixel(255, 255, 0);532     map.put(B3, pixel);533     list.remove(B3);534     B.add(B3);535     n_b += 1;536    }537    if (list.contains(B4)) {538     pixel = tree_map1.getPixel(255, 255, 0);539     map.put(B4, pixel);540     list.remove(B4);541     B.add(B4);542     n_b += 1;543    }544    if (list.contains(B5)) {545     pixel = tree_map1.getPixel(255, 255, 0);546     map.put(B5, pixel);547     list.remove(B5);548     B.add(B5);549     n_b += 1;550    }551    if (list.contains(B6)) {552     pixel = tree_map1.getPixel(255, 255, 0);553     map.put(B6, pixel);554     list.remove(B6);555     B.add(B6);556     n_b += 1;557    }558    if (list.contains(B7)) {559     pixel = tree_map1.getPixel(255, 255, 0);560     map.put(B7, pixel);561     list.remove(B7);562     B.add(B7);563     n_b += 1;564    }565    if (list.contains(B8)) {566     pixel = tree_map1.getPixel(255, 255, 0);567     map.put(B8, pixel);568     list.remove(B8);569     B.add(B8);570     n_b += 1;571    }572    if (list.contains(B9)) {573     pixel = tree_map1.getPixel(255, 255, 0);574     map.put(B9, pixel);575     list.remove(B9);576     B.add(B9);577     n_b += 1;578    }579   }580  }581 582  private static void aSpread(int n) {583   if (n_a < 4000) {584    int pixel = 0;585    int Xa = Integer.parseInt((A.get(n).split(","))[0]);586    int Ya = Integer.parseInt((A.get(n).split(","))[1]);587    String A1 = (Xa + 1) + "" + "," + Ya + "";588    String A2 = Xa + "" + "," + (Ya + 1) + "";589    String A3 = (Xa - 1) + "" + "," + Ya + "";590    String A4 = Xa + "" + "," + (Ya - 1) + "";591    String A5 = (Xa + 1) + "" + "," + (Ya + 1) + "";592    String A6 = (Xa + 1) + "" + "," + (Ya - 1) + "";593    String A7 = (Xa - 1) + "" + "," + (Ya - 1) + "";594    String A8 = (Xa - 1) + "" + "," + Ya + "";595    String A9 = Xa + "" + "," + Ya + "";596    // 资源池包含A点,则进行染色,否则不做处理;597    if (list.contains(A1)) {598     pixel = tree_map1.getPixel(255, 175, 175);599     map.put(A1, pixel);600     list.remove(A1);601     A.add(A1);602     n_a += 1;603    }604    if (list.contains(A2)) {605     pixel = tree_map1.getPixel(255, 175, 175);606     map.put(A2, pixel);607     list.remove(A2);608     A.add(A2);609     n_a += 1;610    }611    if (list.contains(A3)) {612     pixel = tree_map1.getPixel(255, 175, 175);613     map.put(A3, pixel);614     list.remove(A3);615     A.add(A3);616     n_a += 1;617    }618    if (list.contains(A4)) {619     pixel = tree_map1.getPixel(255, 175, 175);620     map.put(A4, pixel);621     list.remove(A4);622     A.add(A4);623     n_a += 1;624    }625    if (list.contains(A5)) {626     pixel = tree_map1.getPixel(255, 175, 175);627     map.put(A5, pixel);628     list.remove(A5);629     A.add(A5);630     n_a += 1;631    }632    if (list.contains(A6)) {633     pixel = tree_map1.getPixel(255, 175, 175);634     map.put(A6, pixel);635     list.remove(A6);636     A.add(A6);637     n_a += 1;638    }639    if (list.contains(A7)) {640     pixel = tree_map1.getPixel(255, 175, 175);641     map.put(A7, pixel);642     list.remove(A7);643     A.add(A7);644     n_a += 1;645    }646    if (list.contains(A8)) {647     pixel = tree_map1.getPixel(255, 175, 175);648     map.put(A8, pixel);649     list.remove(A8);650     A.add(A8);651     n_a += 1;652    }653    if (list.contains(A9)) {654     pixel = tree_map1.getPixel(255, 175, 175);655     map.put(A9, pixel);656     list.remove(A9);657     A.add(A9);658     n_a += 1;659    }660   }661  }662 663  private static void create() {664   File file = new File("H:\\maphc02.bmp");665   BufferedImage bi = null;666   try {667    bi = ImageIO.read(file);668   } catch (Exception e) {669    e.printStackTrace();670   }671   int width = bi.getWidth();672   int height = bi.getHeight();673   int minX = bi.getMinX();674   int minY = bi.getMinY();675   for (int y = minY; y < height; y++) {676    for (int x = minX; x < width; x++) {677     String zuobiao = x + "" + "," + y + "";678     if (map.containsKey(zuobiao)) {679      bi.setRGB(x, y, map.get(zuobiao));680     }681    }682   }683   file = new File("H:\\maphc04.bmp");684   try {685    ImageIO.write(bi, "bmp", file);686   } catch (IOException e) {687    e.printStackTrace();688   }689  }690 }691 package hccc01;692 693 import java.awt.image.BufferedImage;694 import java.io.File;695 import java.util.ArrayList;696 import java.util.HashMap;697 import java.util.Map;698 699 import javax.imageio.ImageIO;700 701 /**702  * 703  * @author hccc、704  * 初始化获得初始图片的资源池705  *706 */707 public class tree_map1 {708  public static ArrayList<String> getList() {709   ArrayList<String> list = new ArrayList<String>();710   String temp;711   int[] rgb = new int[3];712   File file = new File("H:\\maphc02.bmp");713   BufferedImage bi = null;714   try {715    bi = ImageIO.read(file);716   } catch (Exception e) {717    e.printStackTrace();718   }719   int width = bi.getWidth();720   int height = bi.getHeight();721   int minX = bi.getMinX();722   int minY = bi.getMinY();723   for (int y = minY; y < height; y++) {724    for (int x = minX; x < width; x++) {725     int pixel = bi.getRGB(x, y);726     rgb[0] = (pixel & 0xff0000) >> 16; // r727     rgb[1] = (pixel & 0xff00) >> 8; // g728     rgb[2] = (pixel & 0xff); // b729     if (rgb[0] == 238 && rgb[1] == 238 && rgb[2] == 238) {730      temp = x + "" + "," + y + "";731      list.add(temp);732     }733    }734   }735   return list;736  }737  public static Map<String,Integer> getMap() {738   Map<String,Integer> map= new HashMap<String,Integer>();739   String temp;740   int[] rgb = new int[3];741   File file = new File("H:\\maphc02.bmp");742   BufferedImage bi = null;743   try {744    bi = ImageIO.read(file);745   } catch (Exception e) {746    e.printStackTrace();747   }748   int width = bi.getWidth();749   int height = bi.getHeight();750   int minX = bi.getMinX();751   int minY = bi.getMinY();752   for (int y = minY; y < height; y++) {753    for (int x = minX; x < width; x++) {754     int pixel = bi.getRGB(x, y);755     rgb[0] = (pixel & 0xff0000) >> 16; // r756     rgb[1] = (pixel & 0xff00) >> 8; // g757     rgb[2] = (pixel & 0xff); // b758     if (rgb[0] == 238 && rgb[1] == 238 && rgb[2] == 238) {759      temp = x + "" + "," + y + "";760      map.put(temp, pixel);761     }762    }763   }764   return map;765  }766  public static int getPixel(int i, int j, int k) {767   int r = i << 16;768   int g = j << 8;769   int b = k;770   int pixel = 0xff000000 | r | g | b;771   return pixel;772  }773 }
View Code

 

 

可视化进度:

一种分割地图的并行分割算法。

图1,世界地图上7个国家与北京的连线,线段交于中国地图上;

 一种分割地图的并行分割算法。

图2,中国地图上,7个国家进行并行切割,互不重合;

 

原标题:一种分割地图的并行分割算法。

关键词:

*特别声明:以上内容来自于网络收集,著作权属原作者所有,如有侵权,请联系我们: admin#shaoqun.com (#换成@)。

可能感兴趣文章

我的浏览记录