• 검색 결과가 없습니다.

Arithmetic 연산 및 Gray-level 변환을 사용한 영상 개선

N/A
N/A
Protected

Academic year: 2022

Share "Arithmetic 연산 및 Gray-level 변환을 사용한 영상 개선"

Copied!
29
0
0

로드 중.... (전체 텍스트 보기)

전체 글

(1)

Arithmetic 연산 및 Gray-level 변환을 사용한 영상 개선

김성영교수 금오공과대학교 컴퓨터공학과

(2)

2

학습 내용

단일 픽셀 처리(point pixel processing) 개요

Scalar and Image arithmetic operations

Gray-level transformations

(3)

point pixel processing

이웃 픽셀과는 독립적으로 입력 영상의 각 픽셀 값을 변환

한 후 결과 영상의 동일한 위치에 출력하는 연산

f(x, y)

(4)

444

Arithmetic operations

Gray-level transformations Histogram modifications

techniques

(5)

Improving image contrast and brightness

Image contrast: a measure of the distribution

and range of the gray levels

the difference between the brightness and darkest pixel values, and

how the intermediate values are arranged

Image brightness: the overall average or mean

objective

(6)

666

Contrast & Brightness

(7)

연산 구 현

덧셈 OutImage[x][y] = InImage[x][y]+C1 뺄셈 OutImage[x][y] = InImage[x][y]-C2 곱셈 OutImage[x][y] = InImage[x][y]*C3 나눗셈 OutImage[x][y] = InImage[x][y]/C4

if( OutImage[x][y] > 255 ) OutImage[x][y] = 255;

if( OutImage[x][y] < 0 ) OutImage[x][y] = 0;

클리핑(clipping) 처리

Scalar arithmetic operation

(8)

888

덧셈 연산(+50) 뺄셈 연산(-50)

(9)

곱셈 연산(*1.2) 나눗셈 연산(/1.2)

(10)

1010 10

void scalarAdd( Mat &image, Mat &result, int value ) {

int numOfLines = image.rows; // number of lines in the image int numOfPixels = image.cols; // number of pixels per a line

result.create( image.rows, image.cols, image.type() );

for( int r=0; r<numOfLines; r++ ) {

const uchar *data_in = image.ptr<uchar>( r );

uchar *data_out = result.ptr<uchar>( r );

for( int c=0; c<numOfPixels; c++ ) {

data_out[c] = saturate_cast<uchar>( data_in[c] + value );

} } }

(11)

cv::add( image, cv::Scalar(value), result ) result = image + value

cv::subtract( image, cv::Scalar(value), result ) result = image - value

cv::multiply( image, cv::Scalar(value), result ) result = image * value

cv::divide( image, cv::Scalar(value), result )

result = image / value

(12)

12

+

Image arithmetic operation

(13)

void imageAdd( Mat &image1, Mat &image2, Mat &result ) {

int numOfLines = image1.rows; // number of lines in the image int numOfPixels = image1.cols; // number of pixels per a line

result.create( image1.rows, image1.cols, image1.type() );

for( int r=0; r<numOfLines; r++ ) {

const uchar *data1_in = image1.ptr<uchar>( r );

const uchar *data2_in = image2.ptr<uchar>( r );

uchar *data_out = result.ptr<uchar>( r );

for( int c=0; c<numOfPixels; c++ ) {

data_out[c] = saturate_cast<uchar>( data1_in[c] + data2_in[c] );

} }

(14)

1414 14

-

subtract diff

(15)

void imageDiff( Mat &image1, Mat &image2, Mat &result ) {

int numOfLines = image1.rows; // number of lines in the image int numOfPixels = image1.cols; // number of pixels per a line

result.create( image1.rows, image1.cols, image1.type() );

for( int r=0; r<numOfLines; r++ ) {

const uchar *src1 = image1.ptr<uchar>( r );

const uchar *src2 = image2.ptr<uchar>( r );

uchar *dst = result.ptr<uchar>( r );

for( int c=0; c<numOfPixels; c++ ) {

dst[c] = saturate_cast<uchar>(

abs

(src1[c] – src2[c]) );

}

(16)

1616 16

-

(17)

cv::addWeighted( src1, alpha, src2, beta, gamma, dst ) dst = src1*alpha + src2*beta + gamma

ex) result = image1*0.7 + image2*0.5 + 0.0 ex) result = image1*1.0 + image2*(-1.0) + 0.0

cv::scaleAdd( src1, alpha, src2, dst ) dst = src1*alpha + src2

ex) result = image1*0.7 + image2

