Like always, the code is available on Github. Hopefully I will be discussing OpenCV furhter in coming weeks on further advanced topics. The Python Imaging Library, or PIL for short, is one of the core libraries for image manipulation in Python. It is just telling you informaiton based on pixel colors rather than performing color segmentation and clustering based on a ML algorithm. It is not a mature product as it can’t tell you about unique colors in a picture. So this was a basic image processing tutorial in OpenCV. I have also made a demo which can see below. Seeing as this is probably one or two lines in Python. The function then returns a list of dictionaries consist of color code in HEX and its frequency which we will use to find the percentages of color in an image. As far as resizing goes, I was hoping it would have a way to do smart resizing (keep proportions). ![]() The image has a size of 30x30 pixels and contains a vertical line. Once the data is retrieved in BGR format, we are using a custom rgb2hex method to convert RGB to HEX color. You can consider a simple image to understand the process of convolution using kernels. By the way, OpenCV stores image data in BGR format instead of RGB color space. The data is available in the form of numpy array hence using it’s shape method to find details like width, heights, and channel. Path = 'website/static/uploaded_images/' + image_nameĪfter importing computer-vision we read the image from the disk by calling cv2.imread(). To see how, create a new file and name it imageviewer.py. Print('Processing the image '.format(image_name)) Creating an Image Viewer PySimpleGUI lets you create a simple image viewer in less than 50 lines. Let’s discuss the core part of the system that is, the command-line script that is doing the main work. You search images by color code and it returns the result, something like below:Īnd the view of the single image looks like: The app consists of two parts: a Web-based application that is used to store images from Web and display processed images and their dominant colors and a command-line script that is run on the downloaded image and extract color codes. I am not going int nitty-gritty details of both OpenCV and Flask and I will be covering what the application is actually doing. I could not find a better excuse other than converting my basic learning of pixels into a product (Google! Beware!!) This is not a state of art application neither it is currently serving the way I intend to do but hey, it is just a start, not the end. ![]() So what is it all about? Well, it is simple, or I say, the simplest demonstration of using OpenCV to load an image and finding color-related to that image and show insights in a Flask based web application. More luck that the guys like Adrian has done a great service by releasing both book and blog on a similar topic. Luckily there are Python bindings available. I recently started playing with OpenCV, an open-source Computer Vision library for image processing.
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |