熱線電話:13121318867

登錄
首頁精彩閱讀Hilbert空間遞歸演示?_數據分析師
Hilbert空間遞歸演示?_數據分析師
2014-12-07
收藏

Hilbert空間遞歸演示_數據分析師


Hilbert空間填充曲線在圖像采樣等方面十分有用關于什么希爾伯特

空間填充曲線看這里:http://en.wikipedia.org/wiki/Hilbert_curve

程序效果:

模擬Hilbert空間填充曲線效果,點擊鼠標自動疊加!運行效果截圖

20140217231252375

Hilbert源程序代碼:

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
package com.gloomyfish.image.hilbert;
         
import java.awt.Color;
import java.awt.Graphics;
import java.awt.Point;
         
public class Hilbert {
             
    public static final int WHEELSIZE = 1024;
             
    // four edges
    public static final int NORTH = 0;
    public static final int EAST = 90;
    public static final int SOUTH = 180;
    public static final int WEST = 270;
         
    // four corners
    public static final int NE = 45;
    public static final int SE = 135;
    public static final int SW = 225;
    public static final int NW = 315;
             
    // attributes
    private Point location;
    private Color[] colorWheel;
    private int colorIdx;
         
    public Hilbert() {
        // build color lookup table
        this.colorWheel = new Color[1024];
        for (int i = 0; i < 128; ++i)
            this.colorWheel[i] = new Color(0, 255 - i, i);
        for (int j = 128; j < 256; ++j)
            this.colorWheel[j] = new Color(0, j, j);
        for (int k = 0; k < 256; ++k)
            this.colorWheel[(k + 256)] = new Color(0, 255 - k, 255);
        for (int l = 0; l < 128; ++l)
            this.colorWheel[(l + 512)] = new Color(0, l, 255 - l);
        for (int i1 = 0; i1 < 128; ++i1)
            this.colorWheel[(i1 + 640)] = new Color(0, 127 - i1, 127 - i1);
        for (int i2 = 0; i2 < 256; ++i2)
            this.colorWheel[(i2 + 768)] = new Color(0, i2, 0);
        this.colorIdx = 0;
    }
         
    public void process(Graphics graphic, int level, int width, int height) {
        this.location = null;
        if(level > 32 ) 
        {
            graphic.drawString("could get max depth is 32!", 40, 40);
            return;
        }
        hilbert(graphic, level, 0, 0, width, height, 0, 225);
    }
         
    public void hilbert(Graphics g, int depth, int startx, int starty, int width, int height, int startgray, int endgray) {
        int centerX = width / 2;
        int centerY = height / 2;
        if (depth == 0) {
            if (this.location != null) {
                g.setColor(this.colorWheel[this.colorIdx]);
                g.drawLine(this.location.x, this.location.y,
                        startx + centerX, starty + centerY);
                if (++this.colorIdx >= 1024)
                    this.colorIdx = 0;
            }
            this.location = new Point(startx + centerX, starty + centerY);
            return;
        }
         
        switch (startgray) {

數據分析咨詢請掃描二維碼

若不方便掃碼,搜微信號:CDAshujufenxi

數據分析師資訊
更多

OK
客服在線
立即咨詢
日韩人妻系列无码专区视频,先锋高清无码,无码免费视欧非,国精产品一区一区三区无码
客服在線
立即咨詢