SlideShare a Scribd company logo
1 of 36
Color
Space/Models
Color Space/Models
The primary color is the one which absorbs a
primary color and reflects the other two.
The primary colors can be added together to
produce the secondary colors –
magenta, cyan and yellow as you can see in
the figure below-
Mixing three primary colors or a secondary
color with its opposite primary color produces
white light as shown in Fig
Brightness
• This expresses the intensity
or amount of the output.
• If we talk about a practical
example, this is what we see
in the movies made before
the 1930s.
Hue
• As we know visible light has energy which is
spread over a band of wavelengths. Hue
represents the dominant wavelength in a
mixture of all light waves.
• It represents the dominant color as viewed
by an observer.
Saturation
• It shows the amount of white
light mixed with the hue.
• Hue and Saturation, together
are called Chromaticity.
Therefore, a color may be
characterized by its
chromaticity and intensity
What is a Color
Model?
A color model is an abstract mathematical model that describes how
colors can be represented as a set of numbers (e.g., a triple in RGB or a
quad in CMYK). Color models can usually be described using a
coordinate system, and each color in the system is represented by a
single point in the coordinate space.
For a given color model, to interpret a tuple or quad as a color, we can
define a set of rules and definitions used to accurately calibrate and
generate colors, i.e. a mapping function. A color space identifies a
specific combination of color models and mapping functions. Identifying
the color space automatically identifies the associated color model. For
example, Adobe RGB and sRGB are two different color spaces, both
based on the RGB color model.
RGB Model
RGB color model stores individual values for
red, green, and blue
The RGB color space is associated with the
device
There are many different RGB color spaces
derived from this color model, standard RGB
is a popular example
Application
The RGB model is widely
used in the representation
and display of images in
electronic systems like
computers and televisions
It is also used in
conventional photography
as well
Image scanner which
scans images and
converts it to a digital
image mostly supports
RGB color
It is used in web graphics
CMY Model
This model contains the secondary colors.
In this model, any secondary color when passed
through white light will not reflect the color from
which a combination of colors is made
For example- when cyan is illuminated with white
light, no red light will be reflected from the surface
which means that the cyan subtracts the red light
from the reflected white light.
CMY Model
The formula given in equation 1 is for inter-
conversion of RGB and CMY models:
Fig.6. C, M and Y components of an image
Fig. 5. Input Image
Application
IT IS USED IN
COLOR PRINTING
AS IT USES
COLORED INKS
IT IS USED IN MOST
COMMERCIAL
PRINTING LIKE
MAGAZINES,
BOOKS, ETC
HSV
HSV (hue, saturation, value), also known as HSB
(hue, saturation, brightness), is often used by
artists because it is often more natural to think
about a color in terms of hue and saturation
than in terms of additive or subtractive color
components.
The system is closer to people’s
experience and perception of color than
RGB. For example, in painting terms,
hue, saturation, and values are expressed
in terms of color, shading, and toning.
Hue is a color component that describes a pure color
Red Green Blue
Saturation component represents the measure of the degree to which
color is mixed with white color.
0 degree –
Red
120 degree
– Green
240 degree
– Blue
60 degree –
Yellow
300 degree
– Magenta
Intensity
Range
is
0 means
white
1 means
black
HSI Model
The angle from the red axis gives the Hue, the length of the
vector is the saturation and the intensity is given by the
position of the plane on the vertical intensity axis.
The biggest application of this model is that it represents
colors similarly to how the human eye senses colors.
HSI Model
The HSV model space can be described as an inverted hexagonal pyramid.
• The top surface is a regular hexagon, showing the change in hue in the H
direction, from 0 ° to 360 ° is the entire spectrum of visible light. The six
corners of the hexagon represent the positions of the six colors of red,
yellow, green, cyan, blue, and magenta, each of which is 60 ° apart.
• The saturation S is represented by the S direction from the center to the
hexagonal boundary, and the value varies from 0 to 1. The closer to the
hexagonal boundary, the higher the color saturation. The color of the
hexagonal boundary is the most saturated, i.e. S = 1; the color saturation
at the center of the hexagon is 0, i.e. S = 0.
• The height of the hexagonal pyramid (also known as the central axis) is
denoted by V, which represents a black to white gradation from bottom to
top. The bottom of V is black, V = 0; the top of V is white, V = 1.
YUV
The Y′UV model defines a color space in terms of one luma component
(Y′) and two chrominance (UV) components. The Y′ channel saves
black and white data. If there is only the Y component and there are no
U and V components, then the graph represented is grayscale.
The Y component can be calculated with the following equation: Y = 0.
299R+ 0. 587G+ 0. 114*B, which is the commonly used grayscale
formula. The color difference U and V are compressed by B-Y and R-Y
in different proportions.
Compared with RGB, Y’UV does not necessarily store a triple tuple for
each pixel. Y′UV images can be sampled in several different ways. For
example, with YUV420, it saves one luma component for every point
and two chroma values—a Cr (U) value and a Cb (V) value—every 2×2
points. I.E., 6 bytes per 4 pixels.
The scope of the terms Y′UV, YUV, YCbCr, YPbPr, etc., is sometimes
ambiguous and overlapping. Historically, the terms YUV and Y′UV were
used for a specific analog encoding of color information in television
systems, while YCbCr was used for digital encoding of color information
suited for video and still-image compression and transmission such as
MPEG and JPEG. Today, the term YUV is commonly used in the
computer industry to describe file-formats that are encoded using
YCbCr.
1. Color to
Grayscale
Conversion
1.1 RGB to
Grayscale
There are a number of commonly used
methods to convert an RGB image to a
grayscale image, such as average method
and weighted method
Average Method
The Average method takes the average value of R, G, and B as the
grayscale value.
Grayscale = (R + G + B ) / 3
A minor note: Theoretically, the formula is 100% correct. But when
writing code, you may encounter uint8 overflow error — the sum of
R, G, and B is greater than 255. To avoid the exception, R, G, and
B should be calculated, respectively.
Grayscale = R / 3 + G / 3 + B / 3
The average method is simple but doesn’t work as well as
expected. The reason is that human eyeballs react differently to
RGB. Eyes are most sensitive to green light, less sensitive to red
light, and the least sensitive to blue light. Therefore, the three
colors should have different weights in the distribution. That brings
us to the weighted method.
The Weighted Method
The weighted method, also called the
luminosity method, weighs of red, green,
and blue according to their wavelengths
The improved formula is as follows:
Grayscale = 0.299R + 0.587G + 0.114B
1.2 YUV to
Grayscale
YUV is a color encoding system used for analog television
The YUV color model represents the human perception of
color more closely than the standard RGB model used in
computer graphics hardware and is more size-efficient
RGB to YUV Conversion:
Y = 0.299R + 0.587G + 0.114B
U'= (B-Y)*0.565
V'= (R-Y)*0.713
The Grayscale Value
The formula for converting RGB to Y is the
same as the formula for converting RGB to
grayscale. Therefore:
Grayscale = Y
1.3 HSV to
Grayscale
HSV (hue, saturation, value) and HSL (hue, saturation, lightness or luminance) are
transformations of a Cartesian RGB color space.
To convert HSV to grayscale, we first need to convert HSV to RGB and then convert the RGB
triple to a grayscale value.
The Grayscale Value
When 0 ≤ H < 360, 0 ≤ S ≤ 1 and
0 ≤ V ≤ 1:
C = V × S
X = C × (1 - |(H / 60°) mod 2 - 1|)
m = V - C
(R,G,B) = ((R‘+m)×255, (G‘+m)×255,
(B‘+m)×255)
HSV to RGB conversion
Grayscale = 0.299R + 0.587G + 0.114B
1.4 An example of RGB to grayscale using the
weighted method
Here is an example of the grayscale conversion method used in a barcode scanner. As we can
see in this image, the DataMatrix code on a Thai government lottery has red lines crossed over.
The barcode scanner first converts the color image to grayscale and then binary. Using the
average method, we get a grayscale image like this one:
To further split the foreground (the DataMatrix code) from the white background with the red
lines, let’s give a larger weight to the red channel.
Grayscale = 1*Red + 0*Green + 0*Blue
Here is the result. The red lines are lighter compared with the result from the average method,
i.e., closer to white.
Source code used for testing
import cv2 RGB_image = cv2.imread("thai-government-lottery.png")
blue = RGB_image[:,:,0]
green = RGB_image[:,:,1]
red = RGB_image[:,:,2]
Average_Gray = blue/3+green/3+red/3
Weighted_Gray = (0 * blue) + (0* green) + (1 * red)
2. Binarization: Grayscale to black/white Conversion
LOCAL THRESHOLDING — CALCULATES
THE THRESHOLD PIXEL BY PIXEL
GLOBAL THRESHOLDING — CALCULATES
THE THRESHOLD ONCE FOR ALL PIXELS
Binarization converts a grayscale image to a black/white image. This transformation is useful in detecting
blobs and further reduces the computational complexity. The critical task is to find a suitable threshold.
There are two main methods:
The images below show an example of before and after binarization.
2.1 Local
Thresholding Method
With the local thresholding method, a
threshold is calculated at each pixel, which
depends on some local statistics such as
mean, range, and the variance of the pixel
neighborhood
The image is divided into several sub-blocks,
and the distribution of gray-value in each
block was analyzed
2.2 Global
Thresholding Method
The global thresholding method takes advantage of the
image histogram. The image histogram is a statistical graph
with grayscale value on the x-axis and the number of pixels
for each grayscale on the y-axis.
Image histogram can be used to automatically determine
the value of the threshold to be used for converting a
grayscale image to a binary image. The basic idea is to find
a point between the peak of the foreground pixel values and
the peak of the background pixel values. If the intensity
level of a pixel is smaller than the threshold, the pixel is set
to black (grayscale = 0). Otherwise, it is set to white
(grayscale = 255). The threshold serves as a dividing line.
Different Ways to Convert
Image to Grayscale in
Python
1. Input Image.
2. Image Grayscale Conversion with Skimage
(Scikit Image) – color. rgb2gray()
3. Image Grayscale Conversion with Pillow (PIL) –
convert()
4. Image Grayscale Conversion with OpenCV –
cv2. imread()
5. Image Grayscale Conversion with OpenCV –
cv2. cvtColor()
Image Grayscale
Conversion with Pillow –
convert
Pillow is another image processing library of
Python which can be used to convert image
to grayscale with its img.convert function
In this example, the image is read with
Image.open and then it is transformed with
convert by passing ‘L’ as the parameter
The ‘L’ parameter is used to convert the
image to grayscale
In [1]:
from PIL import Image
img = Image.open('dog.jpg')
imgGray = img.convert('L')
imgGray.show()
Out[1]:
window_name='Grayscale Conversion OpenCV'
cv2.namedWindow(window_name,
cv2.WINDOW_NORMAL)
cv2.imshow(window_name,img_gray)
cv2.waitKey(0)
cv2.destroyAllWindows()

