7. What is Image Processing?
Manipulation of the properties of images for the
following uses:
Analysis
Enhancement
Systems Application
Data Acquisition
8. IMAGE
“A picture Paints a Thousand words” (wrong)
A picture is a million bytes…
Collection of Colors arranged on vector locations
A color in an image is a PIXEL (picture element)
COLOR = ALPHA + RED + GREEN + BLUE
Where: RED, GREEN, BLUE is a value between 0 – 255
A mixture of there components yield to a pixel color
11. RGB color space interior
planes
0,0,1 1,1,1
0,0,0 1,1,0
1,1,1
0,0,0
1,0,0
0,1,1
12. Color Spaces
RGB (Red, Green, Blue)
- used for screen displays (e.g. monitor)
CMYK (Cyan, Magenta, Yellow, Black)
- used for printing
HSI (Hue, Saturation, Intensity)
- used for manipulation of color components
L*a*b*, L*u*v* (“perceptual” color spaces)
- distances in color space correspond
to distances in human color perception
14. Image Size
Image Width = Number of Columns = X
data on 2D space
Image Height =
Number of Rows =
Y data on 2D
space
15. Images Processing in C#
C# is a programming language that is the main
flagship tool for .NET tech. (Microsoft)
Environment feels like JAVA but looks like Visual
Basic.
Contains Easy Managed Codes from the .NET
Framework
16. Images on C#
An image is represented as a Bitmap in C#
Images are loaded as Bitmaps and placed to view
on a PictureBox
17. Loading/Saving
Loading images can be done by using the
instruction:
○ Image.FromImage(“filename);
For Ease of File selection, use a Dialogs to get the
filename string.
(demo)
18. Basic Image
Manipulations
Basic Copy
This is done by scanning all the pixels and copy each
pixel into another empty bitmap.
Taking color samples is done via “GetPixel()”
Placing colors to a specified vector location is done via
“SetPixel()”
Colors can also be manufactured by a Color class
method “Color.FromARGB(byte,byte,byte)”
19. GrayScaling
The Term GrayScaling is the convertion of colors
to different shades of gray.
Misconception: GrayScaling is not called “BLACK
AND WHITE”
21. GrayScale
To obtain different shades of grey, the average of
the color properties must be done.
pixel = R = G = B =(R+G+B)/3
This must be done for all pixels in the image.
22. Converting an image to Grayscale form is
essential to faster analysis and computation
because the image data has been reduced in its
one dimensional form (1 byte)
Grayscale
23. Color Inversion
Our eyes accept light from dark spaces
We see better colors with more light gathered by
our eyes
Inversion is the opposite of this concept as light is
taken away by the color values.
pixel = 255-R , 255 - G, 255 – B
this is done for all pixels
24. Analysis of Images
An image must be converted into data that is easy
to analyze on the mathematical scale.
Image must analyzed for further application of for
estimation for the correct enhancement of images
The easiest way of doing this is by representing
an image into a 2D space where x is the degree of
image intensity and y as the magnitude of the
intensity
This is called a HISTORGRAM
27. HISTOGRAM
Higher Magnitudes toward 255 level for light
colored images
Higher Magnitudes toward 0 level for dark colored
images
This is done scanning all pixels and counting all
the color of different levels
28. Example
Step 1 Convert the image to grayscale.
Step 2 Use an array to count up pixels of same levels
Step 3 Plot the values of the array on a bitmap graph
0 0 0
50 50 255
255 255 255
0 1 ….. 50 …. ….. ….. ….. …. 255
3 0 0 2 0 0 0 0 0 4
29. Image Intensity
Brightness
This Process is done by adding the magnitude for all
pixels by the same factor.
Contrast
This is done by evenly distributing magnitude data over
the histogram (HISTOGRAM EQUALIZATION)
32. See The Difference
You Judge for Yourself
What is the Difference between Brightness and
Contrast?
33. Flipping
Flipping: An image translation tool for creating
mirror images from the original image
This can be done in 2 ways:
○ Horizontal:
- taking pixels from original image at 0 to width-1 columns
- Placing each pixel taken to empty bitmap at width-1 to 0 columns
○ Vertical
- taking pixels from original image at 0 to height-1 rows
- Placing each pixel taken to empty bitmap at height-1 to 0 rows
34. Rotation
Using a rotation matrix will make the image rotate
at positive degrees (clockwise) or negative
degrees (counter-clockwise)
x` cos θ - sin θ x
y` sin θ cos θ y
0 0 1
x`= xcos θ + y(-sin θ )
y`=xsin θ +ysin θ
35. Scaling
An image of any size can be resized to any
desired width and height
Large to Small size: samples from original image will be
taken an placed on a smaller, empty bitmap.
Small to Large: samples from original image will be
taken an placed numerous times on a larger empty
bitmap.
xSource = xTarget * origwidth / targetWidth
ySource = yTarget * origheight / targetHeight
36. example
Large to small
1 2 3 4
5 6 7 8
9 10 11 12
13 14 15 16
1 3
9 11
38. Binary Operations
Thresholding: A method used to convert images to
extreme values 0 (black) 1 (white)
Useful for converting images from colored to this format
for old dot matrix printers
Good tool for determining objects of study without the
image noise
39. Thresholding
Step1 : convert the image to grayscale
Step2 : compare the image grayscale data with a
limit value
If data is less than the limit = convert the pixel to black
Else , convert pixel to white
40. Subtraction
Image tool for comparing 2 images and detect
differences on them
For all pixels
○ result = |A(x,y)-B(x,y)|
where A and B are images taken with colors of the same location.
If result is > than limit sensitivity value then a pixel has
changed from its original image A
41. Dynamic Processing
You need to have a real time image acquisition
device
Camera
Video Stream
Video Clip
42. Simple requirements
In this case, we will be using a simple WEBCAM.
The camera must be properly installed with the
right manufactured drivers
43. DLL
A DLL or Direct Link Library is a system file that
references your newly installed hardware to the
operating system
DLL’s communicate between the main application
program interface (device) and to the operating system
The concept of communication is to send “message” to
system files DLL to and fro the application
44. C# DLL
C# can easily create DLL’s and can also easily
manipulate predefined and user defined DLL’s
using the dllimport instruction
This makes C# the ideal tool for creating user
friendly applications that are powerful enough to
handle devices
45. How to?
I have already made two C# classes
Device.cs = a class that sends Messages to the DLL
DeviceManager.cs = functions/methods that manipulate
the Device.cs class
Both these classes are of the same namespace
(WebCamLib)
46. How to
Device.cs class manipulates a certain DLL called
AVICAP.DLL
The AVICAP.DLL is a system file that generically
manipulates any webcam devices installed onto
the computer.
47. How to class functions
Public void showWindow (object) = shows the
preview of the images on the camera
Public void stop() = stops camera preview
Public void sendMessage() = sends refresh data
instructions to the camera (devicehandle)
48. How to class functions
Public static Device[] getAllDevices() = gets all
available camera devices
public static Device GetDevice(int deviceIndex) =
gets the current available device
49. How to steps
Upon loading, get all devices by calling the
getAllDevice() function
Select the certain device and use the
showWindow() function
Place the preview onto a picture box object in c#
50. How to process
images
Images are processed via bitmap casting of the
image
Once a bitmap is made out of an image, pixels are
analyzed for further enhancement and or
alteration
51. How to
IDataObject data;
Image bmap;
Device d = DeviceManager.GetDevice(listBox1.SelectedIndex);
d.Sendmessage();
data=Clipboard.GetDataObject();
bmap = (Image)(data.GetData("System.Drawing.Bitmap",true));
Bitmap b=new Bitmap(bmap);
52. Pointer Based DIP
A pointer is used to access address location of the
actual image and manipulate its RGB pixels
This process is faster than the managed code
method
53. Convolution Matrix
Convolution matrix is used to manipulate pixels
and its neighboring pixels to a desired effect
Normal convolution image is an 3x3 pixel matrix
compared to each 3x3 grid pixel
COMPUTATION
∑[3x3][3x3matrix]/factor + offset value
topleft topmid Topright
left pixel right
bottomleft bottommid bottomright