Pixel Transformation
- Shin Yoonah, Yoonah
- 2022년 7월 17일
- 2분 분량
최종 수정일: 2022년 8월 8일
Will cover the lesson of 3 types of pixel transformation
1.Histogram
2.Intensity transformation
3.Thresholding and simple segmentation
This lesson will focus on gray scale images
Histogram
=counts the number of occurrences of a pixel and useful for understanding and manipulating images

"Image histograms are present on many modern services. Photographers can use them as an aid to show the distribution of tones captured, and whether image detail has been lost to blown-out highlights or blacked-out shadows" (Wikipedia)
Horizontal axis: the tonal variations
Vertical axis: the total number of pixels in that particular tone

Histogram counts the pixel intensities
= Intensities could be represented as an array

0 = black / 1 = gray / 2 = white
The index of the array = intensity level r
Most images are consist of 256 levels which representing the count of the different intensity of gray levels
Darker portions = lower intensities/Brighter regions = mapped to the higher values
Intensity Transformations
= changes an image one pixel at a time
g(x,y) = T[f(x,y)]
T is called intensity transformation function or mapping, gray level function
s = T(r)
s,r: denote the intensity of g and f at any point

Image Negatives
= where we reverse the intensity levels of an image
Linear transform applying brightness and contrast adjustments
g[i,j] = af[i,j] + B
a(alpha) = simple contrast control
B(Beta) = simple brightness control
Ex) alpha = 1/beta = 100
g[i,j] = 1f[i,j] + 100
Use the function "convertScaleAbs" after applying the transformation
Code:
new_image = cv2.convertScaleAbs(imageName, alpha=alpha, beta=beta)
Function scales = calculates absolute values, so the intensity values fall in the 0 to 255 value range
Adjust alpha to change the contrast
=> contrast in the darker areas have improved
Histogram Equalization
= algorithm that uses the image's histogram to adjust contrast
Ex) let "zelda" as an image name
Zelda = cv2.imread("Zelda.png", cv2.IMREAD_GRAYSCALE)
new_image = cv2.equalizetlist(Zelda)
Thresholding and simple segmentation
- Threshold function applies a threshold to every pixel
- It can be used in extracting objects from an image = segmentation

*The red box*
Cycle through each pixel (i,j)
- If pixel is greater than that threshold and set a pixel in the array "image_out" pixel to same value, usually 1 or 255
- Otherwise, it will set it to another value, usually zero
Copyright Coursera All rights reserved
Comments