G'MIC exercises


(Alan Gibson) #227

If you want edges to be balanced in brightness and thickness, Canny edge detection does that directly. Eg with ImageMagick:

magick tiger.png -canny 0x4+10%+30% tiger_canny.png

This has lost very fine detail, eg the whiskers. You could do multiple Cannys and combine the results.

I can’t find Canny in the G’MIC docs. Perhaps it isn’t available.


G’MIC has an otsu but I don’t think a canny. Canny is too maze-like for my tastes. I am sure there is a paper somewhere showing how we can convert a photo into a colouring book page. A quick web search yields dozens of web services and apps that do just that.


@Stampede asked about Mixer [PCA] and I gave an uninformed answer.

I know people who frequent this thread can do better than that. :slight_smile: Additional thoughts:

1. I was curious what the command would be in CLI and so output the command to the layer name. :thinking: The command is kind of lengthy; are those values for the gradients?

[G'MIC] Mixer [PCA]: fx_mix_pca 0,0,0,-1.5,0,0,-1.5,0,0,0,3,248,98,2325.2000000000003,111.79512900164166,114.29732606890039,67.953656912764956,2315.6918711327867,1198.1961603337977,1119.5840052975143,1198.1961603337977,1460.9525680609997,972.14804576863651,1119.5840052975143,972.14804576863651,1028.2088564317926,0,50,50

If so, they don’t require user input at all. Should they belong to the argument list?

2. It would be great if we could get a rgb2pca and pca2rgb, though I don’t know if that is meaningful or useful. If anything, it would be an educational demonstration on how to get to and back from 3 PCA components.

3. I guess the input for PCA manipulation isn’t limited to RGB. It could be any number of channels, right? Does the number of input channels correspond to the number of PCA components we get? Or could we decompose the input image to any number of components, sort of like split_details?

Apologies for asking so many questions, especially when many of you are busy people. I hope I don’t tempt you away from your important work. :stuck_out_tongue:


@afre , if you have ImageJ on your computer, you can try the 3D Color Inspector/Color Histogram plugin for ImageJ.Here is some help for the plugin, but the help was written, before the PCA functionality was added (see second hyperlink).

With this plugin for imageJ, you can make the color distribution within different 3D-color-spaces visible. With this tool, maybe it is more easy to understand whats going on.

The nice thing of the G’MIC “Mixer [PCA]” filter is that you also can shift and rotate (the color distribution) in 3 directions. That isn’t possible with the imageJ plugin.

This G’MIC mixer is useful in images that have a narrow color distribution, like faded images or images with color cast. With help from the PCA you now have the right directions within the color distribution to work with. So now, I don’t have to think about RGB or AB, that’s extreme helpful for lazy people like me :smile:. In this PCA directions now you can shift in case of color cast (second slider) and widen the color distribution (first slider) to have more color-contrast between the opposites of the PCA direction. With the third slider you can rotate the color distribution around one of the PCA “axes”. The other two PCA opposites will rotate, not the colors on the axis. Therefore it seems a little bit strange, but with this in mind, it is more easy to work with.

You can also use this mixer to make the color distribution smaller (with first slider). Then there will be less color contrast within the PCA axis . You can also shift with second slider to color grade your image.

I hope this information is useful. If it is wrong on some places, other people here can correct my information. :wink:

(http://4232.cf) #231

I wish to do a distortion of the degrade from the difference of two image

I think that using the difference between source_gseg and target_gseg can distortion source_gpos and obtain target_gpos

(http://4232.cf) #232

I think that it can paint with colours the “morph layers” distorsion

A version to reverse of this:

(G'MIC staff) #233

@garagecoder, just to thank you again for your wonderful noise_poissondisk command. That’s my new favorite weapon in my arsenal. I use it all the time, it’s so convenient to get a random spatial sampling uniformly distributed like this ! :beer:

(dumb) #234

I’ll try my hand at making a Cubehelix filter after probing Color.js’s README on GH for stuff about colour spaces. It’s not quite as easy as splitting channels and binding them to sine waves.


Interesting, you might want to start with the matlab code - it probably needs very little modification for the gmic math parser.


1. What is the best way to input all of the sample images? My lazy way is

gmic repeat 100 sp done remove_duplicates

2. animate messes up the aspect ratio of images. How can I prevent that? E.g., if I do

gmic repeat 100 sp done remove_duplicates animate 2000

(dumb) #237

I was thinking of a different method entirely which involves splitting the channels but this might work. The Matlab code does seem a little tricky for me to understand though. I can sort out the if and for stuff just fine but I’m unfamiliar with matrices in G’MIC. map looks like it’s initially a two-dimensional matrix of zeros and I have no idea how it works. The stuff in the if structure is also difficult for me to understand. I also have no idea how vectorN works.

Mind you, I’ve found an extension of Cubehelix which allows for interpolation between any two different colours. It’s quickly becoming something that I don’t think that I can do because of how much technical stuff it requires.

(G'MIC staff) #238

Maybe $ gmic repeat 40 sp "$>" done
(but you have to remember there are 40 sample images right now, and this may be extended in the future)

This is something I have to fix ASAP, I guess :slight_smile:


3. The d and d0 aspect ratio also messes up when I do something like

gmic sp tiger,tiger a x

I realize it may be to keep the window size in check relative to the screen. However, I prefer fidelity over that. I am uncertain whether this only happens when the image is larger than the desktop… If it is, I suggest that you consider giving the window a scroll bar or two (and perhaps panning capabilities {with the right mouse button?} if you are really ambitious).

(Juan David Garavito Espejo) #240

hi, i-m new on this. i want to use ebsynth and dont know how to make the target gpos. do you know how can i use it to create this. Thank you so much. any advice?

(Juan David Garavito Espejo) #241

@bazza me encataria hablar contigo, veo tus trabajos y es muy interesante lo que haces. he intentado entender un poco como crear la diferencia entre los gsec para crear el gpos. Cualquier ayuda o tip seria muy util para mi. muchisimas gracias de antemano.

(http://4232.cf) #242

gracias :smiley:

parece que lo genera usando algun tipo representación de un “flow” es como una transformación de una imagen a la otra. logre crear una versión usando deepmatch y deepflow no es igual, pero da buen resultado, pense que gmic podria hacer algo así.


@jdgaravito Welcome to the forum!

@jdgaravito @bazza I suggest you create a new thread for discussion on post #231 and posts #240-242.


4. What is the best way to take 2 input layers and display every single blend mode for the pair?