Computer Vision Undergrad
Computer Vision Undergrad
1. # import libraries
2. from skimage import io 9. # Convert back to RGB
3. from skimage import color 10. img_rgb = color.xyz2rgb(img_xyz)
4. from skimage import data
11. # Show oth figures
12. figure(0)
5. # Read image 13. io.imshow(img_xyz)
6. img = io.imread('im5.jpg')
14. figure(1)
7. # Convert to XYZ 15. io.imshow(img_rgb)
8. img_xyz = color.rgb2xyz(img)
• Hue, Saturation, and Value (HSV) is a color model that is often used in
place of the RGB color model in graphics and paint programs. In using
this color model, a color is specified then white or black is added to
easily make color adjustments. HSV may also be called HSB (short for
hue, saturation and brightness).
• XYZ coordinates that are outside the locus of colors mapped by
the color matching experiments that led to the creation of the XYZ
color space are called imaginary colors. XYZ coordinates that are
inside the locus of colors mapped by the color matching experiments
are called real colors.
• Xyz is an additive color space based on how the eye intereprets
stimulus from light. Unlike other additive rgb like Rgb, Xyz is a purely
mathmatical space and the primary components are "imaginary",
meaning you can't create the represented color in the physical by
shining any sort of lights representing x, y, and z.
RGB to LAB and Vice Versa
• For the LAB color, L* indicates lightness, a* is the red/green
coordinate, and b* is the yellow/blue coordinate.
RGB to LAB and Vice Versa
• # import libraries
• from skimage import io • # Convert back to RGB
• from skimage import color • img_rgb = color.lab2rgb(img_lab)
• from skimage import data
• # Show oth figures
• figure(0)
• # Read image • io.imshow(img_lab)
• img = io.imread('im2.jpg')
• figure(1)
• # Convert to LAB • io.imshow(img_rgb)
• img_lab = color.rgb2lab(img)
Output
Example
1. from skimage import exposure 7. figure(0)
2. from skimage import io 8. io.imshow(gamma_corrected1)
3. from skimage import * 9. figure(1)
4. img = io.imread('ceci.jpg') 10. io.imshow(gamma_corrected2)
5. gamma_corrected1 =
exposure.adjust_gamma(img,
0.5)
6. gamma_corrected2 =
exposure.adjust_gamma(img, 5)
Output
Advanced image processing using openCV
• Advanced computer vision image processing is pursued using openCV.
OpenCV can examine the following concepts:
• Blending two images
• Changing the contrast and brightness of an image
• Adding text to images
• Smoothing images
• Changing the shape of images
• Effecting image thresholding
• Calculating gradients to detect edges
• Performing histogram equalization
Terms and definitions
• cv2.addWeighted(): This function blends the two images.
• alpha and beta parameters indicate the transparency in both images.
• gamma is a scalar, which is added to formulas to transform images
more effectively. In general, gamma is zero.
• cv2.imshow(): Similar to skimage.io.imshow(), cv2. imshow() helps to
display the image in a new window.
• cv2.waitKey(): waitKey() is used so that the window displaying the
output remains until we click Close or press Escape. If we do not
include this function after cv2.imshow(), the images are not displayed.
• cv2.DestroyAllWindows(): After we have clicked Close or pressed
Escape, this function destroys all the windows that have been opened
and saved in the memory.
Changing contrast and brightness
• To change contrast and brightness in an image, we should have an
understanding of what these two terms mean: