1 / 27

Chap.2 Point processes

Chap.2 Point processes. Inverting : f(x,y) <- 255-f(x,y) arithmetic operations adding, subtracting, dividing, and multiplexing pixels by constant When values become greater than 255, they are set to 255 f(x,y) <- f(x,y) + 10 f(x,y) <- min(255, max(f(x,y), 0)) fig. 2.1, 2,2. Histogram.

pippa
Télécharger la présentation

Chap.2 Point processes

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. Chap.2 Point processes • Inverting : f(x,y) <- 255-f(x,y) • arithmetic operations • adding, subtracting, dividing, and multiplexing pixels by constant • When values become greater than 255, they are set to 255 • f(x,y) <- f(x,y) + 10 • f(x,y) <- min(255, max(f(x,y), 0)) • fig. 2.1, 2,2 Practical Image Processing

  2. Histogram • view intensity profile of an image • give information on contrast & overall intensity distribution of image • used to determine range of pixels for objects or background : thresholding Practical Image Processing

  3. Invert, Addition ? f(x,y) <- f(x,y)+50 f(x,y) <- 255-f(x,y) Practical Image Processing

  4. XOR operation • bit operation • generate binary image where value of 0 is assigned to pixels whose value were the same as some constant mask • gray value of a pixel x = 1011, mask y = 0101 • x XOR y = 1110, (x XOR y) XOR y = 1011 • y XOR y = 0000 • often used to generate cursor Practical Image Processing

  5. Look-up Table • 점 처리는 명암값을 다른 명암값으로 변경하는 것임 Look-up Table(1차원 배열)을 사용해서 빠르게 수행 • 입력 : 픽셀의 명암값  배열의 인덱스가 됨 • 출력 : 그 픽셀의 변환된 명암값  배열의 값 • 각 픽셀에 대해 처리하기 전에 미리 LUT 만듦 • 각 픽셀은 단지 한번의 메모리 참조만 필요  매우 빠름 Practical Image Processing

  6. Histogram equalization(히스토그램 평활화) • 자동으로 영상의 밝기 조정 (비교 : 히스트그램 스트레칭) • 히스토그램을 좁히거나 넓혀 가능하면 모든 명암값에 대해 균일한 히스토그램을 얻고자 함 • 방법 • 히스토그램을 계산 (compute histogram) • 히스토그램의 “정규화된 합계”를 구함 (calculate normalized sum of histogram) • “정규화된 합계” 를 Look up table로 사용해서 각 픽셀의 명암값 변환 (transform input image to output image) • 영상이 어두워서 구별이 잘 안되던 부분이 향상됨 • 포토샵 : 이미지>조정>자동레벨 Practical Image Processing

  7. Practical Image Processing

  8. Practical Image Processing

  9. Image : 4 4 3 3 4 4 3 3 4 1 2 3 0 1 2 3 Max_level =7 # pixels =16 Normalized sum(정규화된 합계): sum * max_level / # pixels Ex) for level=2, ns = 5 * 7 / 16 = 2.18 Practical Image Processing

  10. 히스토그램 평활화 : 프로그램 (교과서 64쪽) float scale_factor = (float)255.0/(m_nHeight * m_nWidth); for(int i=0 ; i<256 ; i++) hist[i] = 0; // 전체의 픽셀의 값으로 찾아가서 그 수가 나오면 1씩 증가 for(int j=1;j<m_nHeight;j++) for(i=1;i<m_nWidth; i++) // 배열 hist[]에 hist[image_in[j][i]] += 1; // 히스토그램이 저장됨 //정규화된 합계(normalized sum of histogram) 을 구함 for(i=0; i<256;i++) { sum += hist[i]; sum_hist[i] = unsigned int((sum * scale_factor) + 0.5); } //정규화된 합계를 LUT로 해서 영상을 변환함. for(j=0;j<m_nHeight-1;j++) for(i=0;i<m_nWidth-1; i++) image_out[j][i] = sum_hist[image_in[j][i]]; Practical Image Processing

  11. Histogram specification(히스토그램 명세화) • 히스트그램 평활화 : 처리된 영상의 히스트그램이 가능한 균일한 분포를 가지도록  결과 히스트그램 : 균일한 값 (uniform distribution) : 고정된 값.  사용자가 정해 줄 필요 없음 • 히스토그램 명세화 : 명암값의 특정부분(어두운 부분, 혹은 밝은 부분)을 더 밝게 혹은 어둡게 하고자 함  결과 히스트그램을 사용자가 제공 • 기술적으로는 히스트그램 평활화와 역 평활화의 두 단계를 거침 : 그렇지만 Look up table 처리가 됨 • histogram equalization + inverse histogram equalization Practical Image Processing

  12. 역평활화 : 다음 슬라이드 평활화 : 앞에서 설명 Practical Image Processing

  13. 원하는 히스토그램의 normalized sum 역변환표(inverse Look Up Table) 2와 가장 가까운 값의 index Inverse Histogram Equalization Practical Image Processing

  14. 히스토그램 명세화 : 프로그램 (교과서 68쪽 참조) void histogram_specificationbuffer : input image (1D) number_of_pixels : desired_histogram : 1D /* clear histogram to 0 */ for (i=0; i<256; i++) histogram[i]=0; /* calculate histogram */ for (i=0; i<number_of_pixels; i++) histogram[buffer[i]]++; /* calculate normalized sum of hist */ sum=0.0; scale_factor=255.0/number_of_pixels; for (i=0; I<256; i++) { sum += histogram[i]; sum_hist[i] = sum * scale_factor; } /* transform image using new sum_hist as a LUT */ for (i=0; i< number_of_pixels; i++) buffer[i]=(unsigned char) sum_hist[buffer[i]]; /* calculate normalized sum of hist for desired histogram */ sum=0.0; scale_factor = 255.0 / number_of_pixels; for (i=0; i<256; i++) { sum += desired_histogram[i]; sum_hist[i] = sum * scale_factor; } /* generate the inversed transform */ for (i=0; i< 256; i++) { difference = fabs(i-sum_hist[0]); min = 0; for (j=0; i<256; j++) { if (fabs(i-sum_hist[j]) < differnece { difference = fabs(i-sum_hist[j]); min = j; } inv_hist[i] = (unsigend_char) min; } /* transform final image using inv_hist */ for (i=0; i < number_of_pixels; i++) buffer[i] = inv_hist[buffer[i]]; 평활화 역평활화 Practical Image Processing

  15. 콘트라스트 스트레칭(Contrast stretching)(히스토그램 스트레칭, 히스토그램 확장) High Contrast Low Contrast Practical Image Processing

  16. 히스토그램을 선형적(linear)으로 변환 입력영상 : Low=50, high=200 출력영상 : Low=0, high=255 Practical Image Processing

  17. 콘트라스트 스트레칭(Contrast stretching) 입력영상 범위 : (fmin, famx) 출력영상 범위 : (gmin, gamx) 입력영상의 명암값 f  출력 영상의 명암값 g 일반적인 경우 출력영상 범위가 (0, 255)인 경우 입력영상 범위 설정 방법 1) 사용자 지정 2) 입력 영상에서 최대 , 최소값 구함 (basic method) 3) 입력 영상의 최대, 최소값에서 각각 p% 버림 (p-tile method (ends-in search)) Practical Image Processing

  18. 히스토그램 확장 : basic method (교과서 72쪽 참조) void auto_histogram_stretchsource : input image (1D) /* compute historgram */ // histogram[0..255]에 저장 /*히스토그램에서 최대(high), 최소(low) 구함 */ for (i=255; i>=0; i--) if (histogram[i]) { high = i; break; } for (i=0; i<255; i++) if (histogram[i]) { low = i; break; } /* LUT 만듦 */ for (i=0; i<low; i++) LUT[i] = 0; for (i=255; i>high; i--) LUT[i]=0; scale = 255.0 / (high-low); for (i=low; i<=high; i++) LUT[i] = (unsigned char) ((i-low)*scale + 0.5); /* LUT를 이용하여 점처리. 입력 영상에 엎어씀 */ for (i=0; i < number_of_pixels; i++) source[i] = LUT[source[i]]; Practical Image Processing

  19. 히스토그램 확장 : p-tile method (교과서 74쪽 참조) void auto_histogram_stretchsource : input image (1D) low : 명암값 작은 쪽 low%는 0으로 high : 명암값 큰쪽 high%는 0으로 /* compute historgram */ // hist[0..255]에 저장 /*입력 low, high에서 최대, 최소 명암값 (highthres, lowthres) 구함 */ sum = 0; for (i=0; i<255; i++) { sum += hist[i]; if (sum * 100 / n_pixels >= low) { lowthres = i; break; } } sum = 0; for (i=255; i<=0; i--) { sum += hist[i]; if (sum * 100 / n_pixels <= high) { highthres = i; break; } } /* LUT 만듦 */ for (i=0; i<lowthres; i++) LUT[i] = 0; for (i=255; i>highthres; i--) LUT[i]=0; scale = 255.0 / (highthres-lowthres); for (i=lowthres; i<=highthres; i++) LUT[i] = (unsigned char) ((i-lowthres)*scale + 0.5); /* LUT를 이용하여 점처리. 입력 영상에 엎어씀 */ for (i=0; i < number_of_pixels; i++) source[i] = LUT[source[i]]; Practical Image Processing

  20. 명암변환(Histogram transformation) • 입력 영상의 명암값  출력 영상의 명암값으로 변환 : 변환 함수를 미리 지정함 • 변환함수가 바로 LUT 가 됨 : 프로그램 간단 • 변환 함수에 따라 다양한 효과 (포토샵에서 Image>Adjust>Curves 참조) • null transform : g = f • negative transform : g = 255-f (fig. 2.15) Practical Image Processing

  21. Practical Image Processing

  22. Gamma correction :센서, 디스플레이, 필름등의 비선형 특성 보상 Sample input Monitor output Gamma Correction Gamma corrected input Monitor output Practical Image Processing

  23. Gamma Correction: 프로그램 void gamman_correctionsource : input image (1D)gamma : 감마 값 (사용자 지정) /* LUT 만듦 */ for (i=0; i<256; i++) LUT[i] = (unsigned char) (pow(i/255.0, gamma)*255.0 + 0.5); /* LUT를 이용하여 점처리. 입력 영상에 엎어씀 */ for (i=0; i < number_of_pixels; i++) source[i] = LUT[source[i]]; Practical Image Processing

  24. contrast stretching : fig. 2.17 a, b) • produce brighter image • contrast compression : fig. 2. 17 c, d) • produce darker image • posterizing : fig. 2. 18 a, b) • reduce number of gray-levels • thresholding : fig. 2. 18 c, d) • produce binary image Practical Image Processing

  25. Posterizing (6레벨) for (i=0; i<256; i++) { LUT[i] = (i + level-1) / n_level ; LUT[i] = LUT[i] * n_level;} Practical Image Processing

  26. bit clipping : fig. 2. 19 • set some MSB to 0 • transfer function : fig. 2. 19 a) • 등 명암 윤곽화 : 그림 2-21 a, b) • 특정 gray level을 흰색/검정색으로 • 범위 강조 : 그림 2-22 a, b) • 특정 gray level 범위를 흰색/검정색으로 • Solarizing : fig 2-23 a, b) • parabola transform : fig 2-24 Practical Image Processing

  27. Homework # 1 : 4/10 다음 각 연산을 프로그램 하고 그 결과를 보여라. • Histogram equalization • Histogram stretching (basic method) • Gamma correction (gamma = 1.5) • Posterizing (4 levels) 결과물 (입력영상은 자유롭게 선택): 입력영상, 결과 영상 (히스토그램 포함) 프로그램(해당함수만 인쇄) Practical Image Processing

More Related