More Related Content

Similar to Lecnoninecolorspacemodelindigitalimageprocess

Color image processing
Color image processingColor image processing
Color image processingrmsurya
 
An investigation for steganography using different color system
An investigation for steganography using different color systemAn investigation for steganography using different color system
An investigation for steganography using different color systemDr Amira Bibo
 
Question bank for students.pdf
Question bank for students.pdfQuestion bank for students.pdf
Question bank for students.pdfNehaVerma258827
 
Colour image processing(fip)
Colour image processing(fip)Colour image processing(fip)
Colour image processing(fip)Vijay Kumar
 
Color
ColorColor
ColorFNian
 
Project report_DTRL_subrat
Project report_DTRL_subratProject report_DTRL_subrat
Project report_DTRL_subratSubrat Prasad
 
Comprehensive Infrared Image Edge detection Algorithm
Comprehensive Infrared Image Edge detection AlgorithmComprehensive Infrared Image Edge detection Algorithm
Comprehensive Infrared Image Edge detection AlgorithmCSCJournals
 
Color Image Processing.pptx
Color Image Processing.pptxColor Image Processing.pptx
Color Image Processing.pptxAntu Chowdhury
 
"Color model" Slide for Computer Graphics Presentation
"Color model" Slide for Computer Graphics Presentation"Color model" Slide for Computer Graphics Presentation
"Color model" Slide for Computer Graphics PresentationAshek Shanto
 
