featured image for gauss optim

Optimizing Circular Gaussian Mask, Krita:GSoC


Previous implementation was based on a slow scalar model, calculating each mask value per coordinate. I implement a new vectorized code using Vc library to allow a robust SIMD usage, calculating the mask values in parallel. Not all operations are implemented on Vc data types, especially erf had to be implemented for Vc data types. The new implementation shows to be up to 10 times faster (on my system) on mask generation. Given that the mask generation requires the most computing on brush stroke generation, this speed improvement holds up even in the full brush stroke benchmarks. Given the way it is implemented the code can become faster as future SIMD registers grows on future CPUs.

Circular Gauss Optimization results.

Code study and implementation of Gauss Mask Mask generator.

Phabricator task: Implement Circular Gauss Mask Optim AVX
Vc creates code from templates tailored for each processor instruction set: AVX, AVX2, SSSE2, SSSE3, SSE2, and scalar. so first a template must be declared to manage the creation of each instructions set code. Using the vectorized Default Mask implementation as a guideline, studying how the code generates is constructed to provide the functionality allowed to extend it for the other MaskGenerators
Read More »

Advertisements

GSoC: Krita AVX mask optimizations, setting up the environment.

Hi! GSoC student here :]. This first weeks coding for Krita have been so busy I forgot to write about them. So I’ll start to sum everything up in short posts about each step of the project implementation process.

First Steps, setting up a dev environment

I followed the steps in the 3rdparty to compile the base krita system on OSX. This easy to follow instructions helped me get a basic Krita installation in a short time. However not everything worked for me quite easily and most tests did not work or run at all on OSX with the message.

QFATAL : FreehandStrokeBenchmark::testDefaultTip() Cannot calculate the bundle path from the app path

After some digging I found out that no program that uses a GUI can run outside of an app bundle. So while not a future proof, to start working on the code I made a quick script to install the tests I’m interested inside Krita.app folder. To allow tests to run. By default all tests are linked to libraries in the build dir, but because this wont work on OSX one approach would be to install also the tests in the bundle and link to the install libraries or, another approach could be to generate an app bundle for each test.

In any case the tests could run so It was time to start working on the unit test.

Implementing Mask Similarity Test

Phabricator task: Base unit test kis_mask_similarity_test
This unit test intention is to compare the correctness of the new vectorized mask rendering by comparing it to the same settings Mask produced by the previous engine. The new versions have to be as identical as possible to ensure the painting effects the user is expecting does not change between engines (The user can’t change how the mask is produced, but we use the scalar version for smaller brush dab sizes).

Read More »

Into Google Summer of Code

Hi! I’m Iván Yossi,

I can’t believe I was selected for the Google Summer of Code program for working on Krita. The proyect I’ll be working this summer is on optimizing Krita’s brush mask to work with AVX instructions. These instructions will be coded using the Vc library, a “zero overhead C++ types for parallel computing” that enables to efficiently transform the mask’s generator code to SIMD instructions for vectorization.

Brush masks is a core process in the painting task as it creates the shape it will be imprinted in the canvas. This, depending on brush settings, can be done as much as thousends of times per second. Having this optimized will greatly improve painting enjoyment keeping the brush stroke responsive on bigger sizes.

You can see more details of the proyect here

I’ll keep you posted as te proyect advances.

See you soon :]

Imagemagick useful cmds: basic bash select, image resize, crop, creation

Imagemagick adapted personal notes.

Most times when I want to do something on several images I use artscript, a small GUI tool to automate most common, and not so common, imagemagick operations. It makes a breeze to prepare a set of images to display on one or several output sizes and formats. artscript backbone is imagemagick command line program, mainly what artscript does is compose the command line option to make imagemagick do its thing.

The remaining times artscript doesn’t fit my imagemagick needs I find it useful to remember the following commands.

General image selection

Use terminal utilities to filter the wanted images and feed the result to either *xargs* or a *for/do loop*. The most common utilities, and easier to remember are: ls and find.

ls

List all files in a directory, using wildcards from bash its possible to filter the results easily.

 $ ls *.png ## list all png
 $ ls draw_*.jpg ## list all jpg starting with 'draw'

find

For queries more complex or uncertain I use find. find queries can be very complex on its own

