0% found this document useful (0 votes)
46 views9 pages

Intensity Transformation of Images

The document discusses intensity transformation techniques in image processing, focusing on methods such as image negatives, log transformations, power-law (gamma) transformations, and piecewise-linear transformation functions. These techniques are essential for enhancing image brightness and contrast, allowing for better visual representation in various applications. The authors provide mathematical expressions, Python code examples, and results demonstrating the effectiveness of these transformations in manipulating pixel intensity values.

Uploaded by

Abi .J
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
46 views9 pages

Intensity Transformation of Images

The document discusses intensity transformation techniques in image processing, focusing on methods such as image negatives, log transformations, power-law (gamma) transformations, and piecewise-linear transformation functions. These techniques are essential for enhancing image brightness and contrast, allowing for better visual representation in various applications. The authors provide mathematical expressions, Python code examples, and results demonstrating the effectiveness of these transformations in manipulating pixel intensity values.

Uploaded by

Abi .J
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 9

INTENSITY TRANSFORMATION OF IMAGES

Mrs. 1Arulmozhi, 2Mageswari. M, 3Yuvasri. B,

1
Associate Professor, Department of Biomedical Engineering, Prince DR. K. Vasudevan College of Engineering and Technology, Chennai 600
127, Tamil Nadu, +91 India

2,3
Under Graduate Scholars (UGS) Students, Department of Biomedical Engineering, Prince DR. K. Vasudevan College of Engineering and
Technology, Chennai 600 127, Tamil Nadu, +91 India

Abstract: Intensity transformation is most known technique of image processing in the spatial
domain and is widely applied to enhance images in various domains. The visual appearance of an
image is generally characterized by two properties: brightness and contrast. Brightness refers to
the overall intensity level and is therefore influenced by the individual gray-level (intensity)
values of all the pixels within an image.

Keywords: Image, Image Processing, Gray Level, Image Intensity, Image Transforms,
Brightness and Contrast Adjustments.

I. Introduction

Intensity transformations are applied on images for contrast manipulation or image


thresholding. These are in the spatial domain, i.e. they are performed directly on the pixels of
the image at hand, as opposed to being performed on the Fourier transform of the image. The
following are commonly used intensity transformations:

1. Image Negatives (Linear)


2. Log Transformations
3. Power-Law (Gamma) Transformations
4. Piecewise-Linear Transformation Functions

Figure 1. Intensity Transforms


II. Previous Existing Work
2.1 Spatial Domain Processes – Spatial domain processes can be described using the equation:
g(x,y) = T[f(x,y)], where f(x,y) is the input image, T is an operator on f defined over a
neighbourhood of the point (x, y), and g(x,y) is the output.

Figure 2. Original Image

2.2 Image Negatives – Image negatives are discussed in this article. Mathematically, assume
that an image goes from intensity levels 0 to (L-1). Generally, L = 256. Then, the negative
transformation can be described by the expression s = L-1-r where r is the initial intensity level
and s is the final intensity level of a pixel. This produces a photographic negative.

III.Proposed Work

3.1 Log Transformations

Mathematically, log transformations can be expressed as s = c . log (1+r). Here, s is the


output intensity, r ≥0 is the input intensity of the pixel, and c is a scaling constant. c is given
by 255 / (log (1 + m)), where m is the maximum pixel value in the image. It is done to ensure
that the final pixel value does not exceed (L - 1), or 255. Practically, log transformation maps a
narrow range of low-intensity input values to a wide range of output values. Consider the
following input image.

Figure 3. Log Transforms Input Image


Below is the code to apply log transformation to the image.

import cv2
import numpy as np

# Open the image.


img = cv2.imread('sample.jpg')

# Apply log transform.


c = 255/(np.log(1 + np.max(img)))
log_transformed = c * np.log(1 + img)

# Specify the data type.


log_transformed = np.array(log_transformed, dtype =
np.uint8)

# Save the output.


cv2.imwrite('log_transformed.jpg', log_transformed)

Below is the log-transformed output.

Figure 4. Log Transforms Output Image

3.2 Power-Law (Gamma) Transformation –

Power-law (gamma) transformations can be mathematically expressed as s = (cr) γ

Gamma correction is important for displaying images on a screen correctly; to prevent bleaching
or darkening of images when viewed from different types of monitors with different display
settings. This is done because our eyes perceive images in a gamma-shaped curve, whereas
cameras capture images in a linear fashion. Below is the Python code to apply gamma correction.