Multimedia color in image and video
Multimedia color in image and videoMultimedia color in image and video
Multimedia color in image and videoMazin Alwaaly
 
CG04 Color Models.ppsx
CG04 Color Models.ppsxCG04 Color Models.ppsx
CG04 Color Models.ppsxjyoti_lakhani
 
Colorization of Gray Scale Images in YCbCr Color Space Using Texture Extract...
Colorization of Gray Scale Images in YCbCr Color Space Using  Texture Extract...Colorization of Gray Scale Images in YCbCr Color Space Using  Texture Extract...
Colorization of Gray Scale Images in YCbCr Color Space Using Texture Extract...IOSR Journals
 
Color image processing.ppt
Color image processing.pptColor image processing.ppt
Color image processing.pptPapajuvvanapudi
 
Color fundamentals and color models - Digital Image Processing
Color fundamentals and color models - Digital Image ProcessingColor fundamentals and color models - Digital Image Processing
Color fundamentals and color models - Digital Image ProcessingAmna
 

Similar to Lecnoninecolorspacemodelindigitalimageprocess (20)

Color image processing
Color image processingColor image processing
Color image processing
 
An investigation for steganography using different color system
An investigation for steganography using different color systemAn investigation for steganography using different color system
An investigation for steganography using different color system
 
Question bank for students.pdf
Question bank for students.pdfQuestion bank for students.pdf
Question bank for students.pdf
 
Colour image processing(fip)
Colour image processing(fip)Colour image processing(fip)
Colour image processing(fip)
 
Color
ColorColor
Color
 
Project report_DTRL_subrat
Project report_DTRL_subratProject report_DTRL_subrat
Project report_DTRL_subrat
 
Comprehensive Infrared Image Edge detection Algorithm
Comprehensive Infrared Image Edge detection AlgorithmComprehensive Infrared Image Edge detection Algorithm
Comprehensive Infrared Image Edge detection Algorithm
 
Color Image Processing.pptx
Color Image Processing.pptxColor Image Processing.pptx
Color Image Processing.pptx
 
"Color model" Slide for Computer Graphics Presentation
"Color model" Slide for Computer Graphics Presentation"Color model" Slide for Computer Graphics Presentation
"Color model" Slide for Computer Graphics Presentation
 
Color_Spaces.pptx
Color_Spaces.pptxColor_Spaces.pptx
Color_Spaces.pptx
 
Displays and color system in computer graphics(Computer graphics tutorials)
Displays and color system in computer graphics(Computer graphics tutorials)Displays and color system in computer graphics(Computer graphics tutorials)
Displays and color system in computer graphics(Computer graphics tutorials)
 
