Presentation is loading. Please wait.

Presentation is loading. Please wait.

영상처리 실습 #4 Histogram 연산 [ Histogram 대화상자 만들기 ]. Histogram 대화상자 만들기.

Similar presentations


Presentation on theme: "영상처리 실습 #4 Histogram 연산 [ Histogram 대화상자 만들기 ]. Histogram 대화상자 만들기."— Presentation transcript:

1 영상처리 실습 #4 Histogram 연산 [ Histogram 대화상자 만들기 ]

2 Histogram 대화상자 만들기

3 Click

4 Histogram 대화상자 만들기

5 Drag

6 Histogram 대화상자 만들기 Drag Click

7 Histogram 대화상자 만들기 Click

8 Histogram 대화상자 만들기 Click

9 Histogram 대화상자 만들기

10

11

12 m_ctrlHistogram

13 Histogram 대화상자 만들기

14 Double Click

15 Histogram 대화상자 만들기 CxImage img, unsigned int x, y; m_nMaxHistogram = 0; // 히스토그램 초기화 for (x=0; x<256; x++) m_pHistogram[x] = 0; // 히스토그램 구하기 for (y=0; y<img.GetHeight(); y++) for (x=0; x<img.GetWidth(); x++) m_pHistogram[img.GetPixelGray(x,y)]++; // 히스토그램 최대값 구하기 for (x=0; x<256; x++) if (m_pHistogram[x] > m_nMaxHistogram) m_nMaxHistogram = m_pHistogram[x];

16 Histogram 대화상자 만들기 CxImage img, 추가 unsigned intm_pHistogram[256]; unsigned intm_nMaxHistogram; Double Click

17 Histogram 대화상자 만들기

18

19 CRect win_rect; // 0 점 설정 : 픽쳐컨트롤 왼쪽 아래 m_ctrlHistogram.GetWindowRect(&win_rect); ScreenToClient(&win_rect); dc.SetViewportOrg(win_rect.left, win_rect.bottom-1); // 좌표 설정 dc.SetMapMode(MM_ANISOTROPIC); dc.SetWindowExt(256, m_nMaxHistogram+1); dc.SetViewportExt(win_rect.Width(), win_rect.Height()); // 히스토그램 그리기 for (int i=0; i<256; i++) { dc.MoveTo(i,0); dc.LineTo(i, -m_pHistogram[i]); }

20 Histogram 대화상자 만들기

21 Click

22 Histogram 대화상자 만들기

23 CDlgHistogram dlg(*m_pImage); dlg.DoModal();

24 Histogram 대화상자 만들기 맨위로 스크롤

25 Histogram 대화상자 만들기 #include "DlgHistogram.h"

26 Histogram 대화상자 실행

27 영상처리 실습 #4 Histogram 연산 [ Histogram Equalization ]

28 Histogram Equalization

29

30 총 픽셀 수

31 Histogram Equalization intx, y; inti, nTemp; doublesum, pixel_Number;/* variable used to increment sum of hist */ doublehistogram[256];/* image histogram */ doublesum_hist[256];/* sum of histogram elements */ doublescale_factor;/* normalized scale factor */ /* clear histogram to 0 */ for(i=0; i<256; i++) histogram[i]=0; /* calculate histogram */ for(x=0; x GetHeight(); x++) { for(y=0; y GetWidth(); y++) { histogram[m_pImage->GetPixelGray(x,y)]++; }

32 Histogram Equalization /* calculate normalized sum of hist */ sum = 0; pixel_Number = m_pImage->GetHeight() * m_pImage->GetWidth(); scale_factor = 255.0 /pixel_Number; for(i=0; i<256; i++) { sum += histogram[i]; sum_hist[i] = (sum * scale_factor) + 0.5; } /* transform image using new sum_hist as a LUT */ for(y=0; y GetHeight(); y++) { for(x=0; x GetWidth(); x++) { nTemp = sum_hist[m_pImage->GetPixelGray(x,y)]; m_pImage->SetPixelColor(x, y, RGB(nTemp,nTemp,nTemp)); } UpdateAllViews(NULL);

33 Histogram Equalization 결과 영상 원본 영상결과 영상 Histogram Equalization


Download ppt "영상처리 실습 #4 Histogram 연산 [ Histogram 대화상자 만들기 ]. Histogram 대화상자 만들기."

Similar presentations


Ads by Google