davidAlgis / pyDot2Dot

Create a dot to dot draw from an image
MIT License
0 stars 0 forks source link

Dot-to-Dot Image Processor

This project helps in creating a dot-to-dot version of an image:

This tool processes an image to detect contours or paths and generates an output image with dots placed along them. It also adds labels to each dot and allows for additional customization such as dot color, radius, and distance between dots.

Usage

Ensure you have Python 3.6 or newer installed on your system. Then you can simply launch the application with dot_2_dot.exe.

Details about parameters

Two ways to change sizes

  1. Using pixel values for radius and font size:
   Radius 10

In this example, the radius of the dots will be 10 pixels, and the font size for labels will be 15 pixels.

  1. Using percentages for radius and font size:
   Font Size 2%

In this example, the radius of the dots will be 5% of the diagonal of the image, and the font size will be 2% of the diagonal.

Using both distance and number of points

You can combine the distance and numPoints parameters to control both the number of dots and their spacing.

Number of Points 100 
Distance Min 5%
Distance Max 10%

This will first simplify the path to around 100 points and then adjust the placement of dots so that the distance between them is between 5% and 10% of the diagonal length.

More about the placement of the dots

The placement of the dots is controlled by the Shape Detection argument, which determines the method used to detect shapes in the image. There are two methods available:

More about the number of dots

The number of dots placed along the paths is influenced by several parameters that control the simplification and spacing of the points:

Priority of Parameters

The script processes the number of dots in the following order:

  1. Initial Simplification: The path is simplified to reach the desired number of points specified by Number of Points using the epsilon value and simplification algorithms.

  2. Enforcing Distance Constraints: After simplification, the script adjusts the points to satisfy the minimum and maximum distance requirements:

  3. Insertion of Midpoints: If the distance between two consecutive points exceeds the maximum distance (distance max), additional points (midpoints) are inserted to reduce the spacing.

  4. Removal of Points: If points are closer than the minimum distance (distance min), they are removed to increase the spacing.

Due to this process, the distance constraints have priority over the desired number of points. The script will adjust the number of dots by adding or removing points to ensure that all points meet the specified distance requirements, even if this means deviating from the initial Number of Points value.

Command Line Usage (Advanced)

For an advance usage, you can use the application through command line.

Installation

Before running the script, make sure to install the required Python libraries. You can install them using the provided requirements.txt file.

pip install -r requirements.txt

Usage

Ensure you have Python 3.6 or newer installed on your system. Clone this repository or download the scripts and requirements.txt file. Install the required libraries as mentioned above. To use the script, run it from the command line with the desired options:

python main.py [options]

By default it launches the gui windows like the example above, but you can apply the computation only with command line arguments and no graphics.

Options

Examples

Basic Usage

To process an image with default settings:

python main.py -i "my_image.png"