Color Models
Color ModelsColor Models
Color Models
 
Lect 06
Lect 06 Lect 06
Lect 06
 
Multimedia color in image and video
Multimedia color in image and videoMultimedia color in image and video
Multimedia color in image and video
 
CG04 Color Models.ppsx
CG04 Color Models.ppsxCG04 Color Models.ppsx
CG04 Color Models.ppsx
 
Colorization of Gray Scale Images in YCbCr Color Space Using Texture Extract...
Colorization of Gray Scale Images in YCbCr Color Space Using  Texture Extract...Colorization of Gray Scale Images in YCbCr Color Space Using  Texture Extract...
Colorization of Gray Scale Images in YCbCr Color Space Using Texture Extract...
 
Color image processing.ppt
Color image processing.pptColor image processing.ppt
Color image processing.ppt
 
Color fundamentals and color models - Digital Image Processing
Color fundamentals and color models - Digital Image ProcessingColor fundamentals and color models - Digital Image Processing
Color fundamentals and color models - Digital Image Processing
 
color image processing
color image processingcolor image processing
color image processing
 
Id3115321536
Id3115321536Id3115321536
Id3115321536
 

Recently uploaded

20240419 - Measurecamp Amsterdam - SAM.pdf
20240419 - Measurecamp Amsterdam - SAM.pdf20240419 - Measurecamp Amsterdam - SAM.pdf
20240419 - Measurecamp Amsterdam - SAM.pdfHuman37
 
GA4 Without Cookies [Measure Camp AMS]
GA4 Without Cookies [Measure Camp AMS]GA4 Without Cookies [Measure Camp AMS]
GA4 Without Cookies [Measure Camp AMS]📊 Markus Baersch
 
04242024_CCC TUG_Joins and Relationships
04242024_CCC TUG_Joins and Relationships04242024_CCC TUG_Joins and Relationships
04242024_CCC TUG_Joins and Relationshipsccctableauusergroup
 
办理学位证纽约大学毕业证(NYU毕业证书)原版一比一
办理学位证纽约大学毕业证(NYU毕业证书)原版一比一办理学位证纽约大学毕业证(NYU毕业证书)原版一比一
办理学位证纽约大学毕业证(NYU毕业证书)原版一比一fhwihughh
 
1:1定制(UQ毕业证)昆士兰大学毕业证成绩单修改留信学历认证原版一模一样
1:1定制(UQ毕业证)昆士兰大学毕业证成绩单修改留信学历认证原版一模一样1:1定制(UQ毕业证)昆士兰大学毕业证成绩单修改留信学历认证原版一模一样
1:1定制(UQ毕业证)昆士兰大学毕业证成绩单修改留信学历认证原版一模一样vhwb25kk
 
Effects of Smartphone Addiction on the Academic Performances of Grades 9 to 1...
Effects of Smartphone Addiction on the Academic Performances of Grades 9 to 1...Effects of Smartphone Addiction on the Academic Performances of Grades 9 to 1...
Effects of Smartphone Addiction on the Academic Performances of Grades 9 to 1...limedy534
 
Call Us ➥97111√47426🤳Call Girls in Aerocity (Delhi NCR)
Call Us ➥97111√47426🤳Call Girls in Aerocity (Delhi NCR)Call Us ➥97111√47426🤳Call Girls in Aerocity (Delhi NCR)
Call Us ➥97111√47426🤳Call Girls in Aerocity (Delhi NCR)jennyeacort
 
Indian Call Girls in Abu Dhabi O5286O24O8 Call Girls in Abu Dhabi By Independ...
Indian Call Girls in Abu Dhabi O5286O24O8 Call Girls in Abu Dhabi By Independ...Indian Call Girls in Abu Dhabi O5286O24O8 Call Girls in Abu Dhabi By Independ...
Indian Call Girls in Abu Dhabi O5286O24O8 Call Girls in Abu Dhabi By Independ...dajasot375
 
Dubai Call Girls Wifey O52&786472 Call Girls Dubai
Dubai Call Girls Wifey O52&786472 Call Girls DubaiDubai Call Girls Wifey O52&786472 Call Girls Dubai
Dubai Call Girls Wifey O52&786472 Call Girls Dubaihf8803863
 
Call Girls in Defence Colony Delhi 💯Call Us 🔝8264348440🔝
Call Girls in Defence Colony Delhi 💯Call Us 🔝8264348440🔝Call Girls in Defence Colony Delhi 💯Call Us 🔝8264348440🔝
Call Girls in Defence Colony Delhi 💯Call Us 🔝8264348440🔝soniya singh
 
Beautiful Sapna Vip Call Girls Hauz Khas 9711199012 Call /Whatsapps
Beautiful Sapna Vip  Call Girls Hauz Khas 9711199012 Call /WhatsappsBeautiful Sapna Vip  Call Girls Hauz Khas 9711199012 Call /Whatsapps
Beautiful Sapna Vip Call Girls Hauz Khas 9711199012 Call /Whatsappssapnasaifi408
 