(18)

18

Gray-level transformations

Improving image contrast and brightness by using mapping function

O(x, y) = M[I(x, y)]

gray-level scaling or gray-scale modification

(19)

(10,50) 범위의 gray level을 (10,250) 범위로 확장

original gray-level values

modified gray-level values

10 30 50

 

 

<

<

=

255 )

, ( 50

) , (

50 )

, ( 10

50 )]

, ( [ 6

50 )

, ( 0

) , ( )]

, ( [

y x I for

y x I

y x I for

y x I

y x I for

y x I y

x I M

example

(20)

2020 20

original gray-level values

m odi fi ed gr ay -l ev el v al u es

(r1, s1) (r2, s2)

General Form of Gray-Scale Modification

(21)

Gray-scale Compression

original gray-level values

mod ifi ed g ra y- level va lu es

153

0.6

(22)

2222 22

Gray-scale Stretching

original gray-level values

mod ifi ed g ra y- level va lu es

40 170

1.96

(23)

original gray-level values

mod ifi ed g ra y- level va lu es

5 40

(24)

2424 24

original gray-level values

mod ifi ed g ra y- level va lu es

110 200

Gray-level Slicing

(25)

original gray-level values

mod ifi ed g ra y- level va lu es

(26)

2626 26

Gray-level Thresholding

original gray-level values

m odi fi ed gr ay -l ev el v al u es

T

(27)

original gray-level values

mod ifi ed g ra y- level va lu es

Gray-level Negative

(28)

28

요약

point pixel processing

이웃 픽셀과는 독립적으로 입력 영상의 각 픽셀 값을 변환한 후 결과 영상의 동일한 위치에 출력하는 연산

목적: Improving image contrast and brightness

Arithmetic operation

Scalar operation: 단일 영상에 상수를 더하거나 빼는 연산

Image operation: 영상 간에 더하거나 빼는 연산

Gray-level transformations

Improving image contrast and brightness by using mapping function

Gray-scale Compression, Gray-scale Stretching, Gray-level Sliding, Gray-level Thresholding, Gray-level Negative 등

(29)

Reference

Scott E Umbaugh, Computer Imaging, CRC Press, 2005

R. Laganière, OpenCV2 Computer Vision: Application

Programming Cookbook, PACKT Publishing, 2011

G. Bradski and A. Kaebler, Learning OpenCV: Computer

Vision with the OpenCV Library, O’REILLY, 2008

정성환, 이문호, 오픈소스 OpenCV를 이용한 컴퓨터 비전 실

무 프로그래밍, 홍릉과학출판사, 2007

참조

관련 문서

Data were collected by Social Interaction Anxiety Scale(SIAS) which measures an anxiety level by interpersonal interaction, Social Phobia Scale(SPS) which

2. watch TV for 2 hours on weekends. a) My parents allowed me to watch TV for 2 hours on weekends... wear make-up today2. a) My parents allowed me to

a) My cousin told me that his teacher was angry all day long... 3. it was very cold

The NL-20 incorporates a memory which can be used to store measurement data (sound level, L eq and other processed values, measurement parameters such as frequency

• 6 DIMMs: Supports six (6) modules inserted into four drak gray slots and one pair of black slots as three pairs of Quad-channel memory configurations. Install the modules

Understanding assembly code and how it relates to the original C code is a key step in understanding how computers execute

 Gray and black vertices, therefore, have been discovered, but breadth-first search distinguishes between them to ensure that the search proceeds in a breadth-first manner..

표면 불순물층 중부인 dark gray 상 (Zr-rich zone) 의 안쪽 부위까지는 Si 침투가 이뤄지지 않음. • Uranium은 중부 dark gray