오른쪽으로 속력 $v$로 와서 벽에 충돌한 후 왼쪽으로 속력 $v$로 나가는 경우 충돌 전과 후의 역학적 에너지는 같다. 같은 상황을 오른쪽으로 일정한 속력 $v$로 달리는 사람이 보면 처음 공은 정지해 있다가 충돌 후 왼쪽으로 $2v$의 속력으로 움직이게 된다. 이 관찰자 입장에서 보면 역학적 에너지가 보존이 안되는 것처럼 보인다? 그럴까? 역학적 에너지 보존은 관찰자에 따라 달라지는 개념인가?

 

 
 
728x90
Posted by helloktk
,

사진 속에 포함된 물체를 판별하기 위해서는 보통 이미지를 이진화시켜 binary 이미지를 만들고, conneted component labeling 등을 이용하여 영상에서 겹치지 않는 다수의 물체들을 분리해 내는 과정을 거친다. 이렇게 분리된 각 물체의 외각을 감싸는 convex hull을 찾으려면 먼저 물체의 경계을 추적해서 폴리곤을 만들고, 그 다음 이 폴리곤의 convex hull을 찾는 알고리즘을 적용하면 된다. 이들 폴리곤은 일정한 규칙에 의해서 정렬이 되어 있으므로 convex hull 알고리즘들 중에 chain-hull 이나 Melkman 알고리즘 이용하면 빠르게 결과를 얻을 수 있다.

 

Raster-scan 방식은 물체의 경계점들을 일정하게 정렬된 순서로 읽게 되므로 on-site convex hull 찾기가 가능하게 된다 (chain-hull에서도 동일한 순서가 들어오지만, 전체 점들을 다 얻은 다음에 다시 분류작업을 해야 하므로, 읽은 즉시 바로 convex  hull을 구성하는 알고리즘은 제공하지 못한다). 아래의  코드는 binary raster image를 스캐닝하면서 경계의 convex hull을 찾는 과정을 보여준다.

#define bg     0x00             /* foreground color (black) */ 
#define fg     0xFF             /* background color (white) */
//cross(AB, AC) > 0 if C is lying on the left side of edge(AB);
#define CCW(A,B,C) ((B.x-A.x)*(C.y-A.y)-(B.y-A.y)*(C.x-A.x))

/* find a convex hull of foreground object in a binary image; */ 
/* in some case L[0] = R[0], or L[ll] = R[rr] if first line or last line of object 
** is composed of a single point (수정본:: 배경 체크 부분);
** convex hull이 중복점을 갖는 경우를 허용하지 않을 때는 comment에 따라서 처리해야 한다.
*/ 
int RasterHull(BYTE *image, int w, int h, CPoint H[/* 2xh */]) { 
    CPoint *L = &H[0]; //stack of left-side hull; 
    CPoint *R = &H[h]; //stack of right side hull; 
    int rr = -1, ll = -1, x; 
    CPoint q; 
    for (int y = 0 ; y < h; y++) {
        BYTE *scanline = &image[y*w]
        for (x = 0; x < w; x++)
            if (scanline[x] != bg) break; 
        if (x == w) continue; 
        q = CPoint(x, y);
        while (ll > 0) {
            // q가 이전 edge의 오른쪽이면 convex hull의 꼭지점이 됨;
            if (CCW(L[ll - 1], L[ll], q) < 0) break; 
            else ll--; 
        } 
        L[++ll] = q; 
        for (x = w; x-- > 0;) //x=-1 never occurs; 
            if (scanline[x] != bg) break; 
        // 행에 싱글 픽셀 있는 경우 왼쪽과 오른쪽이 점이 중복이 되는 경우가
        // 생긴다. 이 중복을 없애고 싶으면
        if (x <= q.x) continue ;
        q = CPoint(x, y); 
        while (rr > 0) { 
            // q가 이전 edge의 왼편에 있으면 convex hull의 꼭지점이 됨;
            if (CCW(R[rr-1], R[rr], q) > 0) break; 
            else rr--; 
        } 
        R[++rr] = q; 
    } 
    // 왼쪽 처음에 점과 오른쪽 처음 점유 중복될 가능성이 있다(싱글 픽셀)
    // 왼쪽 마지막 점과 오른쪽 마지막 점이 중복이 되는 경우도 있다(싱글 픽셀) 
    // convex hull에서 중복점을 완전히 제외하고 싶으면 이를 체크하는 부분이 필요;
    // copy right hull to H;
    int n = ll + 1; // # of pts within left hull;
    // remove bottom degeneracy; 
    if (H[ll] == R[rr]) rr--;
    for (int j = rr; j >= 0; j--) H[n++] = R[j];//right hull; 
    //remove top degeneracy;
    if (n > 1 && H[0] == H[n - 1]) n--;
    return n; 
}