PKS-TGC-1084-630 - Stage 1 Proposal.pptx
PKS-TGC-1084-630 - Stage 1 Proposal.pptxPKS-TGC-1084-630 - Stage 1 Proposal.pptx
PKS-TGC-1084-630 - Stage 1 Proposal.pptxPramod Kumar Srivastava
 
NLP Project PPT: Flipkart Product Reviews through NLP Data Science.pptx
NLP Project PPT: Flipkart Product Reviews through NLP Data Science.pptxNLP Project PPT: Flipkart Product Reviews through NLP Data Science.pptx
NLP Project PPT: Flipkart Product Reviews through NLP Data Science.pptxBoston Institute of Analytics
 
Customer Service Analytics - Make Sense of All Your Data.pptx
Customer Service Analytics - Make Sense of All Your Data.pptxCustomer Service Analytics - Make Sense of All Your Data.pptx
Customer Service Analytics - Make Sense of All Your Data.pptxEmmanuel Dauda
 
Building on a FAIRly Strong Foundation to Connect Academic Research to Transl...
Building on a FAIRly Strong Foundation to Connect Academic Research to Transl...Building on a FAIRly Strong Foundation to Connect Academic Research to Transl...
Building on a FAIRly Strong Foundation to Connect Academic Research to Transl...Jack DiGiovanna
 
科罗拉多大学波尔得分校毕业证学位证成绩单-可办理
科罗拉多大学波尔得分校毕业证学位证成绩单-可办理科罗拉多大学波尔得分校毕业证学位证成绩单-可办理
科罗拉多大学波尔得分校毕业证学位证成绩单-可办理e4aez8ss
 
INTERNSHIP ON PURBASHA COMPOSITE TEX LTD
INTERNSHIP ON PURBASHA COMPOSITE TEX LTDINTERNSHIP ON PURBASHA COMPOSITE TEX LTD
INTERNSHIP ON PURBASHA COMPOSITE TEX LTDRafezzaman
 
B2 Creative Industry Response Evaluation.docx
B2 Creative Industry Response Evaluation.docxB2 Creative Industry Response Evaluation.docx
B2 Creative Industry Response Evaluation.docxStephen266013
 
EMERCE - 2024 - AMSTERDAM - CROSS-PLATFORM TRACKING WITH GOOGLE ANALYTICS.pptx
EMERCE - 2024 - AMSTERDAM - CROSS-PLATFORM  TRACKING WITH GOOGLE ANALYTICS.pptxEMERCE - 2024 - AMSTERDAM - CROSS-PLATFORM  TRACKING WITH GOOGLE ANALYTICS.pptx
EMERCE - 2024 - AMSTERDAM - CROSS-PLATFORM TRACKING WITH GOOGLE ANALYTICS.pptxthyngster
 

Recently uploaded (20)

20240419 - Measurecamp Amsterdam - SAM.pdf
20240419 - Measurecamp Amsterdam - SAM.pdf20240419 - Measurecamp Amsterdam - SAM.pdf
20240419 - Measurecamp Amsterdam - SAM.pdf
 
GA4 Without Cookies [Measure Camp AMS]
GA4 Without Cookies [Measure Camp AMS]GA4 Without Cookies [Measure Camp AMS]
GA4 Without Cookies [Measure Camp AMS]
 
04242024_CCC TUG_Joins and Relationships
04242024_CCC TUG_Joins and Relationships04242024_CCC TUG_Joins and Relationships
04242024_CCC TUG_Joins and Relationships
 
办理学位证纽约大学毕业证(NYU毕业证书)原版一比一
办理学位证纽约大学毕业证(NYU毕业证书)原版一比一办理学位证纽约大学毕业证(NYU毕业证书)原版一比一
办理学位证纽约大学毕业证(NYU毕业证书)原版一比一
 
1:1定制(UQ毕业证)昆士兰大学毕业证成绩单修改留信学历认证原版一模一样
1:1定制(UQ毕业证)昆士兰大学毕业证成绩单修改留信学历认证原版一模一样1:1定制(UQ毕业证)昆士兰大学毕业证成绩单修改留信学历认证原版一模一样
1:1定制(UQ毕业证)昆士兰大学毕业证成绩单修改留信学历认证原版一模一样
 
Call Girls in Saket 99530🔝 56974 Escort Service
Call Girls in Saket 99530🔝 56974 Escort ServiceCall Girls in Saket 99530🔝 56974 Escort Service
Call Girls in Saket 99530🔝 56974 Escort Service
 
Effects of Smartphone Addiction on the Academic Performances of Grades 9 to 1...
Effects of Smartphone Addiction on the Academic Performances of Grades 9 to 1...Effects of Smartphone Addiction on the Academic Performances of Grades 9 to 1...
Effects of Smartphone Addiction on the Academic Performances of Grades 9 to 1...
 
