Image Splitting: 

In Today’s blog, As we understood the difference between image processing, let us now focus how to generate program to detect objects using database. The database is consisting of data collected from our version of Internet Crawlers (Our Spider of World Wide Web), repositories, and search engine AI. Database collected data from world wide web is mostly unstructured, means their data is not arrange properly, our first goals is to recognize website data and make it semi-structured for AI to read them. Now as soon the engine reads the user query it goes thorough the Semi-structured data, recognize the object thorough the user query and saves it to the database.
Today, I will discuss the basic steps needed to make an AI to split images and use the program as a function for future development. First step needed is to choose, what library functions are needed to make our AI Library, So we are using PIL (python Image libraries) for cutting and splitting images, cv2 for reading, smoothing, matching the object, and showing results. The second library we are using is numpy library because we are identifying the image as a 2-Dimensional array, which is highly optimized library for numerical operations with a MATLAB-Style 2D arrays; All the OpenCV array structures are converted to and from Numpy arrays. This makes it easier to integrate with the other libraries and also matplotlib to convert the RGB pattern to Grayscale. To use all this library first we need to download all of them on a Local or global folder for each individual library, downloading this library is not a simple task since these libraries are not the application but more like functional commands that can be used in programing, in other words using such library we are making an AI library. Python is preinstalled with some of the beginner’s library, but there is less utility of all them in programming.
To download these libraries, one needs to get familiar with how to use Command prompt, Now I would not cover how to install every single library because there are lot more blogs and Stack overflow post explaining the step by step procedure, one can easily get exact information from official websites of all the libraries I have mentioned but Websites and online communities like Stacks will give you some extra help if something went wrong in the procedure.
    First we take the OpenCV to read the user image and, we also want OpenCV function ‘imread’ to look into to database to load images from it with the new image and both the images are loaded in color format.  Now, Using PIL we must split the both the images in small box size.  Now as we need to match both outside image and database image we need to use the splitting method for both the images. There is multiple method you can split an image, but we are using PIL library to Manipulate image. For that we need to load both the image, so we make an array of two element, we purposely store both the images in the array so we need not to make redundant code for both the image, now we load the array for splitting the image, we need to sperate the height and width of the image, area variable and one more Variable in for loop. 
Now comes the part of designing our loop, in which we will tell program, what does it need to do in loop. So, We want both the width and height of the images that are loaded in the loop; for that I am going to make array for width and Height that will store shapes of the images. After that we take the images to split into square shape regardless of what the actual shape of the images originally. The new Height and Width we get are needed to be plotted on the image using the area variable. After the process of looping we save all the parts of the images in two different variables which will be used as a function in future programing.
 So the story does not finish here, now I am going to debug the program, since we have followed the steps correctly the program has not errors, so we do not have to worry for error codes but it is really good habit to test the program. So I am  trying to display the cropped parts of the images. According to me, we are using a new variable to save the cropped/parts of images, which it does not work, so let’s me make changes in code. We are no more using the new variable instead we will use the original variable where we read the image.

 So , now the we are getting an cv2.error: C:\projects\opencv-python\opencv\modules\highgui\src\window.cpp:325: error: (-215) size.width>0 && size.height>0 in function cv::imshow. Which mean that program in window,cpp has some command in line 325 that is differing in our code. But when you open Windows.cpp you see there is nothing on line 325. I am going to ask for some assistance regrading it. So, as per some help from Sadik Erison, he have suggested me to use micro level function in looping. Instead of macro level, so I am making changes in the code according to the suggestion So far I am going to omit numpy and use python math library for calculation and going to convert the image as 2d array manually and also we don’t need OpenCV as we have PIL library which almost have all the required function I need for image loading and converting.  

Comments

Popular posts from this blog