위 함수는 픽셀 값이 bg가 아닌 것은 모두 전경으로 처리하도록 작성하였다. 만약 connected component를 구한 상태에서 특정 component의 convex hull을 구하고자 하는 경우에는 if-문의 조건을 image[y * w + x] == index로 바꾸어야 한다 (여기서 index는 connected component label이다. 그리고 labeling 이미지는 일반적으로 정수 이미지이므로 그에 맞게 수정을 해야 한다.) 

 

data matrix 코드를 포함하는 이미지에서 코드 영역을 찾기 위해서는 우선 이진화를 시켜야 한다. 다음으로 이진 이미지에서 connected component labeling을 해서 사이즈가 작은 blob을 제거하면 거의 코드 영역만 남길 수 있다. 그림은 코드 영역(노란색)을 감싸는 convex hull(붉은색 라인)을 찾은 것을 보여준다.

네이버 블로그에서 이전

Convex hull 알고리즘은 아래에서 찾을 수 있다.

 
 
 
 
 
728x90
Posted by helloktk
,

$$ I =  \text{Pr}\int_{-1}^1 \sqrt{ \frac{1+x}{1-x}} \frac{1}{(2-x)x} dx$$

복소함수 

$$f(z)=\left(\frac{1+z}{1-z} \right)^{1/2}\frac{1}{(2-z)z}$$

의 contour $\Gamma$에 대한 적분을 고려한다. $z=\pm1$이 branch point이고, $z=0,1$은 simple pole이다. cut line은 그림처럼 잡고, 위상은 $z=\pm 1$에서 $0\rightarrow 2\pi $로 선택한다.

residue 정리에 의해서 

$$ \int_\Gamma f(z) dz = 2i\pi \text{Res}(z=2) = \sqrt{3} \pi $$

$C_1$: $$\int_{C_1} f(z)dz = O(\sqrt{\epsilon}\epsilon)\rightarrow 0$$  

$C_5$: $$\int_{C_5} f(z)dz = O(\sqrt{\epsilon})\rightarrow 0$$  

$C_3$: $z=\epsilon e^{i \theta}~(\theta: \pi \rightarrow 2\pi)$, $z+1= e^{2i\pi}$, $z-1=e^{i\pi}$이므로

$$\int_{C_3} f(z) dz = \frac{e^{i\pi}}{e^{i\pi/2}e^{i\pi/2} } \int_{\pi}^{2\pi} \frac{i \epsilon e^{i\theta}}{2\epsilon e^{i \theta}} d\theta = i \frac{\pi}{2}.$$ 

$C_7$:  $z=e^{i\theta}~(\theta:0 \rightarrow \pi)$, $z+1 =e^{i 0}$, $z-1=e^{i \pi}$이므로

$$\int_{C_7} f(z) dz = \frac{1}{e^{i\pi/2}  e^{i\pi/2}}\int_0^\pi \frac{i\epsilon e^{i \theta}}{2\epsilon e^{i \theta}} d\theta =-i \frac{\pi}{2} $$

$C_2 + C_4$: $z+1= (x+1) e^{2i \pi }~(x: -1 \rightarrow +1)$, $z-1=(1-x)e^{i\pi}$이므로

$$\int_{C_2 + C_7} f(z)dz = \frac{e^{i\pi}}{e^{i\pi/2}e^{i\pi/2}}\int_{-1}^{1} \sqrt{\frac{1+x}{1-x}}\frac{dx}{(2-x)x}=I.$$

$C_6 + C_8$: $z+1= (x+1) e^{i 0}~(x: +1 \rightarrow -1)$, $z-1=(1-x)e^{i\pi}$이므로

$$\int_{C_2 + C_7} f(z)dz = \frac{1}{e^{i\pi/2}  e^{i\pi/2}}\int_{1}^{-1} \sqrt{\frac{1+x}{1-x}}\frac{dx}{(2-x)x}=I.$$

$C_\infty$: $$ \int_{C_\infty} f(z)dz = O( 1/R) \rightarrow0.$$

이 결과를 모두 정리하면,

$$ I =\text{Pr} \int_{-1}^1 \sqrt{\frac{1+x }{1-x}} \frac{dx}{(2-x)x}=\frac{\sqrt{3}}{2}\pi.$$

 

728x90

'Mathematics' 카테고리의 다른 글

Catenary  (0) 2022.01.14
Integration along a branch cut-013  (0) 2021.12.22
Integration along a branch cut-011  (0) 2021.01.04
Integration along a branch cut-010  (0) 2021.01.04
Integration along a branch cut-009  (0) 2021.01.03
Posted by helloktk
,

$$I= \int_c^\infty \frac{dx}{x^2 - 1} \quad(c > 1)$$

