Deep Learning Into Advance - 1. Image, ConvNetHyojun Kim
[본 자료는 AB180 사내 스터디의 일환으로 제작되었습니다.]
딥러닝에 대한 기초적인 이해 및 적용 예시를 알아보고, 인사이트를 공유하기 위해 만들었습니다. 첫번째로 딥러닝이 이미지 프로세싱에 적용된 방식 및, Convolutional Neural Network (ConvNet)의 기초에 대해 다루었습니다.
* 본 스터디 자료는 Stanford 강좌인 CS231n (http://cs231n.stanford.edu)의 내용을 참고했습니다.
Deep learning기법을 이상진단 등에 적용할 경우, 정상과 이상 data-set간의 심각한 unbalance가 문제. 본 논문에서는 GAN 기법을 이용하여 정상 data-set만의 Manifold(축약된 모델)를 찾아낸 후 Query data에 대하여 기 훈련된 GAN 모델로 Manifold로의 mapping을 수행함으로서 기 훈련된 정상 data-set과의 차이가 있는지 여부를 판단하여 Query data의 이상 유무를 결정하고 영상 내에 존재하는 이상 영역을 pixel-wise segmentation 하여 제시함.
패턴을 인식하는 데 있어서 가장 기본적으로 알아야 하는 개념은 바로 Feature 공간입니다. 이미지 패턴 인식을 할 때에도 각 이미지를 Feature 공간 안에 배치한 후에 패턴을 인식하게 되는데, 불행히도 이미지는 고차원의 정보이기 때문에 우리가 실제로 느낄 수 있는 차원을 훨씬 뛰어넘는 공간에 배치 되어, 직관적인 패턴 분석이 많이 어렵습니다.
그렇기 때문에 PCA처럼 고차원 데이터를 저차원의 공간으로 Projection 하여 Visualization 하기 위한 수많은 연구들이 진행되어 왔고, 실제로 논문에서 실험 결과를 Visualization 하여 이해를 돕거나, 패턴을 분석하기 전에 데이터들이 어떠한 모양으로 분포하고 있는지에 대한 정보를 얻어 분석 방향을 결정하기도 하였습니다.
이번 세미나에서는 여러 Dimension Reduction 알고리즘들을 알아보고, 그 중에서도 좋은 성능을 자랑하는 알고리즘 중의 하나인 Nonlinear & Non-parametric Visualization 알고리즘인 t-SNE 알고리즘에 대해 살펴보겠습니다. 그리고 이러한 알고리즘들이 Dimension Reduction의 중요한 Point인 Global & Local 관계의 유지와 Manifold data의 Visualization을 얼마나 잘 수행하는지 알아보도록 하겠습니다.
사내 스터디용으로 공부하며 만든 발표 자료입니다. 부족한 부분이 있을 수도 있으니 알려주시면 정정하도록 하겠습니다.
*슬라이드 6에 나오는 classical CNN architecture(뒤에도 계속 나옴)에서 ReLU - Pool - ReLu에서 뒤에 나오는 ReLU는 잘못된 표현입니다. ReLU - Pool에서 ReLU 계산을 또 하는 건 redundant 하기 때문입니다(Kyung Mo Kweon 피드백 감사합니다)
Deep Learning Into Advance - 1. Image, ConvNetHyojun Kim
[본 자료는 AB180 사내 스터디의 일환으로 제작되었습니다.]
딥러닝에 대한 기초적인 이해 및 적용 예시를 알아보고, 인사이트를 공유하기 위해 만들었습니다. 첫번째로 딥러닝이 이미지 프로세싱에 적용된 방식 및, Convolutional Neural Network (ConvNet)의 기초에 대해 다루었습니다.
* 본 스터디 자료는 Stanford 강좌인 CS231n (http://cs231n.stanford.edu)의 내용을 참고했습니다.
Deep learning기법을 이상진단 등에 적용할 경우, 정상과 이상 data-set간의 심각한 unbalance가 문제. 본 논문에서는 GAN 기법을 이용하여 정상 data-set만의 Manifold(축약된 모델)를 찾아낸 후 Query data에 대하여 기 훈련된 GAN 모델로 Manifold로의 mapping을 수행함으로서 기 훈련된 정상 data-set과의 차이가 있는지 여부를 판단하여 Query data의 이상 유무를 결정하고 영상 내에 존재하는 이상 영역을 pixel-wise segmentation 하여 제시함.
패턴을 인식하는 데 있어서 가장 기본적으로 알아야 하는 개념은 바로 Feature 공간입니다. 이미지 패턴 인식을 할 때에도 각 이미지를 Feature 공간 안에 배치한 후에 패턴을 인식하게 되는데, 불행히도 이미지는 고차원의 정보이기 때문에 우리가 실제로 느낄 수 있는 차원을 훨씬 뛰어넘는 공간에 배치 되어, 직관적인 패턴 분석이 많이 어렵습니다.
그렇기 때문에 PCA처럼 고차원 데이터를 저차원의 공간으로 Projection 하여 Visualization 하기 위한 수많은 연구들이 진행되어 왔고, 실제로 논문에서 실험 결과를 Visualization 하여 이해를 돕거나, 패턴을 분석하기 전에 데이터들이 어떠한 모양으로 분포하고 있는지에 대한 정보를 얻어 분석 방향을 결정하기도 하였습니다.
이번 세미나에서는 여러 Dimension Reduction 알고리즘들을 알아보고, 그 중에서도 좋은 성능을 자랑하는 알고리즘 중의 하나인 Nonlinear & Non-parametric Visualization 알고리즘인 t-SNE 알고리즘에 대해 살펴보겠습니다. 그리고 이러한 알고리즘들이 Dimension Reduction의 중요한 Point인 Global & Local 관계의 유지와 Manifold data의 Visualization을 얼마나 잘 수행하는지 알아보도록 하겠습니다.
사내 스터디용으로 공부하며 만든 발표 자료입니다. 부족한 부분이 있을 수도 있으니 알려주시면 정정하도록 하겠습니다.
*슬라이드 6에 나오는 classical CNN architecture(뒤에도 계속 나옴)에서 ReLU - Pool - ReLu에서 뒤에 나오는 ReLU는 잘못된 표현입니다. ReLU - Pool에서 ReLU 계산을 또 하는 건 redundant 하기 때문입니다(Kyung Mo Kweon 피드백 감사합니다)
Slides based on "Introduction to Machine Learning with Python" by Andreas Muller and Sarah Guido for Hongdae Machine Learning Study(https://www.meetup.com/Hongdae-Machine-Learning-Study/) (epoch #2)
홍대 머신 러닝 스터디(https://www.meetup.com/Hongdae-Machine-Learning-Study/) (epoch #2)의 "파이썬 라이브러리를 활용한 머신러닝"(옮긴이 박해선) 슬라이드 자료.
3. Agenda
The New Bases
Implementation Strategy
– Dicing Space
– Neighbor Testing
– The Subtle Population Table
– Extensions and Alternatives
Sample Code
3
5. Cellular Texturing
Perlin’s Noise 를 보완할 수 있는 새로운 Function 제안
Steve Worley
CEO, founder
Worley Laboratories
1995 – Present (17 years) Menlo Park, California
Research and development of graphics tools
Developed and released 6 different software products:
Gaffer: lighting snad shading methods
Polk, Taft: collections of artist utilities
Sasquatch: procedural hair and fur modeler and renderer
G2: interactive lighting and shading system
FPrime: the industry's first real-time render-accurate preview renderer, using interactive raytracing.
5
6. Cellular Texturing
Perlin’s Noise 를 보완할 수 있는 새로운 Function 제안
Cell을 random하게 배열하여 공간을 나누는 것에 기초
포장도로의 표면, 타일로 붙여진 표면, 생물의 딱딱한 피부나 껍
질, 구겨진 종이, 얼음, 바위, 분화구 등을 표현
미리 계산하거나 table storage 없이 효율적인 계산 가능
6
7. Cellular Texturing
R3 공간에서 정의되고, scalar value 로 return
– Point (x, y, z) 를 Input value 로 받아서 scalar value 을 얻음.
– 이 scalar value 는 직접적으로 색의 값으로 표현되거나 regular pattern을 흐트러뜨리는 역할
을 함.
< Perlin‟s Noise Function(3D Basis) :
(a) Wrinkles, (b) Color >
7
8. Cellular Texturing
Many Texture Algorithms 와 비교
– Fourier methods
– Reaction diffusion textures, An algorithm by Miyata
-> Extensive Precomputation 이 요구되고, scalar value 로 return 이 되지 않아 매우 복잡하고 규
모가 커서 일반적이지 못함.
(a) (b)
< Many Texture Algorithms :
(a) Reaction diffusion - horse ,
(b) An algorithm by Miyata – Edo Castle >
– Many texture algorithms은 제한된 form 때문에 응용이 어려운 반면, Perlin‟s noise function은
매우 단순하여 얼마든지 다양하고 쉽게 응용 가능.
-> new texture function을 만들고, Basis Function으로 사용 가능.
8
9. The New Bases
2가지 기초 개념
– “feature points” 를 R3영역에 흩어 뿌리는 것.
– “local points”의 분포도에 따른 scalar function을 만드는 것.
• local points 의 분포를 사용하는 또 다른 예 ( Bombing, Lewis Methods…)
The Perlin‟s noise basis function과 같이 precomputation 이나 table storage
없이도 효과적인 noise의 표현과 계산이 가능
기존의 noise function 보다 매우 다양하고 독특한 효과를 기대할 수 있음
9
10. The New Bases
Definition
– Randomly Distributed Feature Points in R3
– F1 (x) : Distance to Closest Feature Point from any Point x in R3
(예를 들면 F1 (x) 를 이용해 R3공간에 일반적인 Voronoi region을 형성)
– F2(x): Distance to Second Closest Feature Point
– Fn(x): Distance to n th Closest Feature Point
(a) (b) (c)
< F1(x) Function :
(a) 2D Plane On surface,
(b) 2D Plane Off surface,
(c) 3D plane >
10
11. The New Bases
Fn(x) Properties
– Fn(x) 는 항상 continuous 함.
– Fn(x) 는 n에 비례하여 항상 증가.( 감소하지 않음)
-> 0 F ( x) F ( x) F ( x)Ingeneral :
1 2 , ( 3 F ( x)) F
n n 1
( x)
– The gradient of Fn(x)
: x 에 n번째로 가까운 feature point 를 가르키는 간단하게 unit direction vector
11
12. The New Bases
Voronoi diagram
두 점 p와 q 사이의 유클리안 거리를 dist(p, q),, 한 평면상에
n개의 분리된 점들의 집합 P를 P={p1, p2, p3, ..., pn} 라고 할때
P의 Voronoi Diagram은 그 평면을 P에 있는 각각의 점에 대해서 n개의 cell로 나누는 것 만
일, dist(pi, q) < dist(pj, q) 를 만족하면 q는 p1 cell에 포함되며
평면상의 점들은 P에 있는 점들 중 가장 가까운 점이 속한 cell에 포함
12
16. Implementation Strategy
이것을 사용 하기 위해
Cellular 텍스처 기반 기능을
구현하는 방법을 이해할 필요는 없다
기초의 주요 알고리즘의 수정 및 각색은
원래 노이즈 버전에서
0
새로운 효과를 생성할수 있게 한다
17. Implementation Strategy
Feature Points가 공간을 통해 확산되는 방법을 정의
밀도 및 포인트의 분포는 basis function 의 성격을 변화
첫번째 가정은 월드의 축에 부합하는
기본 패턴을 피하는 등방성 function이 필요
17
18. Dicing Space
큐브 안에
한정된 영역을
공간을 자르고
생성하고
각 큐브 안의
테스트 Feature Point 를 계산
18
20. Dicing Space
Feature Points가 스스로 생성하는 위치의 Seed 도 필요
Solution
Fast Random Number Generator에 대한 Seed로 사용하는 단일 32 비트 정수
안에서 큐브의 월드 정수 좌표를 섞는 것(hash)
20
21. Dicing Space
short lookup table of 256 possibilities
Seed 큐브에 있는 점 개수를 계산
Possible point populations의 고정배열은 Magic Property
“Points Isotropic 을 유지”해주고 Precomputed 됨
21
24. The Subtle Population Table
포와송 분포는 주어진 평균 밀도에서, 해당 범위내에서, 특정 point
개수를 찾을 확률(가능성)을 제공
불연속 포와송 분포 함수를 사용하면 영역내에 point 가 얼마나
있을지에 대한 정확한 확률을 계산
만약 포와송 확률을 바탕으로 한 모집단을 가지고, 각각의 cube 내에 있는 point
들을 랜덤하게 생성한다면, feature point 들은 모두 등방성 일 것이고, texture
function 은 grid bias를 전혀 가지지 않을 것
이상적인 데이터를 얻기 위해 Poisson distribution 을 사용
24
25. The Subtle Population Table
“unit volume 한개당 feature point 평균 밀도를 λ라고 하고,
unit cube 하나에 m 개의 feature point 가 존재할 확률은 다음과 같다.”
(P(λ,m) : unit cube 하나에 m 개의 feature point 가 존재할 확률, 즉 Poisson 확률)
P(λ,m) = λ^(m)/{ e^(λ)* m!)}
25
26. The Subtle Population Table
“X는 어느 대학의 월요일 오전 9시 수업에 결석하는 학생수를 나타낸다고 가정,
보통 기대값은 2.5명으로 알려져 있다 만약 5명을 초과한 수의 학생이 결석할 확률은?”
26
27. The Subtle Population Table
특징
– λ 값이 크다는 건 Cube 내에 Feature Point 가 많다는 의미 Point를 생성하고 테스트하는데 시
간이 걸림
– λ 값이 낮다는건 더 많은 Neighbor Cube를 조사하는데 시간이 걸림
– λ 값을 선택하는 가장 확실한 방법은 다른 값을 넣어보고 빠른 속도를 가지는지 찾아서 그값
을 λ 값으로 선택하는 것
– 최상의 밸런스는 Input Constant로 나누어 간단하게 Scaling 함으로서 Scale 값을 변경시켜
보면서 밸런스를 찾음 텍스쳐 제작자의 편의를 위해 Normalize 하는 것이 좋음
27
28. Extensions and Alternatives
확장성이 크고 커스터마이즈가 용이함
Ken Musgrave 가 소개한 다양한 방법의 프랙탈 조차도 기본형태에서 Noise의 기
본 Function을 사용
distance 의 정의 자체를 변경할수 있다는것.
(간단하게 Euclidean distance d2=dx*dx+dy*dy+dz*dz; ) Biased
“stretched” A*dx*dx+B*dy*dy+C*dz*dz Manhattan distance
fabs(dx)+fabs(dy)+fabs(dz) Radial Manhattan:
A*fabs(dR)+B*fabs(dTheta)+C*dz Superquadratic:
pow(fabs(dx), A) + pow(fabs(dy), B) + pow(fabs(dz),C)
28
29. Extensions and Alternatives
(a) F1(x)
- 매우 simple
- 직접 color spline and bump 로 map 가능
- feature points 주위로 분포 -> 기본적인 voronoi 영역
- example : Polka Dots (물방울 무늬)
(b) F2(x)(좌) & F2(x)(우)
- 빠른 변화와 내부구조를 형성
- 직접 color spline and bump 로 map 가능하지만
linear combination 을 형성함으로써 더 흥미로운
패턴 생성.
29
30. Extensions and Alternatives
(c) F2(x) – F1(x) ; 2D
- 모든 x에 있어서 F2(x) > F1(x)
- 직접 color spline and bump 로 map 가능
- F2(x) = F1(x) 에서 0 값을 가지고 voronoi boundaries 에서 나타남
- to make latticework of connected ridges, forming a vein-like tracery
(d) Constant Base Color plus Fractal Noise over F1 Regions,
F2(x) – F1(x) Bump Mapping ; 3D Flagstone texture
- F1 function이 가장 가까운 feature point 의 identity 를 나타내는
고유의 ID number를 return 시키면, 이 number는 voronoi cell 에
걸쳐 일정한 values를 만들게 됨. -> 즉 하나의 cell 을 일정한 색으로
shade 가 가능.
- F2(x) - F1(x) 에 기초한 Bump Mapping 적용
- 각 cell 에서 fractal noise 로 얼룩 표현
30
31. Extensions and Alternatives
(e) Linear Combination of Fn
: C1F1 + C2F2 + C3F3 + C4F4
(Flagstone-like area)
- low n basis function 의 combinations
- Cn의 변화를 주어 생성.
31
32. Extensions and Alternatives
(f) Fractal Version
- noise 로 fractal noise 를 만드는 것과
같음.
- different weight & Scaling factors 를
이용하여 다양한 표현
- computing a function
: range of i (i=0~5)
- 위의 Gn 을 color and bumps에 대한
index로 사용
* upper
- spotted pattern, F1의 fractal version
- tongue : fractal noise 사용
- body : linear gradient 가 color variation
을 위해 적용
* lower
- More Fractal versions ; Cut Tori
32
33. Extensions and Alternatives
(g) F1 Fractal Crumple : Seawater (upper)
- 가장 유용한 version
- Bump Map 으로만 응용 시, 종이나 tinfoil(쵸코렛이나
담배 등을 싸는 은종이) 처럼 surface 를 ‘crumple’ 시킴.
- 부드러운 surface 를 break up 하는 방법으로 예술가들
에게 굉장히 인기.
- fractal noise bumps 와는 달리 subtle roughening을 제
공.
- 이 crumple appearance를 가진 reflective, bumped
map plane은 바닷물과 매우 흡사하게 나타남.
(f) More Distance Metrics
- Manhattan Metric (lower)
- A radial coordinate version : ‘Death Star’
33
34. Extensions and Alternatives
(g) Spatially Varying Density
- Object Geometry
- 보통 algorithm 은 3D에서 compute 되지만, 2D
variants는 속도를 빠르게 함.
- 4D variants 는 animated 분야에 사용될 수 있지만
속도가 매우 떨어짐.
34
35. Sample Code
static int Poisson_count[256]=
{4,3,1,1,1,2,4,2,2,2,5,1,0,2,1,2,2,0,4,3,2,1,2,1,3,2,2,4,2,2,5,1,2,3,2,2,2,2,2,3,
2,4,2,5,3,2,2,2,5,3,3,5,2,1,3,3,4,4,2,3,0,4,2,2,2,1,3,2,2,2,3,3,3,1,2,0,2,1,1,2,
2,2,2,5,3,2,3,2,3,2,2,1,0,2,1,1,2,1,2,2,1,3,4,2,2,2,5,4,2,4,2,2,5,4,3,2,2,5,4,3,
3,3,5,2,2,2,2,2,3,1,1,4,2,1,3,3,4,3,2,4,3,3,3,4,5,1,4,2,4,3,1,2,3,5,3,2,1,3,1,3,
3,3,2,3,1,5,5,4,2,2,4,1,3,4,1,5,3,3,5,3,4,3,2,2,1,1,1,1,1,2,4,5,4,5,4,2,1,5,1,1,
2,3,3,3,2,5,2,3,3,2,0,2,1,1,4,2,1,3,2,1,2,2,3,2,5,5,3,4,5,5,2,4,4,5,3,2,2,2,1,4,
2,3,3,4,2,5,4,2,4,2,2,2,4,5,3,2};
#define DENSITY_ADJUSTMENT 0.398150
static void AddSamples(long xi, long yi, long zi, long max_order,
double at[3], double *F,
double (*delta)[3], unsigned long *ID);
35
36. Sample Code
/* The main function! */
void Worley(double at[3], long max_order,
double *F, double (*delta)[3], unsigned long *ID)
{
double x2,y2,z2, mx2, my2, mz2;
double new_at[3];
long int_at[3], i;
/* Initialize the F values to "huge" so they will be replaced by the
first real sample tests. Note we'll be storing and comparing the
SQUARED distance from the feature points to avoid lots of slow
sqrt() calls. We'll use sqrt() only on the final answer. */
for (i=0; i<max_order; i++) F[i]=999999.9;
/* Make our own local copy, multiplying to make mean(F[0])==1.0 */
new_at[0]=DENSITY_ADJUSTMENT*at[0];
new_at[1]=DENSITY_ADJUSTMENT*at[1];
new_at[2]=DENSITY_ADJUSTMENT*at[2];
/* Find the integer cube holding the hit point */
int_at[0]=(long)floor(new_at[0]); /* A macro could make this slightly faster */
int_at[1]=(long)floor(new_at[1]);
int_at[2]=(long)floor(new_at[2]);
/* A simple way to compute the closest neighbors would be to test all
boundary cubes exhaustively. This is simple with code like:
{
long ii, jj, kk;
for (ii=-1; ii<=1; ii++) for (jj=-1; jj<=1; jj++) for (kk=-1; kk<=1; kk++)
AddSamples(int_at[0]+ii,int_at[1]+jj,int_at[2]+kk,
max_order, new_at, F, delta, ID);
}
But this wastes a lot of time working on cubes which are known to be
too far away to matter! So we can use a more complex testing method
that avoids this needless testing of distant cubes. This doubles the
speed of the algorithm. */
36
37. Sample Code
/* Test the central cube for closest point(s). */
AddSamples(int_at[0], int_at[1], int_at[2], max_order, new_at, F, delta, ID);
/* We test if neighbor cubes are even POSSIBLE contributors by examining the
combinations of the sum of the squared distances from the cube's lower
or upper corners.*/
x2=new_at[0]-int_at[0];
y2=new_at[1]-int_at[1];
z2=new_at[2]-int_at[2];
mx2=(1.0-x2)*(1.0-x2);
my2=(1.0-y2)*(1.0-y2);
mz2=(1.0-z2)*(1.0-z2);
x2*=x2;
y2*=y2;
z2*=z2;
/* Test 6 facing neighbors of center cube. These are closest and most
likely to have a close feature point. */
if (x2<F[max_order-1]) AddSamples(int_at[0]-1, int_at[1] , int_at[2] ,
max_order, new_at, F, delta, ID);
if (y2<F[max_order-1]) AddSamples(int_at[0] , int_at[1]-1, int_at[2] ,
max_order, new_at, F, delta, ID);
if (z2<F[max_order-1]) AddSamples(int_at[0] , int_at[1] , int_at[2]-1,
max_order, new_at, F, delta, ID);
if (mx2<F[max_order-1]) AddSamples(int_at[0]+1, int_at[1] , int_at[2] ,
max_order, new_at, F, delta, ID);
if (my2<F[max_order-1]) AddSamples(int_at[0] , int_at[1]+1, int_at[2] ,
max_order, new_at, F, delta, ID);
if (mz2<F[max_order-1]) AddSamples(int_at[0] , int_at[1] , int_at[2]+1,
max_order, new_at, F, delta, ID);
37
40. Sample Code
static void AddSamples(long xi, long yi, long zi, long max_order,
double at[3], double *F,
double (*delta)[3], unsigned long *ID)
{
double dx, dy, dz, fx, fy, fz, d2;
long count, i, j, index;
unsigned long seed, this_id;
/* Each cube has a random number seed based on the cube's ID number.
The seed might be better if it were a nonlinear hash like Perlin uses
for noise but we do very well with this faster simple one.
Our LCG uses Knuth-approved constants for maximal periods. */
seed=702395077*xi + 915488749*yi + 2120969693*zi;
/* How many feature points are in this cube? */
count=Poisson_count[seed>>24]; /* 256 element lookup table. Use MSB */
seed=1402024253*seed+586950981; /* churn the seed with good Knuth LCG */
for (j=0; j<count; j++) /* test and insert each point into our solution */
{
this_id=seed;
seed=1402024253*seed+586950981; /* churn */
/* compute the 0..1 feature point location's XYZ */
fx=(seed+0.5)*(1.0/4294967296.0);
seed=1402024253*seed+586950981; /* churn */
fy=(seed+0.5)*(1.0/4294967296.0);
seed=1402024253*seed+586950981; /* churn */
fz=(seed+0.5)*(1.0/4294967296.0);
seed=1402024253*seed+586950981; /* churn */
/* delta from feature point to sample location */
dx=xi+fx-at[0];
dy=yi+fy-at[1];
dz=zi+fz-at[2];
40
41. Sample Code
/* Distance computation! Lots of interesting variations are
possible here!
Biased "stretched" A*dx*dx+B*dy*dy+C*dz*dz
Manhattan distance fabs(dx)+fabs(dy)+fabs(dz)
Radial Manhattan: A*fabs(dR)+B*fabs(dTheta)+C*dz
Superquadratic: pow(fabs(dx), A) + pow(fabs(dy), B) + pow(fabs(dz),C)
Go ahead and make your own! Remember that you must insure that
new distance function causes large deltas in 3D space to map into
large deltas in your distance function, so our 3D search can find
them! [Alternatively, change the search algorithm for your special
cases.]
*/
d2=dx*dx+dy*dy+dz*dz; /* Euclidian distance, squared */
if (d2<F[max_order-1]) /* Is this point close enough to rememember? */
{
/* Insert the information into the output arrays if it's close enough.
We use an insertion sort. No need for a binary search to find
the appropriate index.. usually we're dealing with order 2,3,4 so
we can just go through the list. If you were computing order 50
(wow!!) you could get a speedup with a binary search in the sorted
F[] list. */
41
42. Sample Code
index=max_order;
while (index>0 && d2<F[index-1]) index--;
/* We insert this new point into slot # <index> */
/* Bump down more distant information to make room for this new point. */
for (i=max_order-1; i-->index;)
{
F[i+1]=F[i];
ID[i+1]=ID[i];
delta[i+1][0]=delta[i][0];
delta[i+1][1]=delta[i][1];
delta[i+1][2]=delta[i][2];
}
/* Insert the new point's information into the list. */
F[index]=d2;
ID[index]=this_id;
delta[index][0]=dx;
delta[index][1]=dy;
delta[index][2]=dz;
}
}
return;
}
42
43. Conclusion
실질적인 texture design 에서 매우 유용함.
Perlin‟s fractal noise 를 보완하며, noise 가 사용되는 어떤 algorithm 에도 „A
Cellular Texture Basis Function‟ 을 적용가능.
시각적인 효과가 늘 똑같지 않고, image 를 더 다양하게 한다는 점에서 가치
가 있음.
43
44. Reference
• Worley, Steven (1996). A cellular texture basis function. Proceedings of the 23rd annual conference on Computer graphics and interactive techniques
• http://www.gutgames.com/post/Cellular-Textures.aspx
• http://www.blackpawn.com/texts/cellular/default.html
• http://codevania.springnote.com/pages/3175790.xhtml
• http://demonstrations.wolfram.com/FractalCellularTextures/
• http://fgiesen.wordpress.com/2010/03/28/how-to-generate-cellular-textures/
• http://hq.scene.ro/blog/read/cellular-texture/
• http://my.opera.com/community/forums/topic.dml?id=1300002
• http://www.gamedev.net/page/resources/_/technical/graphics-programming-and-theory/cellular-textures-the-light-speed-approach-r2668
• http://www.drx.dk/cel.phphttp://cell-auto.com/optimisation/
• http://petewarden.com/notes/archives/2005/05/testing.htm
• http://www.cs.unc.edu/~blloyd/comp238/shader.html
• http://mathworld.wolfram.com/VoronoiDiagram.html
• http://www.snibbe.com/projects/interactive/boundaryfunctions
• http://www.snibbe.com/index.php/projects/interactive/bubbleharp/
• http://gogocj2012.blog.me/50137595052
44