import cv2
import numpy as np

# Open the image.


img = cv2.imread('sample.jpg')

# Trying 4 gamma values.


for gamma in [0.1, 0.5, 1.2, 2.2]:

# Apply gamma correction.


gamma_corrected = np.array(255*(img / 255) ** gamma,
dtype = 'uint8')

# Save edited images.


cv2.imwrite('gamma_transformed'+str(gamma)+'.jpg',
gamma_corrected)

Below are the gamma-corrected outputs for different values of gamma. Gamma = 0.1:

Figure 5. Gamma = 0.1 Transforms Image

Gamma = 0.5:

Figure 6. Gamma = 0.5 Transforms Image


Gamma = 1.2:

Figure 7. Gamma = 1.2 Transforms Image

Gamma = 2.2:

Figure 8. Gamma = 2.2 Transforms Image

IV. Results and Discussions

As can be observed from the outputs as well as the graph, gamma>1 (indicated by the
curve corresponding to ‘nth power’ label on the graph), the intensity of pixels decreases i.e. the
image becomes darker. On the other hand, gamma<1 (indicated by the curve corresponding to
'nth root' label on the graph), the intensity increases i.e. the image becomes lighter.

4.1 Piecewise-Linear Transformation Functions –


These functions, as the name suggests, are not entirely linear in nature. However, they are
linear between certain x-intervals. One of the most commonly used piecewise-linear
transformation functions is contrast stretching. Contrast can be defined as:
Contrast = (I_max - I_min)/(I_max + I_min);
This process expands the range of intensity levels in an image so that it spans the full intensity of
the camera/display. The figure below shows the graph corresponding to the contrast stretching.

Figure 9. Output Intensity Level (s) Vs Input Intensity Level (r)

With (r1, s1), (r2, s2) as parameters, the function stretches the intensity levels by essentially
decreasing the intensity of the dark pixels and increasing the intensity of the light pixels. If r1 = s1
= 0 and r2 = s2 = L - 1, the function becomes a straight dotted line in the graph (which gives no
effect). The function is monotonically increasing so that the order of intensity levels between
pixels is preserved. Below is the Python code to perform contrast stretching.

import cv2
import numpy as np

# Function to map each intensity level to output intensity level.


def pixelVal(pix, r1, s1, r2, s2):
if (0 <= pix and pix <= r1):
return (s1 / r1)*pix
elif (r1 < pix and pix <= r2):
return ((s2 - s1)/(r2 - r1)) * (pix - r1) + s1
else:
return ((255 - s2)/(255 - r2)) * (pix - r2) + s2

# Open the image.


img = cv2.imread('sample.jpg')

# Define parameters.
r1 = 70
s1 = 0
r2 = 140
s2 = 255

# Vectorize the function to apply it to each value in the Numpy array.


pixelVal_vec = np.vectorize(pixelVal)

# Apply contrast stretching.


contrast_stretched = pixelVal_vec(img, r1, s1, r2, s2)

# Save edited image.


cv2.imwrite('contrast_stretch.jpg', contrast_stretched)

Output:

Figure 10. Piecewise - Linear Transforms Image

V. Conclusions

Basic intensity transformations are essential tools in image processing that enable the
adjustment of pixel intensity values in images. These operations serve as the building blocks for
enhancing and manipulating the visual appearance of various types of images, including
grayscale and color ones. In the realm of image processing, basic intensity transformations play
a crucial role in tailoring images to meet specific needs and applications. They are particularly
useful when images have a limited intensity range, and they help to stretch or compress this
range to bring out finer details. These transformations can be used to modify overall image
brightness, create binary images, and even correct the gamma of monitors or cameras. Despite
their simplicity, basic intensity transformations are powerful tools for image enhancement and
manipulation, making them an integral part of various fields, including computer vision, medical
imaging, and digital photography.

Conflict of Interests

The authors are declare that there is no conflicts of the interests and there is any no ethical
issues are regarding the publication of this manuscript.

Ethical approval
This article does not contain any studies with human participants or animals performed by any of
the authors.

Acknowledgements

The authors would like to thank to Trustee and Chairman Dr. K. Vasudevan., M.A.,
B.Ed., Ph.D., Treasury and Vice Chairman Dr. V. Vishnu Karthik, M.D., and Managing
Director Er. V.Prasanna Venkatesh, B.E., M.Sc.,(U.K)., Principal, Vice Principal, Dean, and
HODs of Prince Dr. K. Vasudevan College of Engineering and Technology, Chennai, India,
Faculty of Information and Communication Engineering (ICE) colleagues, Department of
Biomedical Engineering colleagues, the anonymous reviewers and associate editor for their
comments that greatly improved the manuscript.

