README.md

POV-Ray Thread - Bitmap to 3D canvas and cross stitch simulation converter

Python program for conversion of bitmap image (in PNG or PPM format) to some sort of solid objects in POVRay 3D format, resembling threads of canvas or cross stitches. Each source image pixel is converted to a 3D object, colored after source pixel.

Example of linen export rendering

Main program GUI

Main program POVRayThread.py provides general linking between PNG and PPM/PGM reading modules and POV-Ray writing one.

Useful GUI features include mouse event handling:

  • After starting program double click on preview area is equal to “Open…”, right click to “File…” menu;
  • After opening an image Ctrl + Left click is “zoom in”, Alt + Left click is “zoom out”, similar to Photoshop;
  • After filtering an image (pressing “Enter”) left click is source\result preview switch.

Brief effects module description

  • Linen.py - creates an object, simulating canvas, colored after source image (taffeta, print on canvas, and the like).
  • Stitch.py - simulates common cross stitching embroidery appearance.

Example of cross-stitch export rendering

Prerequisite and Dependencies

  1. Python 3.11 or above.
  2. PyPNG. Copy included into current POV-Ray Thread distribution.
  3. PyPNM. Copy included into current POV-Ray Thread distribution.
  4. Tkinter. Normally included into standard CPython distribution.

[!NOTE] Since POVRayThread 1.21.7.11 and Averager 3.21.7.11 PyPNM version included into distribution updated to PyPNM “Victory 2” main, intended to be used with Python 3.11 and above. The only actual limitation is that main version does not have a workaround for displaying 16 bpc images necessary for old Tkinter included into old CPython distributions. If you want bringing old Tkinter compatibility back, download PyPNM extended compatibility version and plug it in manually.

Installation and Usage

Programs distribution is rather self-contained and is supposed to run right out of the box. Program is equipped with minimal GUI, so all you have to do after starting a program is use “Open…” dialog to open image file, then use “Export…” to name 3D file to be created, then wait while program does the job, then open resulting file with POV-Ray and render the scene.

Averager

Averager.py was initially created as an accessory for preprocessing source PNG files. It averages image colors (L, LA, RGB, RGBA) within linear or squarish areas between contrast edges, providing color reduction somewhat similar to used in real cross stitch where single thread is used to produce several stitches in a row.

Later this filtering module was added to POVRayThread, making Averager redundant; however, it is still included into distribution as an illustration of 100% pure Python image filtering program, working at quite acceptable speed without any large third-party C packages.

Adaptive Image Averager program GUI

Related

Dnyarri website - other Python freeware by the same author.

POV-Ray Thread page with illustrations, explanations etc.

Ancestor project: POV‑Ray Mosaic

POV-Ray Thread source at github

POV-Ray Thread source at gitflic mirror

Описание

Converting bitmaps to 3D canvas and embroidery simulation in POV-Ray format.

Конвейеры
0 успешных
0 с ошибкой