G'MIC exercises

exercise

(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.


#229

@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:


#230

@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:
https://www.imagemagick.org/Usage/mapping/#distortion_unified


(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.


#235

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


#236

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:


(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í.


#245

Following up with my exploration of gradient_norm here and here

As I am having fun with G’MIC, I have been noticing that the appearance of gradient_norm heavily depends on the size (and contents) of the image.

This is a problem because what works for a small image won’t work for a large one. E.g., when I apply the same command to PlayRaw images, it doesn’t work because I have been playing with G’MIC sample images, which tend to be much smaller and more idealized.

One approach might be to resize the image. Take sample flower for example. The difference between #1 and #2 is that I doubled the size of #2 before applying gradient_norm and shrinking it back to size. (Actually, #1 vs #2 of flower might not be the best example; it still looks okay.)

With this strategy, I am able to thin the outline. So, I now know that I can manipulate the width of the outline by doing this. However, the details and intensities change resulting a different effect on the image, and this would compound as you chain more commands.


(dumb) #246

You’ve given me an idea for multi-scale gradient norms - I’ll see what I can do.


#247

To thin edges of gradient norm you can do this. It’s not perfect because the thin edges are not centred, but you may find it useful

-gradient_norm

--l[-1]
    (1,-1)
    -convolve[-2] [-1]
    -rm[-1]
    -c 0,255
-endl

--l[-2]
     (1;-1)
     -convolve[-2] [-1]
    -rm[-1]
    -c 0,255
-endl

-max[-1,-2]

#248

Hmm, I am attempting to understand how G’MIC can create pattern, and it is my understanding that patterns can be defined by x-pixel, and y-pixel as well as width, and height. I am attempting to generate this pattern - https://forums.getpaint.net/topic/3691-vibrato-ymd080223/?_fromLogin=1 , but however, user-defined function is not getting me the answer I need. I am using user-defined function in order to understand how that works first.

However, I did found a cool idea, but it would require symmetrizing and the smooth modulo operation I just implemented for Krita.

Leaving this here for future reference : (x - y)/i * (x - i)/i * (x + i)/i * (y - i)/i * (y + i)/i

And this here for future reference : http://users.cs.cf.ac.uk/Dave.Marshall/CM0268/PDF/10_CM0268_Audio_FX.pdf

EDIT: I realize I could use solidify filter approach instead to recreate vibrato. I think a lot of effect from the paint.net forum can be recreated with the help of solidify feature. I think I might create a thread just for that task.


Also, I really could use a way to assume the center of the image is 0 in G’MIC user-defined. Wow, this is hard, but learning…

K3DSurf to G’MIC

K3DSurf:
cos(x*y)

G’MIC:
cos((x-w/2)/w*(y-h/2)/h)

that means, for x is replaced by (x-w/2)/w, and y is replaced by (y-h/2)/h

And to get to -pi, pi coordinate for G’MIC, the end equation is:
cos(((x-w/2)/w) * pi * 2 * ((y-h/2)/h) * pi * 2)



Also, this equation might lead to Moire for paint.net to G’MIC
sin((((x-w/2)/w)pi2)^2+(((y-h/2)/w)pi2)^2)

sin((((x-w/2)/w) * pi * 2 * 10) ^ 2+(((y-h/2)/w) * pi * 2 * 10)^2) leads to a interesting moire. The 10 are adjustable.

Your rendering engine setting affects the moire result when zoomed away. Bilinear filtering leads me to apparent moire.


#249

Are there two questions here? It’s a little hard for me to decipher what you’re asking at the beginning!

The question about input coordinates - if I had to convert some formula based on -1 to 1 domain, I would probably define another variable or vector first and work with that to simplify readability, e.g.

f "X=(x/w-.5)*2; Y=(y/h-.5)*2; cos(X*Y)"

Just to restate what you probably already know: g’mic coords in a fill use 0 <= x < w, so quite often you need to convert to -1 to 1 or 0 to 1.


#250

Yes, that is what I wanted. Now, I think I can find out what vibrato filter for paint . NET does.

I got this far for user-defined function :

f "X=(x/w-.5)*2; Y=(y/h-.5)*2; ;Z = (X - Y) * (X - 1) * (X + 1) * (Y - 1) * (Y + 1);1 - ( Z>.0001 ? Z : 1- Z*-1)"

A few more tweak to the formula to add into modulo operation seen in paint .NET thread, and to add more modulo operation after the normalize would be enough to mimic Vibrato plugin for paint .NET.

- Normalize [Insert Function] * Z mod 256 

That’ll be what I’ll do.