Call Us ➥97111√47426🤳Call Girls in Aerocity (Delhi NCR)
Call Us ➥97111√47426🤳Call Girls in Aerocity (Delhi NCR)Call Us ➥97111√47426🤳Call Girls in Aerocity (Delhi NCR)
Call Us ➥97111√47426🤳Call Girls in Aerocity (Delhi NCR)
 
Indian Call Girls in Abu Dhabi O5286O24O8 Call Girls in Abu Dhabi By Independ...
Indian Call Girls in Abu Dhabi O5286O24O8 Call Girls in Abu Dhabi By Independ...Indian Call Girls in Abu Dhabi O5286O24O8 Call Girls in Abu Dhabi By Independ...
Indian Call Girls in Abu Dhabi O5286O24O8 Call Girls in Abu Dhabi By Independ...
 
Dubai Call Girls Wifey O52&786472 Call Girls Dubai
Dubai Call Girls Wifey O52&786472 Call Girls DubaiDubai Call Girls Wifey O52&786472 Call Girls Dubai
Dubai Call Girls Wifey O52&786472 Call Girls Dubai
 
Call Girls in Defence Colony Delhi 💯Call Us 🔝8264348440🔝
Call Girls in Defence Colony Delhi 💯Call Us 🔝8264348440🔝Call Girls in Defence Colony Delhi 💯Call Us 🔝8264348440🔝
Call Girls in Defence Colony Delhi 💯Call Us 🔝8264348440🔝
 
Beautiful Sapna Vip Call Girls Hauz Khas 9711199012 Call /Whatsapps
Beautiful Sapna Vip  Call Girls Hauz Khas 9711199012 Call /WhatsappsBeautiful Sapna Vip  Call Girls Hauz Khas 9711199012 Call /Whatsapps
Beautiful Sapna Vip Call Girls Hauz Khas 9711199012 Call /Whatsapps
 
PKS-TGC-1084-630 - Stage 1 Proposal.pptx
PKS-TGC-1084-630 - Stage 1 Proposal.pptxPKS-TGC-1084-630 - Stage 1 Proposal.pptx
PKS-TGC-1084-630 - Stage 1 Proposal.pptx
 
NLP Project PPT: Flipkart Product Reviews through NLP Data Science.pptx
NLP Project PPT: Flipkart Product Reviews through NLP Data Science.pptxNLP Project PPT: Flipkart Product Reviews through NLP Data Science.pptx
NLP Project PPT: Flipkart Product Reviews through NLP Data Science.pptx
 
Customer Service Analytics - Make Sense of All Your Data.pptx
Customer Service Analytics - Make Sense of All Your Data.pptxCustomer Service Analytics - Make Sense of All Your Data.pptx
Customer Service Analytics - Make Sense of All Your Data.pptx
 
Building on a FAIRly Strong Foundation to Connect Academic Research to Transl...
Building on a FAIRly Strong Foundation to Connect Academic Research to Transl...Building on a FAIRly Strong Foundation to Connect Academic Research to Transl...
Building on a FAIRly Strong Foundation to Connect Academic Research to Transl...
 
科罗拉多大学波尔得分校毕业证学位证成绩单-可办理
科罗拉多大学波尔得分校毕业证学位证成绩单-可办理科罗拉多大学波尔得分校毕业证学位证成绩单-可办理
科罗拉多大学波尔得分校毕业证学位证成绩单-可办理
 
INTERNSHIP ON PURBASHA COMPOSITE TEX LTD
INTERNSHIP ON PURBASHA COMPOSITE TEX LTDINTERNSHIP ON PURBASHA COMPOSITE TEX LTD
INTERNSHIP ON PURBASHA COMPOSITE TEX LTD
 
B2 Creative Industry Response Evaluation.docx
B2 Creative Industry Response Evaluation.docxB2 Creative Industry Response Evaluation.docx
B2 Creative Industry Response Evaluation.docx
 
EMERCE - 2024 - AMSTERDAM - CROSS-PLATFORM TRACKING WITH GOOGLE ANALYTICS.pptx
EMERCE - 2024 - AMSTERDAM - CROSS-PLATFORM  TRACKING WITH GOOGLE ANALYTICS.pptxEMERCE - 2024 - AMSTERDAM - CROSS-PLATFORM  TRACKING WITH GOOGLE ANALYTICS.pptx
EMERCE - 2024 - AMSTERDAM - CROSS-PLATFORM TRACKING WITH GOOGLE ANALYTICS.pptx
 

