[CE] Subdivision using DFS

2023. 5. 24. 14:32·Computer/CE
728x90
728x90

이 페이지는 Recursive subdivision의 동작을 간단한 binary image를 대상으로 보여준다.

 

사용한 image는 The Secret Life of Programs 의 5장에 나오는 Figure 5-3: A crude simley face를 사용하면서 단지 좌표를 일반적인 image에서 사용하는대로 top-left pixel을 0,0으로 처리했다.

 

최종으로 나오는 Tree의 leaf node의 갯수는 40개로 원래의 64개보다 줄어들며, 일종의 압축된 representation을 형성한다.

 

Pseudo code 및 동작

이 Recursive subdivision 예제의 Pseudo code (Recursive Functon이 사용됨)는 다음과 같다.

function subdivide(x, y, size)
{
    IF size != 1 AND "the pixels in the square are not all the same color" {
        half = size / 2
        subdivide(x, y, half)                # upper left quadrant
        subdivide(x, y + half, half)         # lower left quadrant
        subdivide(x + half, y + half, half)  # lower right quadrant
        subdivide(x + half, y, half)         # upper right quadrant                        
    }
    ELSE {
        save the information about the square
    }
}

동작은 다음과 같음.

위의 image subdivision은 Depth-First-Search로 동작하며, stack과 recursive call을 통해 쉽게 구현할 수 있음.

Stack

Stack과 stack frame은 다음과 같음.

  • recursive call이 발생할 때마다, 귀환할 주소와 해당 call의 parameter에 할당된 argument를 stack에 집어넣음.

Stack Frame : stack에 저장된 데이터들의 모음 을 Stack Frame이라고 부르고 다음으로 구성됨.

  • function(=subroutine)으로 전달하는 parameters (이들의 값은 호출 시 사용된 argument임)
  • local variables (C언어)
  • 복귀 주소

다음 url들을 같이 보면 도움이 됨.

2023.05.23 - [Computer/CE] - [CE] Stack

 

[CE] Stack

Stack은 자료구조의 하나로서 FILO (First-In-Last-Out, LIFO 와 같은 의미.)로 동작함. 많은 경우 접시 쌓기를 예로 사용하여 First-In-Last-Out (FILO), Last-In-First-Out (LIFO)를 설명한다. Stack에 저장되는 데이터 단

dsaint31.tistory.com

2023.05.24 - [Programming] - [Python] recursive call : Fibonacci Sequence

 

[Python] recursive call : Fibonacci Sequence

Recursive call의 경우, 특정 함수가 내부에서 자기자신을 다시 호출하는 것을 가르킴. 다음과 같은 재귀적인 수식을 있는 그대로 작성하게 해준다는 장점은 있지만, 속도의 측면에서는 그리 환영받

dsaint31.tistory.com

 

2023.02.20 - [Computer/CE] - [CE] Tree vs. Graph

 

[CE] Tree vs. Graph

Graph node와 node를 연결하는 edge로 구성된 자료구조. object들의 network를 모델링하는데 주로 사용됨. Tree Directed Acyclic Graph 에서, graph 내의 모든 node와 path가 존재하는 root node라는 것이 1개 있는 자료

dsaint31.tistory.com

https://nostarch.com/foundationsofcomp

 

The Secret Life of Programs

The Secret Life of Programs is a primer on the underlying technologies that allow computer programs to work.

nostarch.com

 

'Computer > CE' 카테고리의 다른 글

[CE] Round-off Error 예제  (1) 2024.02.17
[CE] Classless Inter-Domain Routing 표기법: IP Address  (0) 2024.02.07
[CE] Stack  (0) 2023.05.23
[Linux] Signal : SIGINT  (0) 2023.04.09
[CE] URL, URI and UNC  (1) 2023.04.09
'Computer/CE' 카테고리의 다른 글
  • [CE] Round-off Error 예제
  • [CE] Classless Inter-Domain Routing 표기법: IP Address
  • [CE] Stack
  • [Linux] Signal : SIGINT
dsaint31x
dsaint31x
    반응형
    250x250
  • dsaint31x
    Dsaint31's blog
    dsaint31x
  • 전체
    오늘
    어제
    • 분류 전체보기 (748)
      • Private Life (13)
      • Programming (56)
        • DIP (112)
        • ML (26)
      • Computer (119)
        • CE (53)
        • ETC (33)
        • CUDA (3)
        • Blog, Markdown, Latex (4)
        • Linux (9)
      • ... (351)
        • Signals and Systems (103)
        • Math (172)
        • Linear Algebra (33)
        • Physics (42)
        • 인성세미나 (1)
      • 정리필요. (54)
        • 의료기기의 이해 (6)
        • PET, MRI and so on. (1)
        • PET Study 2009 (1)
        • 방사선 장해방호 (4)
        • 방사선 생물학 (3)
        • 방사선 계측 (9)
        • 기타 방사능관련 (3)
        • 고시 (9)
        • 정리 (18)
      • RI (0)
      • 원자력,방사능 관련법 (2)
  • 블로그 메뉴

    • Math
    • Programming
    • SS
    • DIP
  • 링크

    • Convex Optimization For All
  • 공지사항

    • Test
    • PET Study 2009
    • 기타 방사능관련.
  • 인기 글

  • 태그

    linear algebra
    Python
    opencv
    Term
    fourier transform
    인허가제도
    Optimization
    signal_and_system
    Convolution
    SIGNAL
    Programming
    SS
    DIP
    Probability
    signals_and_systems
    math
    cv2
    numpy
    Vector
    function
  • 최근 댓글

  • 최근 글

  • hELLO· Designed By정상우.v4.10.3
dsaint31x
[CE] Subdivision using DFS
상단으로

티스토리툴바