Stylize

Stylize

what is needed to get started?

G’mic is a massive collection of image processing filters combined to a one easy to use gui and cli program that can be installed on gimp, krita etc … or used on the terminal, it’s so big even tho i already made a markdown file specific for showing it with many examples i barely scratched the surface of what it does and i’m going to showcase one of it’s filters here

for the basics of how to use the G’mic look here , now that you are somewhat familiar with this program lets do our thing

stylize is a cool filter for applying style transfer to our images, see here for a deep dive of the filter documented by G’mic, stylize is the most easy to use and un-complicated implementation of style transfer i have seen that runs locally on your computer without the need for internet or installing extra programs like python, lua or others

note: images that are linked in this markdown file are compressed to make loading the page faster, for the uncompressed versions go to the examples folder

source material

everything is downloaded from a royalty free image website here and here, there is also some royalty free stock footage from youtube

explanation of the config and how the program works

basic advanced
basic advanced

the default options in the gui translates to this command in the cli by clicking on the copy command icon on the top right side of the gui

fx_stylize 0,5,0,0,0.5,2,3,0.5,0.1,3,3,0,0.7,1,0,1,0,5,5,7,1,30,10,2,1.85,0

add a gmic behind the command, specify your input image and output image, styles has a few images embedded into it if you don’t want to set an style image

gmic input.jpg fx_stylize 2,5,0,0,0.5,2,3,0.5,0.1,3,3,0,0.7,1,0,1,0,5,5,7,1,30,10,2,1.85,0 -o output.jpg

the 2 after fx_stylize tells gmic to use the 3rd option in the first gui entry which is the first embedded image style, by default 0 is used which uses the first image as our style so if we want to specify our own style we set that number to 0 and insert 2 images to gmic

gmic style.jpg input.jpg fx_stylize 0,5,0,0,0.5,2,3,0.5,0.1,3,3,0,0.7,1,0,1,0,5,5,7,1,30,10,2,1.85,0 -o output.jpg

basic usage (using built-in styles)

we’ll start we some pre-embedded images as styles, this is easiest way to use the filter

gmic earth.jpg fx_stylize 32,5,0,0,0.5,2,3,0.5,0.1,3,3,0,0.7,1,0,1,0,5,5,7,1,30,10,2,1.85,0 -o earth_gogh+.jpg
input style (Picasso: Seated Woman) output
earth seated-woman earth_gogh1+
gmic statue.jpg fx_stylize 25,5,0,0,0.5,2,3,0.5,0.1,3,3,0,0.7,1,0,1,0,5,5,7,1,30,10,2,1.85,0 -o statue_mondrian+.jpg
input style (Mondrian: Gray Tree) output
statue gray-tree statue_mondrian+

basic usage (using our own images as styles)

gmic tree.jpg lighthouse.jpg fx_stylize 0,5,0,0,0.5,2,3,0.5,0.1,3,3,0,0.7,1,0,1,0,5,5,7,1,30,10,2,1.85,0 -o Light_tree.jpg ; rm *000000.jpg

this command outputs two images, Light_tree_000000.jpg which is the same as our input image and Light_tree_000001.jpg which is what we actually want so for further commands we add a remove command at the end of our command to remove this un-needed file like this ; rm *000000.jpg the ; add the remove command to our gmic command to make it a one liner

input style output
lighthouse tree Light_tree_000001+
genie skyscraper genie_sky_000001+
x-ray colorss x-ray_color_000001+

scale style image to produce different results

by default stylize sets your style image to 75% of it’s size and uses it to re-create the input image, you can set this operation to none or make the resizing smaller or bigger depending on your style image, the default value is a good start point and might be fine for your case but we’ll still show the differences here

changing style scale is done by changing the second number we pass to fx_stylize filter, it starts at 0 and ends at 10

input style
car magnet
10% scale (1) 50% scale (4)
l-scale-10_000001 l-scale-50_000001
150% scale (7) 300% scale (10)
l-scale-150_000001 l-scale-300_000001

specify smoothness

smoothness decides how much styles uses the style image to recreate the input image, the higher the smoothness the less the style image is used and the output image effected

input style
flower5 ice
smoothness 0 smoothness 5
l-smooth_0_000001 l-smooth_5_000001

respect gradients

by default stylize only takes 20% (1 out 5) of gradients into the effect, this part of the filter works in tandem with the smoothness option but won’t mix them here because we want to showcase it on it’s own

input style
tincan wall
gradients 0 gradients 5
l-gradient_0_000001 l-gradient_5_000001

other config knobs and choices

there is simply too many options to go over, i’m not sure how effective they are and how much they might show up in result outputs as i didn’t have the time to test them, but i’ll make sure to include them if they caught my attention

fun with gifs

making a animated gif with stylize is just as easy as still images, we just need a for loop for batch processing, if we don’t have a image sequence of your gif file you can make one like this

ffmpeg -i my.gif -vsync 0 S-%4d.jpg

the above command pads 4 zeros to our images after S- , each gif file is limited to 500 frames but we add an extra 0 at the beginning to make life easier for our for loop and the conversion of our stylized sequence to gif again

