Post on 13-Jan-2016
11
CS6825: Digital imagesCS6825: Digital images
How are How are DIGITALDIGITAL images created.images created.
Previous lecture we Previous lecture we discussed how discussed how ANALOG images ANALOG images are createdare created
22
Making Digital imagesMaking Digital images
1. Sampling image into pixels---- 1. Sampling image into pixels---- "picture element" "picture element"
2. Quantize the pixel value to make 2. Quantize the pixel value to make discrete or finitediscrete or finite
33
Sampling – the first stepSampling – the first step Model sensor “array” for a 2D camera, as a 2D array as Model sensor “array” for a 2D camera, as a 2D array as
shown on right.shown on right. We use rectangles even though the actual shape is not We use rectangles even though the actual shape is not
exactly this.exactly this. Some researches use more complicated sesnor array models Some researches use more complicated sesnor array models
…but, 2D array works adequately for many applications…but, 2D array works adequately for many applications
44
SAMPLING in more detailSAMPLING in more detail1. fit a grid over the image 1. fit a grid over the image
pixel location (r,c)=(row,column) pixel location (r,c)=(row,column)
2.Get value of pixel 2.Get value of pixel
Pixel(r,c) =(R,G,B) Pixel(r,c) =(R,G,B)
R = ∫ ∫ red(x,y) dx dy R = ∫ ∫ red(x,y) dx dy
(over pixel area)(over pixel area)
red(x,y) = function of red red(x,y) = function of red spectral energy at each spectral energy at each contiguous point in your contiguous point in your sensor sensor
55
Resolution, Size of ImageResolution, Size of Image Image size = (rows)*(colomns) Image size = (rows)*(colomns) Resolution = size of image = #pixels Resolution = size of image = #pixels low resolution ---> # of pixels is small low resolution ---> # of pixels is small high resolution ----> # of pixels is big high resolution ----> # of pixels is big HOW DO YOU SELECT A RESOLUTION?HOW DO YOU SELECT A RESOLUTION?
• if grid is too large you will get jagged edges if grid is too large you will get jagged edges • This is called Aliasing.This is called Aliasing.
No Aliasing Aliasing
66
QUANTIZATIONQUANTIZATION
Convert continuous values Convert continuous values to discreteto discretee.g. 1.222 -> 1.0e.g. 1.222 -> 1.0
Instead of infinite Instead of infinite colors we have a finitecolors we have a finitenumber of colors.number of colors.
Remember in computers Remember in computers we store things in bits.we store things in bits.
Cat image at 24 bits / pixel (over 16 million colors)8 bits each field – 8 /red, 8/green, 8/blue
Cat image at 4 bits / pixel (only 16 colors)
77
How to QUANTIZEHow to QUANTIZE Simple Quantization scheme:Simple Quantization scheme:
The rule to convert The rule to convert
If ZIf Zk-1k-1 <= pixel (r,c) <= Z <= pixel (r,c) <= Zkk then new pixel (r,c) = Qkthen new pixel (r,c) = Qk
ZZii = decision level = decision level (i = 0 to N)(i = 0 to N) QQkk = quantization level = quantization level (k = 0 to M)(k = 0 to M)
0
50
100
150
200
250
300
Z1 Z1 Z2 Z3 Z4 Z5
Continuous Pixel InputD
iscr
ete
Pix
el O
utp
ut
Q's
88
More QuantizationMore Quantization We can have more complicated We can have more complicated
quantization schemes as indicated by quantization schemes as indicated by the figures here and the quantization the figures here and the quantization boundaries in the red-green spaceboundaries in the red-green space
Image with no blue values only red and greenThe color space above produced by PhotoshopUsing 16-colors only, shows partitioning of space
99
More QuantizationMore Quantization We can have more complicated We can have more complicated
quantization schemes as indicated by quantization schemes as indicated by the figures here and the quantization the figures here and the quantization boundaries in the red-green spaceboundaries in the red-green space
Image with no blue values only red and greenThe color space above produced by PhotoshopUsing 16-colors only, shows partitioning of space
1010
With Our Simple Step Function With Our Simple Step Function Conversion – how select Q’s & Z’sConversion – how select Q’s & Z’s
The goal is to choose Q's & Z's to minimize error produced from The goal is to choose Q's & Z's to minimize error produced from quantization, E quantization, E where where E E = Expected value{(pixel- newpixel)*(pixel-newpixel )} = Expected value{(pixel- newpixel)*(pixel-newpixel )}
= mean squared error = mean squared error
Note: Note: error= (pixel value - new value) error= (pixel value - new value) expected value = a type of average or meanexpected value = a type of average or mean
If we try to minimize this error this leads to the following equation If we try to minimize this error this leads to the following equation
Qk=Qk= (Z (Zk+1k+1 + Z+ Zkk) / 2) / 2
So, Steps to follow are: So, Steps to follow are: choose Zchoose Zkk calculate Q's via above equationcalculate Q's via above equationCALLED “ UNIFORM QUANTIZATION” as it splits up the space uniformly CALLED “ UNIFORM QUANTIZATION” as it splits up the space uniformly
(evenly).(evenly).
1111
So, how do we choose Z’s?So, how do we choose Z’s?
Basically, it is function of image Basically, it is function of image contentcontent
You want more levels (Z values) You want more levels (Z values) in greyvalue or color ranges in in greyvalue or color ranges in which much of the image pixels which much of the image pixels fall. fall.
1212
Loss in making a Digital Image?Loss in making a Digital Image?
Loss from sampling? Loss from sampling? • Not if choose the correct number of Not if choose the correct number of
samples.samples.• Over-Sampling Over-Sampling = when you have more = when you have more
samples than you need samples than you need • Under-Sampling Under-Sampling = not enough samples are = not enough samples are
used used Loss from quantization?Loss from quantization?
• AlwaysAlways unless your analog unless your analog image miraculously happens to image miraculously happens to only have values at the only have values at the quantization levels.quantization levels.
Ok samples Under sampled
256 levels 8 levels
1313
How to choose the number of How to choose the number of samples (pixels)samples (pixels)
You need 2 times the You need 2 times the Nyquest rate.Nyquest rate.
Nyquest rate= Nyquest rate= function of highest function of highest frequency in the frequency in the image image
• highest frequency in highest frequency in image = function of image = function of fastest varying spatial fastest varying spatial patter in the image = patter in the image = f(how fast things f(how fast things change)change)
1414
ConclusionConclusion Discussed 2 steps involved in creating a digital Discussed 2 steps involved in creating a digital
image from an analog image: Sampling + image from an analog image: Sampling + Quantization.Quantization.
Discussed schemes for both Sampling and Discussed schemes for both Sampling and Quantization.Quantization.
Discussed how to avoid loss of information in Discussed how to avoid loss of information in Sampling and that you always loose Sampling and that you always loose information in the Quantization process.information in the Quantization process.