Writing Contrast Stretching && Edge detection

@ Aaron 2022년 9월 1일

Contrast Stretching

Contrast is a measure of the range of intensity values in an image and is defined as the difference between the maximum pixel value and minimum pixel value. The full contrast of an 8-bit image is $ 255 (max) – 0 (min) = 255$.

Any value less than that means the image has lower contrast than possible. Contrast stretching attempts to improve the contrast of the image by stretching the range of intensity values using linear scaling.

Assume that $𝐼$ is the original input image and $𝑂$ is the output image. Let $𝑎$ and \𝑏 be the minimum and maximum pixel values allowed (for an 8-bit image that means $𝑎$ = 0 and $𝑏$ = 255) and let $𝑐$ and $𝑑 $ be the minimum and maximum pixel values found in $𝐼$. Then the contrast-stretched image $𝑂$ is given by the function:

\( 𝑂(𝑥, 𝑦) = (𝐼(𝑥, 𝑦) − 𝑐)( \frac {b-a}{d-c}) +a\)

Edge Detection

Edges are an important source of semantic information in images. They occur in human visual perception at divisions between areas of different intensity, colour, or texture. A grayscale image can be thought of as a 2D landscape with areas of different intensity living at different heights. A transition between areas of different intensity in an image $𝐼$ means there must be a steep slope, which we formalise as the gradient (vector):

$$ $ \nabla =(\frac{\partial I}{\partial x},\frac{\partial I}{\partial y})$ $$

As the image 𝐼 is discrete, we need to approximate the continuous derivatives $\frac{\partial I}{\partial x}$ by finite differences. Simple examples of convolution kernels that perform finite differencing are the Sobel filters defined as follows:

$$ $ S_x = \begin{bmatrix} 1 & 0 & -1\\ 2 & 0 & -2 \\ 1 & 0 & -1 \ \end{bmatrix}$ $$
$$ $ S_y = \begin{bmatrix} 1 & 2 & 1\\ 0 & 0 & -0 \\ -1 & -2 & -1 \end{bmatrix}$ $$
heading
None
code
None
<

评论 · Comments (0)

需要 MetaMask 等以太坊钱包,签名不花 gas。