Posts

Showing posts from December, 2018

Dice grid from a photo with Python (III) – Creating the resulting picture

Image
This post is part of the Project: Create a grid of dice from a photo with Python and PIL The logic behind the program Drawing the dice Create a grid of dice from a photo Design of the GUI Document and creation of the stand-alone executable Introduction In the first post of this project I mentioned the steps to create a dicing grid parting from a picture: Divide the picture into subsets Analyze each subset and replace it with the correspondent die based on its brightness I already defined the functions to draw the dice, so in this post I'm going to continue with the functions needed to transform the picture into a grid of dice, basically finishing the main purpose of this project. The steps to code the dicing grid are a bit different than the mentioned before, being like this: Get the constant values using the formula mentioned in the first post Validate or resize the size of the picture Divide the picture into subsets Analyze each subset and replace it with th

Dice grid from a photo with Python (II) – Drawing the dice

Image
This post is part of the Project: Create a grid of dice from a photo with Python and PIL The logic behind the program Drawing the dice Create a grid of dice from a photo Design of the GUI Document and creation of the stand-alone executable Introduction In the previous post we analyzed all the steps to create a dicing grid from a picture in theory, but no code was written. In this post, I will show you how to draw dice with Pillow and its methods. In this post, we will see: How to install Pillow as a Python module How to import and use the methods in PIL.Image and PIL.ImageDraw in our code How to divide our code into functions Use of arguments and keyword arguments Installation of Pillow Pillow is a library that adds support for manipulation of images in Python. Pillow is a fork of PIL , appearing after the later stopped being updated in 2009. You can install Pillow through PIP on Windows, Mac, and Linux with the command: pip install Pillow Installing Pillow

Dice grid from a photo with Python (I) – Logic behind the program

Image
This post is part of the Project: Create a grid of dice from a photo with Python and PIL The logic behind the program Creation of the dice Create a grid of dice from a photo Design of the GUI Document and creation of the stand-alone executable Introduction Before we code the program, it is necessary to have a general idea about how we will solve the problem that surrounds us. Here, we want to know how can we create a grid of dice parting from a picture, and what must we do to put the correct dice in each part of the picture in such a way that the result resembles the original picture. Note: In this post, I will only show the logic behind the program and therefore no coding will be done. In this post, we will analyze: How to draw the dice How to divide the picture into subsets How to decide which die paste in each part of the picture Thinking of a template for the die We are going for the simplest approach to draw the dice: 1 dot per pixel. As the die is a cube

How to install Spyder 3 on Windows without Anaconda

Image
What is Spyder? Spyder is a robust integrated development environment (IDE) for Python with a lot of useful features for scientists, engineers, and data analysts. Spyder is entirely written in Python and comparable with Matlab. Although Spyder is usually included in the Anaconda Distribution , it can run on its own, something that will be enough for most programmers who are looking for one of the best Python IDEs that we can install in our system. Install Spyder on Windows without Anaconda To install Spyder IDE on Windows, we are going to need PIP; if you're not familiarized with PIP, you can look at my post How to install python packages with PIP . Open a command prompt and type the following command to install Spyder : pip install spyder Spyder has multiple dependencies that you can check on the official Spyder documentation . However, PIP will automatically install any not satisfied dependencies making the process very straight-forward. Once you install Spyd

How to install the last version of Python 3 on Windows

Image
Python 3 has surpassed Python 2 as the most popular version of Python out there, according to JetBrains Python Developer Survey 2020. The most recent version of Python is available for most Operative Systems, including Windows 7, 8 and 10. To install the last version of Python in your system, follow these steps. How to install the last version of Python 3 on Windows Go to python.org and put your mouse over the Downloads button The website has done most of the work for us, detecting our version of Windows and selecting the right installer for us, so now you only have to click on the button displaying the version of Python to download Python 3. Open the installer and before clicking on Install Now, mark the checkbox " Add Python 3.x to PATH ". Doing this will allow you to execute Python from the CMD typing only " python " instead of having to type the whole path to executable in your system. After clicking on " Install now " you will onl

How to install Python packages with PIP

Image
What is PIP? PIP is the recommended tool for installing Python packages and modules written in Python. PIP is straightforward to use, and it lets us manage and add new packages like Scipy, TensorFlow, OpenCV, Sympy, and more to our system or our virtual environment in a fast and easy way. If you're a Windows user, PIP comes bundled with Python if you install it using the official installer from python.org. If you're a Linux user, you already have Python 3 and PIP installed in your system. Install packages with PIP PIP commands Note: All the commands must be typed into a terminal or command promp, and they will only work as shown if you added Python to your PATH System Variable during the installation. If you didn't, look 'pip' is not recognized as an internal or external command. To install a package with PIP, you only need to know the name with which it is listed in PyPi (The Python Package Index, with an online search engine that you can use to fi