References

[1] J. Liang, J. Cao, G. Sun, K. Zhang, L. VanGool, andR. Timofte, “SwinIR: Image restoration
using swin transformer,” inProc. IEEE/CVF Int. Conf. Comput. Vis. Workshops, Oct. 2021, pp.
1833–1844.

[2] H. Chen et al., “Real-world single image super-resolution: Abrief review,” Inf. Fusion, vol.
79, pp. 124–145, Mar. 2022.

[3] Z. Zhang, Z.Wang,W. He, andX. Tong, “An improved coastline inflection method for
geolocation correction of Microwave radiation imager data,” Int. J. Remote Sens., vol. 43, no.
12, pp. 4410–4435, Aug. 2022.

[4] S. Wu and J. Chen, “Instrument performance and cross calibration of FY-3C MWRI,” inProc.
IEEE Int. Geosci. Remote Sens. Symp., Jul. 2016, pp. 388–391.

[5] C. Ledig et al., “Photo-realistic single image super-resolution using a generative adversarial
network,” inProc. IEEEConf. Comput. Vis. Pattern Recognit., pp. 4681–4690, 2017.

[6] H. Chen et al., “Pre-trained image processing transformer,” inProc. Conf. Comput. Vis.
Pattern Recognit., pp. 12299–12310, 2021.

[7] A. Vaswani et al., “Attention is all you need,” inProc. Adv. Neural Inf. Process. Syst., 2017,
pp. 5998–6008.

[8] A. Dosovitskiy et al., “An image is worth 16x16 words: Transformers for image recognition
at scale,” in Proc. Int. Conf. Learn. Representations, 2021, pp. 1–12.
[9] Z. Z. Bi andQ.Meng, “Transformer in computer vision,” inProc. IEEE Int. Conf. Comput.
Sci., Electron. Inf. Eng. Intell. Cont. Technol., pp. 178–188, 2021.

[10] Z. Lu, J. Li, H. Liu, C. Huang, L. Zhang, and T. Zeng, “Transformer for single image super-
resolution,” inProc. IEEE/CVF Conf. Comput. Vis. Pattern Recognit. Workshops, Jun. 2022, pp.
457–466.

[11] M. V. Conde, U.-J. Choi, M. Burchi, and R. Timofte, “Swin2SR: SwinV2 transformer for
compressed image super-resolution and restoration,” in Proc. Eur. Conf. Comput. Vis.
Workshops, 2023, pp. 669–687.

[12] W. Shi et al., “Real-time single image and video super-resolution using an efficient sub-
pixel convolutional neural network,” inProc. IEEE Conf. Comput. Vis. Pattern Recognit., 2016,
pp. 1874–1883.

[13] I. Gulrajani, F. Ahmed, M. Arjovsky, V. Dumoulin, and A. Courville, “Improved training of


wassersteinGANs,”Dec. 2017, Accessed: Jun. 16, 2021. [Online]. Available:
http://arxiv.org/abs/1704.00028

[14] Y. Gao, H. Li, J. Dong, and G. Feng, “A deep convolutional network for medical image
super-resolution,” in Proc. Chin. Automat. Congr., Oct. 2017, pp. 5310–5315,
doi:10.1109/CAC.2017.8243724.

[15] D. Mahapatra and B. Bozorgtabar, “Progressive generative adversarial networks for medical
image super resolution,” Feb. 2019, Accessed: May 28, 2021. [Online]. Available:
http://arxiv.org/abs/1902.02144

[16] T. Gulati, S. Sengupta, and V. Lakshminarayanan, “Application of an enhanced deep super-


resolution network in retinal image analysis,” in Proc. Ophthalmic Technol. XXX, Feb. 2020,
vol. 11218, Paper 112181K, doi:10.1117/12.2543791.

[17] G. Zamzmi, S. Rajaraman, and S. Antani, “Accelerating super-resolution and visual task
analysis in medical images,”Appl. Sci., vol. 10, no. 12, Jan. 2020, Art. no. 4282, doi:
10.3390/app10124282.

[18] “A pan-sharpening method based on evolutionary optimization and HIS transformation,”


Accessed: Dec. 10, 2021. [Online]. Available: https:
//www.hindawi.com/journals/mpe/2017/8269078/

You might also like

pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy