SlideShare a Scribd company logo
1 of 60
Chris Jordan G. Aliac M.C.S.
Research Coordinator
Intelligent Systems Lab.
Cebu Institute of Technology
Topics
 Image Properties
 Pixels/Color Property
 Image Size
 Loading an image
 Saving an Image
Topics
 Basic Image Manipulations
 Basic Pixel Copy
 GreyScaling
 Color Inversion
 Analysis of Images
 Histograms
 Image Contrasting
 Equalization vs Brightness
Topics
 Image POSE/SIZE
 Flipping (horizontal/Vertical)
 Rotation
 Scaling
 Binary Operations on images
 Thresholding
 Image Subtraction
Topic
 Dynamic Frames
 WebCam Input
 Application of Static Image process techniques
 Pointer Based Systems
 Method vs Pointers
 Convolution Matrix
 Definition
 Calculation
Topic
 Convolution Matrix Samples
 Smooth
 Gaussian Blur
 Mean Removal
 Sharpen
 Emboss
 Edge Detection
 Sobel
 Prewitt
 Kirsh
What is Image Processing?
 Manipulation of the properties of images for the
following uses:
 Analysis
 Enhancement
 Systems Application
 Data Acquisition
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
Sample
0,0,0
255,255,255
MSPAINT
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
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
pigment
Colored Light vs. Color Pigment
light
RGB color space
CMYK color space
Image Size
Image Width = Number of Columns = X
data on 2D space
Image Height =
Number of Rows =
Y data on 2D
space
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
Images on C#
 An image is represented as a Bitmap in C#
 Images are loaded as Bitmaps and placed to view
on a PictureBox
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)
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)”
GrayScaling
 The Term GrayScaling is the convertion of colors
to different shades of gray.
 Misconception: GrayScaling is not called “BLACK
AND WHITE”
RGB Space Map
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.
 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
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
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
HISTOGRAM
HISTOGRAM
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
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
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)
Brightness
Contrast
See The Difference
 You Judge for Yourself
 What is the Difference between Brightness and
Contrast?
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
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 θ
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
example
 Large to small
1 2 3 4
5 6 7 8
9 10 11 12
13 14 15 16
1 3
9 11
Example
 Small to large
1 2
3 4
1 1 2 2
1 1 2 2
3 3 4 4
3 3 4 4
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
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
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
Dynamic Processing
 You need to have a real time image acquisition
device
 Camera
 Video Stream
 Video Clip
Simple requirements
 In this case, we will be using a simple WEBCAM.
The camera must be properly installed with the
right manufactured drivers
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
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
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)
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.
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)
How to class functions
 Public static Device[] getAllDevices() = gets all
available camera devices
 public static Device GetDevice(int deviceIndex) =
gets the current available device
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#
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
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);
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
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
Convolution Matrix
Samples
 Smooth
 Gaussian Blur
1 1 1
1 Weight 1
1 1 1
1 1 1
2 Weight 2
1 2 1
 Mean Removal
 Sharpen
-1 -1 -1
-1 Weight -1
-1 -1 -1
0 0 0
-2 Weight -2
0 -2 0
 Emboss
-1 -1 -1
0 4 0
-1 0 -1
Edge Detection
 Sobel
 Prewitt
1 0 -1
2 0 -2
1 0 -1
-1 0 1
-1 0 1
-1 0 1
Edge Detection
 Kirsh
5 -3 -3
5 0 -3
5 -3 -3
Others
 Explore other color Space Maps like HSL
 Avid C# programmers can use the color Matrix to
do color manipulations
THANK YOU
chris.jordan.aliac@cit.edu

More Related Content

Similar to Image_Processing_LECTURE_c#_programming.ppt

19BCS1815_PresentationAutomatic Number Plate Recognition(ANPR)P.pptx
19BCS1815_PresentationAutomatic Number Plate Recognition(ANPR)P.pptx19BCS1815_PresentationAutomatic Number Plate Recognition(ANPR)P.pptx
19BCS1815_PresentationAutomatic Number Plate Recognition(ANPR)P.pptx
SamridhGarg
 

Similar to Image_Processing_LECTURE_c#_programming.ppt (20)

Log polar coordinates
Log polar coordinatesLog polar coordinates
Log polar coordinates
 
4 image enhancement in spatial domain
4 image enhancement in spatial domain4 image enhancement in spatial domain
4 image enhancement in spatial domain
 
Dip review
Dip reviewDip review
Dip review
 
Digital Image Processing
Digital Image ProcessingDigital Image Processing
Digital Image Processing
 
Computer graphics
Computer graphicsComputer graphics
Computer graphics
 
A Biometric Approach to Encrypt a File with the Help of Session Key
A Biometric Approach to Encrypt a File with the Help of Session KeyA Biometric Approach to Encrypt a File with the Help of Session Key
A Biometric Approach to Encrypt a File with the Help of Session Key
 
Digital.cc
Digital.ccDigital.cc
Digital.cc
 
IRJET- 3D Vision System using Calibrated Stereo Camera
IRJET- 3D Vision System using Calibrated Stereo CameraIRJET- 3D Vision System using Calibrated Stereo Camera
IRJET- 3D Vision System using Calibrated Stereo Camera
 
Ch6
Ch6Ch6
Ch6
 
Ch06
Ch06Ch06
Ch06
 
CBIR Final project1
CBIR Final project1CBIR Final project1
CBIR Final project1
 
Automated Face Detection System
Automated Face Detection SystemAutomated Face Detection System
Automated Face Detection System
 
cvpresentation-190812154654 (1).pptx
cvpresentation-190812154654 (1).pptxcvpresentation-190812154654 (1).pptx
cvpresentation-190812154654 (1).pptx
 
ppt 20BET1024.pptx
ppt 20BET1024.pptxppt 20BET1024.pptx
ppt 20BET1024.pptx
 
Eugene Khvedchenya. State of the art Image Augmentations with Albumentations.
Eugene Khvedchenya. State of the art Image Augmentations with Albumentations.Eugene Khvedchenya. State of the art Image Augmentations with Albumentations.
Eugene Khvedchenya. State of the art Image Augmentations with Albumentations.
 
Optical Watermarking Literature survey....
Optical Watermarking Literature survey....Optical Watermarking Literature survey....
Optical Watermarking Literature survey....
 
Image processing for robotics
Image processing for roboticsImage processing for robotics
Image processing for robotics
 
Image Processing(Beta1)
Image Processing(Beta1)Image Processing(Beta1)
Image Processing(Beta1)
 
mini prjt
mini prjtmini prjt
mini prjt
 
19BCS1815_PresentationAutomatic Number Plate Recognition(ANPR)P.pptx
19BCS1815_PresentationAutomatic Number Plate Recognition(ANPR)P.pptx19BCS1815_PresentationAutomatic Number Plate Recognition(ANPR)P.pptx
19BCS1815_PresentationAutomatic Number Plate Recognition(ANPR)P.pptx
 

Recently uploaded

一比一原版(曼大毕业证书)曼尼托巴大学毕业证成绩单留信学历认证一手价格
一比一原版(曼大毕业证书)曼尼托巴大学毕业证成绩单留信学历认证一手价格一比一原版(曼大毕业证书)曼尼托巴大学毕业证成绩单留信学历认证一手价格
一比一原版(曼大毕业证书)曼尼托巴大学毕业证成绩单留信学历认证一手价格
q6pzkpark
 
如何办理(Dalhousie毕业证书)达尔豪斯大学毕业证成绩单留信学历认证
如何办理(Dalhousie毕业证书)达尔豪斯大学毕业证成绩单留信学历认证如何办理(Dalhousie毕业证书)达尔豪斯大学毕业证成绩单留信学历认证
如何办理(Dalhousie毕业证书)达尔豪斯大学毕业证成绩单留信学历认证
zifhagzkk
 
Abortion pills in Doha {{ QATAR }} +966572737505) Get Cytotec
Abortion pills in Doha {{ QATAR }} +966572737505) Get CytotecAbortion pills in Doha {{ QATAR }} +966572737505) Get Cytotec
Abortion pills in Doha {{ QATAR }} +966572737505) Get Cytotec
Abortion pills in Riyadh +966572737505 get cytotec
 
如何办理(UPenn毕业证书)宾夕法尼亚大学毕业证成绩单本科硕士学位证留信学历认证
如何办理(UPenn毕业证书)宾夕法尼亚大学毕业证成绩单本科硕士学位证留信学历认证如何办理(UPenn毕业证书)宾夕法尼亚大学毕业证成绩单本科硕士学位证留信学历认证
如何办理(UPenn毕业证书)宾夕法尼亚大学毕业证成绩单本科硕士学位证留信学历认证
acoha1
 
Abortion Clinic in Kempton Park +27791653574 WhatsApp Abortion Clinic Service...
Abortion Clinic in Kempton Park +27791653574 WhatsApp Abortion Clinic Service...Abortion Clinic in Kempton Park +27791653574 WhatsApp Abortion Clinic Service...
Abortion Clinic in Kempton Park +27791653574 WhatsApp Abortion Clinic Service...
mikehavy0
 
Reconciling Conflicting Data Curation Actions: Transparency Through Argument...
Reconciling Conflicting Data Curation Actions:  Transparency Through Argument...Reconciling Conflicting Data Curation Actions:  Transparency Through Argument...
Reconciling Conflicting Data Curation Actions: Transparency Through Argument...
Bertram Ludäscher
 
