1 / 33

영상처리 실습 #4

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

guy-shaw
Download Presentation

영상처리 실습 #4

An Image/Link below is provided (as is) to download presentation Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author. Content is provided to you AS IS for your information and personal use only. Download presentation by click this link. While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server. During download, if you can't get a presentation, the file might be deleted by the publisher.

E N D

Presentation Transcript


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

  2. Histogram 대화상자만들기 2 3 1

  3. Histogram 대화상자만들기 1 Click 2

  4. Histogram 대화상자만들기

  5. Histogram 대화상자만들기 Drag

  6. Histogram 대화상자만들기 1 2 Drag Click

  7. Histogram 대화상자만들기 3 1 2 Click

  8. Histogram 대화상자만들기 1 2 Click

  9. Histogram 대화상자만들기 2 1

  10. Histogram 대화상자만들기 2 1

  11. Histogram 대화상자만들기 1 2 1 3

  12. Histogram 대화상자만들기 4 1 2 m_ctrlHistogram 3

  13. Histogram 대화상자만들기

  14. Histogram 대화상자만들기 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, 추가 Double Click unsigned intm_pHistogram[256]; unsigned intm_nMaxHistogram;

  17. Histogram 대화상자만들기

  18. Histogram 대화상자만들기 1 4 2 5 3

  19. Histogram 대화상자만들기 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 대화상자만들기 3 2 4 5 1

  21. Histogram 대화상자만들기 1 2 Click

  22. Histogram 대화상자만들기 1 4 3 5 2

  23. Histogram 대화상자만들기 CDlgHistogramdlg(*m_pImage); dlg.DoModal();

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

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

  26. Histogram 대화상자 실행

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

  28. Histogram Equalization 2 1 4 3

  29. Histogram Equalization

  30. Histogram Equalization 총 픽셀 수

  31. Histogram Equalization int x, y; int i, nTemp; double sum, pixel_Number; /* variable used to increment sum of hist */ double histogram[256]; /* image histogram */ double sum_hist[256]; /* sum of histogram elements */ double scale_factor; /* normalized scale factor */ /* clear histogram to 0 */ for(i=0; i<256; i++) histogram[i]=0; /* calculate histogram */ for(x=0; x<m_pImage->GetHeight(); x++) { for(y=0; y<m_pImage->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<m_pImage->GetHeight(); y++) { for(x=0; x<m_pImage->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 원본 영상 결과 영상

More Related