$ find . -name '*.ora' ## finds all file and dirs ending with '.ora' (used * wildcard again)
$ find . -type f -name '*.?[pn]?' -ctime -30 ## finds all png and jpg files in current dir created in the last 30 days.

## spaces in characters will break the pipe, use print0 to feed xargs
$ find . -name '*.jpg' -print0

When doing a for loop its not necessary to use xargs, and its possible to feed the bash mini script with patters, this is specially usefull when you know exactly the image you are going to process.

## Inspect all files patterns between 044, 045, 046.. until 050.
## any command can go after the do.
$ for f in 14_{030..050}.ora ; do file $f; done

## Using xargs
$ echo 14_{030..050}.ora | xargs file

Creating Images

Read More »

Painting with index colors filter

Krita

Working with index color filter, described here https://krita.org/item/236-last-week-in-krita-week-21, can be confusing. The filter works so slow (in my pc) that getting results just by moving sliders is a waste of time. Some things are good with the tool and some others are hideous. I wanted to work with index colors to get the messy pixely effect and also using live filters to edit anything later (if it’s needed). here are some notes on the tools to avoid future headaches.14_189fs_netAbove: my result. Used the same layer setup as in the video here https://www.youtube.com/watch?v=v1Z__mSfo8s (whoppix was very kind to share the file). To control a little better the output. I worked in gray scale all the way and used 4 main groups. Background, Clothes, Skin, Hair. The idea at first was to use a different colour on each section and a slightly different dithering effect on each.

Layer Stack description (As in source file)

Set a group for each dithered object you need. each group act as an isolation environment so its possible to get different colors and dithering patterns on different elements in canvas.

  • Top layer: Dithered filter
    – Ramps: Brigth 3 colors, Light, base and Dark 1 color each
    – Diagonal Grafients ON
    – Gradient steps: 3 / L 4 / B 5 / Shadow 5
    – Limit to:  Indexing factors ( move at will)
    -Alpha steps 1
  • Group Layer: Dither layers (Op: 16%)
    Grayscale texture dither patterns
  • Paint layer. This is the where the object is made.

On Dither patterns and textures

Layer must have opacity lower than 20 to add the effect without interfering with the painting itself. If it is too high the pattern will become the painting instead of just dithering the gradients. You can use any data as dithering patterns. I only tested grayscale layers and different types of layer content. From what I can observe:

  •  Sharp pixel shape patterns with different gray values work best
  • Its possible to use krita painting brush patterns to add dither, results are more or less nice. (Used on the background)
  • Add any image texture and tweak values to make nice dither. This came come from a photo or a painting. Krita grayscale patterns enter this category
  • Use a brush engine to generate Texture. this is trickier since you need to generate an organic pattern for it to look good. (Ramon miranda’s hairy brush set works extremely well for this.)

Brush engines tested and settings

Painting with Brush patterns Grayscale textures: Set Cut Off Policy to “Brush” and set arrows. black on middle, white closer to edge.
Painting with spray to generate dither:
Spray brush:
Size off
Shape dynamics, Random size?
Paint mode BuildUp, (Wash with Random Opacity in “Color options” doesn’t seem to work)
Spray area: Diameter, Scale, Particle count alter the way the dither is “rendered”
I ended up using Turning off: Spray Shape and setting the brush set tip to 1px, more or less.
Hatching brush: Ok This one works very well for creating gradient dithering. however the results are hard to control
Hair brush: Very Good, just lower opacity to control texture amount
I have: Opacity 94%, Ink depletion: ON (1024, opacity)
Sketch brush: Could work
Brush size: Offset scale above 80%, density low, Ucheck “use distance density”, Uncheck “Magnetify”

Speed problems?

Live filtering is very slow at the moment, to avoid the trouble of working at snail speeds get used to work in Grayscale (values only) and turn on index colors filtering for fine adjustments.

Controlling color output

14_190_net