如何办理(UCLA毕业证书)加州大学洛杉矶分校毕业证成绩单学位证留信学历认证原件一样
如何办理(UCLA毕业证书)加州大学洛杉矶分校毕业证成绩单学位证留信学历认证原件一样如何办理(UCLA毕业证书)加州大学洛杉矶分校毕业证成绩单学位证留信学历认证原件一样
如何办理(UCLA毕业证书)加州大学洛杉矶分校毕业证成绩单学位证留信学历认证原件一样
jk0tkvfv
 
Displacement, Velocity, Acceleration, and Second Derivatives
Displacement, Velocity, Acceleration, and Second DerivativesDisplacement, Velocity, Acceleration, and Second Derivatives
Displacement, Velocity, Acceleration, and Second Derivatives
23050636
 
Abortion pills in Riyadh Saudi Arabia (+966572737505 buy cytotec
Abortion pills in Riyadh Saudi Arabia (+966572737505 buy cytotecAbortion pills in Riyadh Saudi Arabia (+966572737505 buy cytotec
Abortion pills in Riyadh Saudi Arabia (+966572737505 buy cytotec
Abortion pills in Riyadh +966572737505 get cytotec
 

Recently uploaded (20)

一比一原版(曼大毕业证书)曼尼托巴大学毕业证成绩单留信学历认证一手价格
一比一原版(曼大毕业证书)曼尼托巴大学毕业证成绩单留信学历认证一手价格一比一原版(曼大毕业证书)曼尼托巴大学毕业证成绩单留信学历认证一手价格
一比一原版(曼大毕业证书)曼尼托巴大学毕业证成绩单留信学历认证一手价格
 
Credit Card Fraud Detection: Safeguarding Transactions in the Digital Age
Credit Card Fraud Detection: Safeguarding Transactions in the Digital AgeCredit Card Fraud Detection: Safeguarding Transactions in the Digital Age
Credit Card Fraud Detection: Safeguarding Transactions in the Digital Age
 
Identify Rules that Predict Patient’s Heart Disease - An Application of Decis...
Identify Rules that Predict Patient’s Heart Disease - An Application of Decis...Identify Rules that Predict Patient’s Heart Disease - An Application of Decis...
Identify Rules that Predict Patient’s Heart Disease - An Application of Decis...
 
如何办理(Dalhousie毕业证书)达尔豪斯大学毕业证成绩单留信学历认证
如何办理(Dalhousie毕业证书)达尔豪斯大学毕业证成绩单留信学历认证如何办理(Dalhousie毕业证书)达尔豪斯大学毕业证成绩单留信学历认证
如何办理(Dalhousie毕业证书)达尔豪斯大学毕业证成绩单留信学历认证
 
Digital Transformation Playbook by Graham Ware
Digital Transformation Playbook by Graham WareDigital Transformation Playbook by Graham Ware
Digital Transformation Playbook by Graham Ware
 
Northern New England Tableau User Group (TUG) May 2024
Northern New England Tableau User Group (TUG) May 2024Northern New England Tableau User Group (TUG) May 2024
Northern New England Tableau User Group (TUG) May 2024
 
Introduction to Statistics Presentation.pptx
Introduction to Statistics Presentation.pptxIntroduction to Statistics Presentation.pptx
Introduction to Statistics Presentation.pptx
 
Abortion pills in Doha {{ QATAR }} +966572737505) Get Cytotec
Abortion pills in Doha {{ QATAR }} +966572737505) Get CytotecAbortion pills in Doha {{ QATAR }} +966572737505) Get Cytotec
Abortion pills in Doha {{ QATAR }} +966572737505) Get Cytotec
 
Bios of leading Astrologers & Researchers
Bios of leading Astrologers & ResearchersBios of leading Astrologers & Researchers
Bios of leading Astrologers & Researchers
 
Predictive Precipitation: Advanced Rain Forecasting Techniques
Predictive Precipitation: Advanced Rain Forecasting TechniquesPredictive Precipitation: Advanced Rain Forecasting Techniques
Predictive Precipitation: Advanced Rain Forecasting Techniques
 
如何办理(UPenn毕业证书)宾夕法尼亚大学毕业证成绩单本科硕士学位证留信学历认证
如何办理(UPenn毕业证书)宾夕法尼亚大学毕业证成绩单本科硕士学位证留信学历认证如何办理(UPenn毕业证书)宾夕法尼亚大学毕业证成绩单本科硕士学位证留信学历认证
如何办理(UPenn毕业证书)宾夕法尼亚大学毕业证成绩单本科硕士学位证留信学历认证
 
SCI8-Q4-MOD11.pdfwrwujrrjfaajerjrajrrarj
SCI8-Q4-MOD11.pdfwrwujrrjfaajerjrajrrarjSCI8-Q4-MOD11.pdfwrwujrrjfaajerjrajrrarj
SCI8-Q4-MOD11.pdfwrwujrrjfaajerjrajrrarj
 
Abortion Clinic in Kempton Park +27791653574 WhatsApp Abortion Clinic Service...
Abortion Clinic in Kempton Park +27791653574 WhatsApp Abortion Clinic Service...Abortion Clinic in Kempton Park +27791653574 WhatsApp Abortion Clinic Service...
Abortion Clinic in Kempton Park +27791653574 WhatsApp Abortion Clinic Service...
 
Reconciling Conflicting Data Curation Actions: Transparency Through Argument...
Reconciling Conflicting Data Curation Actions:  Transparency Through Argument...Reconciling Conflicting Data Curation Actions:  Transparency Through Argument...
Reconciling Conflicting Data Curation Actions: Transparency Through Argument...
 
Seven tools of quality control.slideshare
Seven tools of quality control.slideshareSeven tools of quality control.slideshare
Seven tools of quality control.slideshare
 
如何办理(UCLA毕业证书)加州大学洛杉矶分校毕业证成绩单学位证留信学历认证原件一样
如何办理(UCLA毕业证书)加州大学洛杉矶分校毕业证成绩单学位证留信学历认证原件一样如何办理(UCLA毕业证书)加州大学洛杉矶分校毕业证成绩单学位证留信学历认证原件一样
如何办理(UCLA毕业证书)加州大学洛杉矶分校毕业证成绩单学位证留信学历认证原件一样
 
RESEARCH-FINAL-DEFENSE-PPT-TEMPLATE.pptx
RESEARCH-FINAL-DEFENSE-PPT-TEMPLATE.pptxRESEARCH-FINAL-DEFENSE-PPT-TEMPLATE.pptx
RESEARCH-FINAL-DEFENSE-PPT-TEMPLATE.pptx
 
Las implicancias del memorándum de entendimiento entre Codelco y SQM según la...
Las implicancias del memorándum de entendimiento entre Codelco y SQM según la...Las implicancias del memorándum de entendimiento entre Codelco y SQM según la...
Las implicancias del memorándum de entendimiento entre Codelco y SQM según la...
 
Displacement, Velocity, Acceleration, and Second Derivatives
Displacement, Velocity, Acceleration, and Second DerivativesDisplacement, Velocity, Acceleration, and Second Derivatives
Displacement, Velocity, Acceleration, and Second Derivatives
 
Abortion pills in Riyadh Saudi Arabia (+966572737505 buy cytotec
Abortion pills in Riyadh Saudi Arabia (+966572737505 buy cytotecAbortion pills in Riyadh Saudi Arabia (+966572737505 buy cytotec
Abortion pills in Riyadh Saudi Arabia (+966572737505 buy cytotec
 

Image_Processing_LECTURE_c#_programming.ppt

  • 1. Chris Jordan G. Aliac M.C.S. Research Coordinator Intelligent Systems Lab. Cebu Institute of Technology
  • 2. Topics  Image Properties  Pixels/Color Property  Image Size  Loading an image  Saving an Image
  • 3. Topics  Basic Image Manipulations  Basic Pixel Copy  GreyScaling  Color Inversion  Analysis of Images  Histograms  Image Contrasting  Equalization vs Brightness
  • 4. Topics  Image POSE/SIZE  Flipping (horizontal/Vertical)  Rotation  Scaling  Binary Operations on images  Thresholding  Image Subtraction
  • 5. Topic  Dynamic Frames  WebCam Input  Application of Static Image process techniques  Pointer Based Systems  Method vs Pointers  Convolution Matrix  Definition  Calculation
  • 6. Topic  Convolution Matrix Samples  Smooth  Gaussian Blur  Mean Removal  Sharpen  Emboss  Edge Detection  Sobel  Prewitt  Kirsh
  • 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
  • 13. pigment Colored Light vs. Color Pigment light RGB color space CMYK color space
  • 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
  • 37. Example  Small to large 1 2 3 4 1 1 2 2 1 1 2 2 3 3 4 4 3 3 4 4
  • 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
  • 54. Convolution Matrix Samples  Smooth  Gaussian Blur 1 1 1 1 Weight 1 1 1 1 1 1 1 2 Weight 2 1 2 1
  • 55.  Mean Removal  Sharpen -1 -1 -1 -1 Weight -1 -1 -1 -1 0 0 0 -2 Weight -2 0 -2 0
  • 56.  Emboss -1 -1 -1 0 4 0 -1 0 -1
  • 57. Edge Detection  Sobel  Prewitt 1 0 -1 2 0 -2 1 0 -1 -1 0 1 -1 0 1 -1 0 1
  • 58. Edge Detection  Kirsh 5 -3 -3 5 0 -3 5 -3 -3
  • 59. Others  Explore other color Space Maps like HSL  Avid C# programmers can use the color Matrix to do color manipulations