Import cv2.cv as cv
# Load image
Filename = "../Video/cat.jpg"
Image = cv. LoadImage (filename)
# Set created image
Size = cv. GetSize (image) # (100,100)
Depth = 8
Channels = 1
Grayscale Processing
Gray = cv. CreateImage (size, depth, channels) # create one 100x100 single channels image
Cv. CvtColor (image, gray, cv. CV_BGR2GRAY)
Smooth de-noise, making the place where the image changes dramatically over-smooth, that is, blurring the line between different colors on the Image
Smooth = cv. CreateImage (size, depth, channels)
Cv. Smooth (gray, smooth, cv. CV_MEDIAN)
Balance operation: Calculate the pixel value of an image, draw a histogram, and then balance (the impression is to make the histogram distribution closer to the normal distribution) www.2cto.com
Equalize = cv. CreateImage (size, depth, channels)
Cv. Smooth (gray, equalize)
Laplace operation: You can highlight the outlines in an image.
Laplace = cv. CreateImage (size, depth, channels) # create one 100x100 single channels image
Cv. CvtColor (image, Laplace, cv. CV_BGR2GRAY)
Dst_16s2 = cv. CreateImage (size, cv. IPL_DEPTH_16S, 1)
Cv. Laplace (Laplace, dst_16s2)
Cv. Convert (dst_16s2, Laplace)
# Create a window
Win_name1 = "gray"
Win_name2 = "smooth"
Win_name3 = "equalize"
Win_name4 = "Laplace"
Cv. NamedWindow (win_name1)
Cv. NamedWindow (win_name2)
Cv. NamedWindow (win_name3)
Cv. NamedWindow (win_name4)
# Cv. NamedWindow (win_name5)
Cv. ShowImage (win_name1, gray)
Cv. ShowImage (win_name2, smooth)
Cv. ShowImage (win_name3, equalize)
Cv. ShowImage (win_name4, Laplace)
Cv. WaitKey ()
Grayscale result
Smooth Noise Removal
Histogram equalization result
Laplace operation result