복소함수 $f(z)= \frac{\log(z-c) }{ z^2 -1}$을 그림의 contour을 따라 적분을 한다. $z=c, \infty$가 branch point이므로 $x>c$인 $x$축을 따라 cut line을 설정한다. 또, $z=\pm 1$은 simple pole이다.

$C_2$:   $$ \int f(z) dz = O( \log(\epsilon) \epsilon ) \rightarrow 0.$$$C_1$: $z-c = (x-c) e^{i 2\pi}~(x: \infty \rightarrow c)$이므로,$$ \int_{C_1} f(z) dz = \int_\infty ^c \frac{1}{x^2 -1} ( \log (x-c) + 2i \pi) dx $$$C_3$: $z-c= (x-c) e^{i 0} ~(x: c \rightarrow \infty)$이므로,$$ \int_{C_3} f(z) dz = \int_c^\infty \frac{1}{x^2 - 1} \log(x-c) dx $$ $C_\infty$: $$\int f(z) dz  = O( \log(R) /R ) \rightarrow   0$$ 따라서, $$\int_{\Gamma}  f(z) dz= 2 i \pi  [\text{Res}(z=1) + \text{Res}(z=-1)] =2i \pi \left( \frac{\log (c-1)}{2} - \frac{ \log(c+1)}{2}\right)$$

정리하면,

$$\int_c^\infty \frac{dx}{x^2 -1} = \log\sqrt{\frac{c+1}{c-1}}$$

물론 $\frac{1}{x^2-1} = \frac{1}{2} (\frac{1}{x-1} - \frac{1}{x+1})$임을 이용하는 것이 더 쉽다.

 

728x90

'Mathematics' 카테고리의 다른 글

Integration along a branch cut-013  (0) 2021.12.22
Integration along a branch cut-012  (0) 2021.01.05
Integration along a branch cut-010  (0) 2021.01.04
Integration along a branch cut-009  (0) 2021.01.03
Integration along branch cuts-008  (0) 2021.01.03
Posted by helloktk
,

$$ I = \int_{-1}^1 \sqrt{1-x^2} dx$$

복소함수를 $f(z)= \sqrt{1+z^2}$으로 선택하면, $z=\pm i$가 branch point이므로 cut line을 $z=-i$와 $z=+i$을 잇는 선분으로 잡는다. $z=\pm i$ 근방에서 위상은 각각 $-\pi/2\rightarrow 3\pi/2$, $0\rightarrow 2\pi$ 선택하면 된다. $z=\infty$에서 residue가 있으므로 그림과 같은 contour $(\Gamma= C_1 + C_2 + C_\epsilon +C_{\epsilon'} + C_\infty)$에서 

$C_\epsilon(z=i), C_{\epsilon'}(z=-i)$: $$ \int f(z) dz = O(\sqrt{\epsilon} \epsilon) \rightarrow  0.$$

$C_1$: $z- i = (1-x)e^{-i \pi/2}~ (x:-1 \rightarrow 1)$, $z+i = (1+x)e^{i\pi/2}$이므로

$$\int_{C_1} f(z)dz  = \int_{-1}^{1}\sqrt{1-x^2} d( e^{i \pi/2} x) = i I$$

$C_2$: $z-i = (1-x)e^{i 3\pi/2}~(x:1\rightarrow -1)$, $z+i=(1+x)e^{i \pi/2}$이므로

$$\int_{C_2} f(z)dz = \int_{1}^{-1} \sqrt{1-x^2} e^{i\pi}  d (e^{i\pi/2}x) = i I$$

무한대에서 residue를 결정하기 위해서 $z=1/t$로 치환하면 ($z=Re^{i\theta}~(\theta:2\pi\rightarrow 0)$이면 $t= \delta e^{-i\theta}, ~\delta = 1/R$)

$$\int_{C_\infty} f(z) dz = \int_{C_\delta }  \sqrt{1 + \frac{1}{t^2} } \frac{dt}{-t^2}=\int_{C_\delta } \frac{1}{t}(1 + \frac{1}{2}t^2 + ...) \frac{dt}{-t^2}\\=\int_{C_\delta} \frac{dt}{-2t}  =\int_{2\pi}^{0} \frac{ - e^{- i \theta} d \theta }{ - 2e^{-i \theta}} =- i\pi $$

따라서 $\int_\Gamma f(z) dz = 0$에서 

$$ I = \int_{-1}^1 \sqrt{1-x^2} dx  =\frac{\pi}{2}.$$

이 결과는 $x=\sin \theta$의 치환적분을 이용하면 더 쉽게 구할 수 있다.

728x90

'Mathematics' 카테고리의 다른 글

Integration along a branch cut-012  (0) 2021.01.05
Integration along a branch cut-011  (0) 2021.01.04
Integration along a branch cut-009  (0) 2021.01.03
Integration along branch cuts-008  (0) 2021.01.03
Integration along a branch cut-007  (1) 2020.12.31
Posted by helloktk
,