CONCOT OF IMAGE USING OPEN CV AND BACKGROUND ... - …



CONCOT OF IMAGE USING OPEN CV AND BACKGROUND SUBTRACTINGM V PAVAN KUMAR Asst.ProfessorDept. of MCAKBN College VijayawadaAbstract:Open CV is an Image and Video Processing Library with bindings of C,C++,Python and java.OpenCV is used for all sorts of image and video analysis, like facial recognition and detection, license plate reading, photo editing, advanced robotic vision, optical character recognition. image processing is processing of images using mathematical operations by using any form of signal processing for which the input is an image, a series of images, or a video, such as a photograph or video frame; the output of image processing may be either an image or a set of characteristics. In this paper an image is background subtracting, color filtering and Edge detection is used to recognize the objects in the Images.Keywords: BackGroundSubstracting, color Filtering, Edge Detection, Object Recognition.Introduction:In electrical engineering and computer science, Image processing is any form of processing for which the input is an image or a series of images or videos, such as photographs or frames of video. The output of image processing can be either an image or a set of characteristics or parameters related to the image.It also mean "Analyzing and manipulating images with a computer". Image processing is performed in three steps:First, import images with an optical device like a scanner or a camera or directly through digital processing.Second, manipulate or analyze the images in some way. This step can include image improvement and data summary, or the images are analyzed to find rules that aren't seen by the human eyes. For example, meteorologists use this processing to analyze satellite photographs.Last, output the result of image processing. The result might be the image changed by some way or it might be a report based on analysis or result of the images.Image processing usually means "digital" image processing, but optical and analog image processing are also included in image processing.We use the function cv2.imread() to read the image.cv2.IMREAD_COLOR: Loads a color image. Any transparency of image will be neglected. It is the default flag. cv2.IMREAD_GRAYSCALE: Loads image in grayscale mode cv2.IMREAD_UNCHANGED: Loads image as such including alpha channel.import numpy as npimport cv2# Load an color image in grayscaleimg = cv2.imread('messi5.jpg',0)To display the image we use the following codecv2.imshow('image',img)cv2.waitKey(0)cv2.destroyAllWindows()066294000A screenshot of the window will look like this (in Fedora-Gnome machine):cv2.waitKey() is a keyboard binding function. Its argument is the time in milliseconds. The function waits for specified milliseconds for any keyboard event. If you press any key in that time, the program continues. If 0 is passed, it waits indefinitely for a key stroke. It can also be set to detect specific key strokes like, if key a is pressed etc which we will discuss below.cv2.destroyAllWindows() simply destroys all the windows we created. If you want to destroy any specific window, use the function cv2.destroyWindow() where you pass the exact window name as the argument.We can summarize the code for image as followsimport numpy as npimport cv2img = cv2.imread('messi5.jpg',0)cv2.imshow('image',img)k = cv2.waitKey(0)if k == 27: # wait for ESC key to exit cv2.destroyAllWindows()elif k == ord('s'): # wait for 's' key to save and exit cv2.imwrite('messigray.png',img) cv2.destroyAllWindows() Matplotlib is a plotting library for Python which gives you wide variety of plotting methods. You will see them in coming articles. Here, you will learn how to display image with Matplotlib. You can zoom images, save it etc using Matplotlib.import numpy as npimport cv2from matplotlib import pyplot as pltimg = cv2.imread('messi5.jpg',0)plt.imshow(img, cmap = 'gray', interpolation = 'bicubic')plt.xticks([]), plt.yticks([]) # to hide tick values on X and Y axisplt.show().3086100419100000211455000There are some operations for OpenCV that you will not be able to do without a full installation of OpenCV (about 3GB in size), but you can actually do quite a bit with the fairly minimal installation of python-OpenCV. We will wind up using the full installation of OpenCV later in this series, so you can feel free to get it if you like, but these 3 modules will keep us busy for a while.30861001651635003086100280924000First, we should understand a few basic assumptions and paradigms when it comes to image and video analysis. With the way just about every video camera records today, recordings are actually frames, displayed one after another, 30-60+ times a second. At the core, however, they are static frames, just like images. Thus, image recognition and video analysis use identical methods for the most part. Some things, like directional tracking, is going to require a succession of images (frames), but something like facial detection, or object recognition can be done with almost the exact same code on images and video.02349500We can perform in OpenCV by followingBACKGROUND SUBSTRACTINGCOLOR FILTERING:EDGE DETECTION:-22098064579500FEATURE MATCHING FOR OBJECT RECOGNITION-9525033464500GENERAL OBJECT RECOGNITION:321564023939500In the case of edge detection, the black corresponds to pixel values of (0,0,0), and white lines are (255,255,255). Every picture and frame from a video breaks down to pixels like this, and we can deduce, like in the case of edge detection, where edges are based on where the white pixels are compared to black. import cv2import numpy as npfrom matplotlib import pyplot as pltimg = cv2.imread('watch.jpg',cv2.IMREAD_GRAYSCALE)cv2.imshow('image',img)cv2.waitKey(0)cv2.destroyAllWindows()First, we are importing a few things, those three modules I had you all install. Next, we define img to be cv2.read(image file, parms). The default is going to be IMREAD_COLOR, which is color without any alpha channel. If you're not familiar, alpha is the degree of opaqueness (the opposite of transparency). If you need to retain the alpha channel, you can also use IMREAD_UNCHANGED. Many times, you will be reading in the color version, and later converting it to gray. If you do not have a webcam, this will be the main method you will use throughout this tutorial, loading an image.We can also use simple numbers. You should be familiar with both options, so you understand what the person is doing. For the second parameter, you can use -1, 0, or 1. Color is 1, grayscale is 0, and the unchanged is -1. Thus, for grayscale, one could do img = cv2.imread('watch.jpg', 0)For this temporary example, we will use the following image:import numpy as npimport cv2img=cv2.imread('watch.jpg',cv2.IMREAD_COLOR)cv2.line(img,(0,0),(150,150),(255,255,255),15)cv2.imshow('image',img)cv2.waitKey(0)cv2.destroyAllWindows()2667020193000Conclusion:Using Image Processing we can change the Images between different color spaces ,apply geometric transformations to images like rotation and translation.Image thresholding is the process of converting binary images to threshold images and we can blur the images and can apply filtering, apply gradients and develop histograms in OpenCV like Fourier transformation , detecting circles in images and extract the foreground for a image. ................
................

In order to avoid copyright disputes, this page is only a partial summary.

Google Online Preview   Download