Lecnoninecolorspacemodelindigitalimageprocess

  • 2. Color Space/Models The primary color is the one which absorbs a primary color and reflects the other two. The primary colors can be added together to produce the secondary colors – magenta, cyan and yellow as you can see in the figure below- Mixing three primary colors or a secondary color with its opposite primary color produces white light as shown in Fig
  • 3. Brightness • This expresses the intensity or amount of the output. • If we talk about a practical example, this is what we see in the movies made before the 1930s.
  • 4. Hue • As we know visible light has energy which is spread over a band of wavelengths. Hue represents the dominant wavelength in a mixture of all light waves. • It represents the dominant color as viewed by an observer.
  • 5. Saturation • It shows the amount of white light mixed with the hue. • Hue and Saturation, together are called Chromaticity. Therefore, a color may be characterized by its chromaticity and intensity
  • 6. What is a Color Model? A color model is an abstract mathematical model that describes how colors can be represented as a set of numbers (e.g., a triple in RGB or a quad in CMYK). Color models can usually be described using a coordinate system, and each color in the system is represented by a single point in the coordinate space. For a given color model, to interpret a tuple or quad as a color, we can define a set of rules and definitions used to accurately calibrate and generate colors, i.e. a mapping function. A color space identifies a specific combination of color models and mapping functions. Identifying the color space automatically identifies the associated color model. For example, Adobe RGB and sRGB are two different color spaces, both based on the RGB color model.
  • 7. RGB Model RGB color model stores individual values for red, green, and blue The RGB color space is associated with the device There are many different RGB color spaces derived from this color model, standard RGB is a popular example
  • 8. Application The RGB model is widely used in the representation and display of images in electronic systems like computers and televisions It is also used in conventional photography as well Image scanner which scans images and converts it to a digital image mostly supports RGB color It is used in web graphics
  • 9. CMY Model This model contains the secondary colors. In this model, any secondary color when passed through white light will not reflect the color from which a combination of colors is made For example- when cyan is illuminated with white light, no red light will be reflected from the surface which means that the cyan subtracts the red light from the reflected white light.
  • 10. CMY Model The formula given in equation 1 is for inter- conversion of RGB and CMY models: Fig.6. C, M and Y components of an image Fig. 5. Input Image
  • 11. Application IT IS USED IN COLOR PRINTING AS IT USES COLORED INKS IT IS USED IN MOST COMMERCIAL PRINTING LIKE MAGAZINES, BOOKS, ETC
  • 12. HSV HSV (hue, saturation, value), also known as HSB (hue, saturation, brightness), is often used by artists because it is often more natural to think about a color in terms of hue and saturation than in terms of additive or subtractive color components. The system is closer to people’s experience and perception of color than RGB. For example, in painting terms, hue, saturation, and values are expressed in terms of color, shading, and toning.
  • 13. Hue is a color component that describes a pure color Red Green Blue
  • 14. Saturation component represents the measure of the degree to which color is mixed with white color. 0 degree – Red 120 degree – Green 240 degree – Blue 60 degree – Yellow 300 degree – Magenta
  • 16. HSI Model The angle from the red axis gives the Hue, the length of the vector is the saturation and the intensity is given by the position of the plane on the vertical intensity axis. The biggest application of this model is that it represents colors similarly to how the human eye senses colors.
  • 17. HSI Model The HSV model space can be described as an inverted hexagonal pyramid. • The top surface is a regular hexagon, showing the change in hue in the H direction, from 0 ° to 360 ° is the entire spectrum of visible light. The six corners of the hexagon represent the positions of the six colors of red, yellow, green, cyan, blue, and magenta, each of which is 60 ° apart. • The saturation S is represented by the S direction from the center to the hexagonal boundary, and the value varies from 0 to 1. The closer to the hexagonal boundary, the higher the color saturation. The color of the hexagonal boundary is the most saturated, i.e. S = 1; the color saturation at the center of the hexagon is 0, i.e. S = 0. • The height of the hexagonal pyramid (also known as the central axis) is denoted by V, which represents a black to white gradation from bottom to top. The bottom of V is black, V = 0; the top of V is white, V = 1.
  • 18. YUV The Y′UV model defines a color space in terms of one luma component (Y′) and two chrominance (UV) components. The Y′ channel saves black and white data. If there is only the Y component and there are no U and V components, then the graph represented is grayscale. The Y component can be calculated with the following equation: Y = 0. 299R+ 0. 587G+ 0. 114*B, which is the commonly used grayscale formula. The color difference U and V are compressed by B-Y and R-Y in different proportions. Compared with RGB, Y’UV does not necessarily store a triple tuple for each pixel. Y′UV images can be sampled in several different ways. For example, with YUV420, it saves one luma component for every point and two chroma values—a Cr (U) value and a Cb (V) value—every 2×2 points. I.E., 6 bytes per 4 pixels. The scope of the terms Y′UV, YUV, YCbCr, YPbPr, etc., is sometimes ambiguous and overlapping. Historically, the terms YUV and Y′UV were used for a specific analog encoding of color information in television systems, while YCbCr was used for digital encoding of color information suited for video and still-image compression and transmission such as MPEG and JPEG. Today, the term YUV is commonly used in the computer industry to describe file-formats that are encoded using YCbCr.
  • 20. 1.1 RGB to Grayscale There are a number of commonly used methods to convert an RGB image to a grayscale image, such as average method and weighted method
  • 21. Average Method The Average method takes the average value of R, G, and B as the grayscale value. Grayscale = (R + G + B ) / 3 A minor note: Theoretically, the formula is 100% correct. But when writing code, you may encounter uint8 overflow error — the sum of R, G, and B is greater than 255. To avoid the exception, R, G, and B should be calculated, respectively. Grayscale = R / 3 + G / 3 + B / 3 The average method is simple but doesn’t work as well as expected. The reason is that human eyeballs react differently to RGB. Eyes are most sensitive to green light, less sensitive to red light, and the least sensitive to blue light. Therefore, the three colors should have different weights in the distribution. That brings us to the weighted method.
  • 22. The Weighted Method The weighted method, also called the luminosity method, weighs of red, green, and blue according to their wavelengths The improved formula is as follows: Grayscale = 0.299R + 0.587G + 0.114B
  • 23. 1.2 YUV to Grayscale YUV is a color encoding system used for analog television The YUV color model represents the human perception of color more closely than the standard RGB model used in computer graphics hardware and is more size-efficient RGB to YUV Conversion: Y = 0.299R + 0.587G + 0.114B U'= (B-Y)*0.565 V'= (R-Y)*0.713
  • 24. The Grayscale Value The formula for converting RGB to Y is the same as the formula for converting RGB to grayscale. Therefore: Grayscale = Y
  • 25. 1.3 HSV to Grayscale HSV (hue, saturation, value) and HSL (hue, saturation, lightness or luminance) are transformations of a Cartesian RGB color space. To convert HSV to grayscale, we first need to convert HSV to RGB and then convert the RGB triple to a grayscale value.
  • 26. The Grayscale Value When 0 ≤ H < 360, 0 ≤ S ≤ 1 and 0 ≤ V ≤ 1: C = V × S X = C × (1 - |(H / 60°) mod 2 - 1|) m = V - C (R,G,B) = ((R‘+m)×255, (G‘+m)×255, (B‘+m)×255) HSV to RGB conversion Grayscale = 0.299R + 0.587G + 0.114B
  • 27. 1.4 An example of RGB to grayscale using the weighted method Here is an example of the grayscale conversion method used in a barcode scanner. As we can see in this image, the DataMatrix code on a Thai government lottery has red lines crossed over.
  • 28. The barcode scanner first converts the color image to grayscale and then binary. Using the average method, we get a grayscale image like this one:
  • 29. To further split the foreground (the DataMatrix code) from the white background with the red lines, let’s give a larger weight to the red channel. Grayscale = 1*Red + 0*Green + 0*Blue Here is the result. The red lines are lighter compared with the result from the average method, i.e., closer to white.
  • 30. Source code used for testing import cv2 RGB_image = cv2.imread("thai-government-lottery.png") blue = RGB_image[:,:,0] green = RGB_image[:,:,1] red = RGB_image[:,:,2] Average_Gray = blue/3+green/3+red/3 Weighted_Gray = (0 * blue) + (0* green) + (1 * red)
  • 31. 2. Binarization: Grayscale to black/white Conversion LOCAL THRESHOLDING — CALCULATES THE THRESHOLD PIXEL BY PIXEL GLOBAL THRESHOLDING — CALCULATES THE THRESHOLD ONCE FOR ALL PIXELS Binarization converts a grayscale image to a black/white image. This transformation is useful in detecting blobs and further reduces the computational complexity. The critical task is to find a suitable threshold. There are two main methods: The images below show an example of before and after binarization.
  • 32. 2.1 Local Thresholding Method With the local thresholding method, a threshold is calculated at each pixel, which depends on some local statistics such as mean, range, and the variance of the pixel neighborhood The image is divided into several sub-blocks, and the distribution of gray-value in each block was analyzed
  • 33. 2.2 Global Thresholding Method The global thresholding method takes advantage of the image histogram. The image histogram is a statistical graph with grayscale value on the x-axis and the number of pixels for each grayscale on the y-axis. Image histogram can be used to automatically determine the value of the threshold to be used for converting a grayscale image to a binary image. The basic idea is to find a point between the peak of the foreground pixel values and the peak of the background pixel values. If the intensity level of a pixel is smaller than the threshold, the pixel is set to black (grayscale = 0). Otherwise, it is set to white (grayscale = 255). The threshold serves as a dividing line.
  • 34. Different Ways to Convert Image to Grayscale in Python 1. Input Image. 2. Image Grayscale Conversion with Skimage (Scikit Image) – color. rgb2gray() 3. Image Grayscale Conversion with Pillow (PIL) – convert() 4. Image Grayscale Conversion with OpenCV – cv2. imread() 5. Image Grayscale Conversion with OpenCV – cv2. cvtColor()
  • 35. Image Grayscale Conversion with Pillow – convert Pillow is another image processing library of Python which can be used to convert image to grayscale with its img.convert function In this example, the image is read with Image.open and then it is transformed with convert by passing ‘L’ as the parameter The ‘L’ parameter is used to convert the image to grayscale
  • 36. In [1]: from PIL import Image img = Image.open('dog.jpg') imgGray = img.convert('L') imgGray.show() Out[1]: window_name='Grayscale Conversion OpenCV' cv2.namedWindow(window_name, cv2.WINDOW_NORMAL) cv2.imshow(window_name,img_gray) cv2.waitKey(0) cv2.destroyAllWindows()