now for converting our newly made image sequence

for i in S-0*.jpg ; do gmic crochet.jpg $i fx_stylize 0,5,0,0,0.5,2,3,0.5,0.1,3,3,0,0.7,1,0,1,0,5,5,7,1,30,10,2,1.85,0 -o G-$i.jpg ; rm *000000.jpg ; done

now make the animated gif

cat G-*.jpg | ffmpeg -framerate 30 -f image2pipe -i - -preset veryslow crochet_face.gif
input output
face-low crochet_low

for the style image go to the gif folder inside examples, these gifs were significantly compressed using gifsicle to make their size way smaller and are not representative of the actual result quality

stylizify a video

lets apply what we learned to a video, i have made a example of how to download a free video, make image sequence, apply filter and mux it back here

for i in *.jpg ; do gmic neon.jpg $i fx_stylize 0,5,0,0,0.5,2,3,0.5,0.1,3,3,0,0.7,1,0,1,0,5,5,7,1,30,10,2,1.85,0 -o G-$i.jpg ; rm *000000.jpg ; done 

as you can see the process is similar to gif making, we just want to make a video instead, videos have the advantage of applying a uniform compression to each frame and produce amazing quality images with a really small output size

cat G-*.jpg | ffmpeg -framerate 30 -f image2pipe -i - -preset veryslow guitar-neon.mp4

here is another example at half speed

glitch it

we’ve been trying to re-create the input images as best as we can and get a clear result, lets change all of that and destroy the input

the easiest way you can go about this is using a frame out of an image sequence as the style image

for i in *.jpg ; do gmic 0468.jpg $i fx_stylize 0,6,0,0,0.5,2,3,0.5,0.1,3,3,0,0.7,1,0,1,0,5,5,7,1,30,10,2,1.85,0 -o G-$i.jpg ; rm *000000.jpg ; done

using a glitched image as style

use a pixelated or a very small image as style

use a blank noise image as style

use a dithered gradient as style

use G’mic’s own pixel sort filter for style

use G’mic’s own charcoal filter for style

batch processing

it’s kind of hard to know how an image might look without converting it first, when in doubt, stylize them all!

for i in *.jpg ; do gmic $i statue_of_liberty.jpg fx_stylize 0,6,0,0,0.5,2,3,0.5,0.1,3,3,0,0.7,1,0,1,0,5,5,7,1,30,10,2,1.85,0 -o G-$i.jpg ; rm *000000.jpg ; done
S-statue_liberty_landmark_close_1 S-G-wood_texture_material_3d jpg_000001 S-G-wood_texture_burned_fire jpg_000001 S-G-wall_texture_background_stones-b_2 jpg_000001
S-G-trunk_bark_texture_background jpg_000001 S-G-texture_wood_wood_texture_0 jpg_000001 S-G-texture_wood_paint_grain_2 jpg_000001 S-G-texture_white_black_pattern jpg_000001
S-G-texture_weave_background_macro jpg_000001 S-G-texture_structure_composition_1680613 jpg_000001 S-G-texture_straw_hut_970479 jpg_000001 S-G-texture_pattern_beautiful_bright jpg_000001
S-G-texture_oil_water_blue jpg_000001 S-G-texture_metal_background_model jpg_000001 S-G-texture_leaf_ruffled_sheet jpg_000001 S-G-texture_grid_graphic_abstract jpg_000001
S-G-texture_green_plant_lettuce jpg_000001 S-G-texture_facade_shielding_steel jpg_000001 S-G-texture_fabric_fabric_texture jpg_000001 S-G-texture_dried_seeds_decoration jpg_000001
S-G-texture_bench_chair_white jpg_000001 S-G-strawberry_texture_fruit_healthy jpg_000001 S-G-stone_texture_background_stones_1 jpg_000001 S-G-stone_ruins_texture jpg_000001
S-G-scale_texture_background_green jpg_000001 S-G-pineapple_texture_macro_pattern jpg_000001 S-G-pattern_texture_blocks_wood jpg_000001 S-G-mosaic_texture_blue_yellow jpg_000001
S-G-model_texture_pattern_427979 jpg_000001 S-G-leaves_texture_scroll_area jpg_000001 S-G-grunge_texture_square_pattern jpg_000001 S-G-gravel_texture_grass_rocks jpg_000001
S-G-gravel_texture_0 jpg_000001 S-G-colorful_texture_scarf_pattern jpg_000001 S-G-cobbles_grey_texture jpg_000001 S-G-cable_texture_yellow_black jpg_000001
S-G-braid_texture_background_model jpg_000001 S-G-bokeh_texture_lights_bright jpg_000001 S-G-basket_texture_pattern_weave jpg_000001 S-G-bamboo_texture_pattern_wood jpg_000001
S-G-background_texture_textile_pattern jpg_000001 S-G-background_texture_design_layer_13 jpg_000001 S-G-background_texture_bricks_wall jpg_000001 S-G-background_texture_banana_braid jpg_000001