This is a tricky business. I tried many different variations and I could obtain the same color combinations from different color mixtures in the dark, base, light, bright color swatches.
The colors provided by default work well as long as you don’t alter the value. In other words they will affect the gradient at the same bright tones as long as you don’t alter the value setting.
In the end I made the following process
  • Removing all swatches and leaving base will create a cut out shape with the color selected.
  • Add then a light tone for getting gradient variations. The colors are not exactly the ones you picked, but very close
  • You can use second and third rows, jumping wrows will make a strong gradient effect. however use with care as activating them might cause unwanted color shifting.
  • Color value is everything. Add a Bright tone with very dark value and you will affect the dark tones. Add light value to Dark column and highlight will get colored, despite being in the dark column. Not sure if this is a bug but, use this to your advantage to fine tune dark tones a little bit in the end.
  • Because of the former point, have some order, using values from light to dark, top to bottom.
  • Activate diagonal gradients to use any column and get mostly the same effect as if you were using only one column. I have to investigate this further as the option might imply some other things.

Adding screenshots showing color mixing variations.

 

Conclusions

The results from this technique are strongly dependant on your value mastering and for more aesthetically appealing picture you have to prepare a nice set of patters and use them with care. Failing to do so will result in a muddy picture with no volume and zero flow on forms. Very difficult indeed to get. My pictures ire nowhere near that level. Finally, while the results are satisfactory I still need to master the coloring mistery for selecting the exact colors I want. I could help to set a gradient inside the affected area to help selecting the color ramps. In the end I had to use level and color balance to get a brighter look on the first image.

Second image was better controlled in respect to color setting in the filter. I started working on it with the experimental brush to focus only on hard shapes. Abusing Krita layers ystem I worked as with the red marker and light yellow for the background, cloned the resulting group layers. Added those clones to the indexed layer and toyed with the index filtering colors.

Get the Source files

[es] Esta semana en krita — semanas 25 y 26

Estas semanas han sido emocionantes con la campaña de kickstarter acercándose más y más al objetivo. Al momento de escribir este artículo estamos pasando 13k. Y con la nueva oleada de usuarios, atraídos por la gran labor de colaboradores y entusiastas en la difusión de la misma, hemos estado muy ocupados trayendo nuevas versiones de prueba y desarrollando nuevas funcionalidades.

Antes de entrar de lleno a lo nuevo, no puedo dejar de mencionar a Ramón Miranda que, con el objetivo de difundir mejor las capacidades de Krita para aquellos que escuchan del software por primera vez, ha creado una serie de video tips: Introducciones cortas a diversas funciones avanzadas y fundamentales dentro del software. Aún para los iniciados es un buen recurso, al menos yo aprendí un par de cosas que no conocía. Todos los tips en el post de kickstarter Ramon youtube channel

Progreso semanas 25 y 26

Entre las cosas más destacarles podemos citar los importantes esfuerzos de Boud por crear un entorno de construcción que permita crear eventualmente una versión de prueba para los usuarios en OSX. Aún en fase experimental, el avance es bueno logrando compilar el programa, y hacer que funcione. Por supuesto esto está lejos de ser una versión para distribuir, pero si recordamos como empezó la versión de Windows, es una gran señal.

Somsubhra, desarrollador de la versión Krita Animation, ha añadido, entre muchos arreglos de fallos, un primer esbozo de un reproductor para las animaciones hechas. Se puede ver más en el video adjunto.

Read More »

Krita Fundraiser campaign!

Krita Fundraiser campaign! Hola. Fue en 2012 que comencé a usar Krita para pintar. En ese entonces usaba la versión 2.5 en Windows, aunque por momentos se cerraba, era la primera aplicación de pintura digital donde realmente me sentí cómodo. Tanto me gustó que hoy día es casi la única aplicación de pintura que uso. […]

Sketch Dump: March 2014

I had to rest a lot this month, It seems when I use a tablet I use a repetitive unnatural movemtent to draw (Short inwards wrist movements). Over the hundreds of drawings that began causing a tendon wear out. Before it develops any further (even to a tendinitis) I rested. Between rests  I tried several ways of working but I kept going back to the short movements. In the end the only thing that seems to be working is tilting the tablet and draw more in paper.

Here is the sketchdump of all drawings made with the tablet. I focused on finding my creativity and learning a bit of technical stuff. The drawings offer little technique variety, they are low on composition values and overall few men were amongst the drawing subjects. Overall this month was not very productive.

The sketches

Some are referenced from other artists artwork, a lot are build from reference, and only few are completely invented.