It is currently Fri Nov 27, 2026 9:24 am


All times are UTC - 5 hours [ DST ]



Post new topic Reply to topic  [ 99 posts ]  Go to page Previous  1, 2, 3, 4, 5  Next
Author Message
 Post subject: Re: G'MIC - tips and curiosities
PostPosted: Fri Mar 28, 2014 9:11 am  (#61) 
Offline
GimpChat Member
User avatar

Joined: Jan 20, 2013
Posts: 14835
Location: roma, italy
Tip #18 - part two

As anticipated, now we go one level down, from the "end user" view (how to use the filter)
to the coder view (how the filter is written in G'MIC language).
To analyse the code, first I show it, expanded for better understanding of the single commands, that is:
- one command per line
- no short format of the commands
#@gimp Stained glass : gimp_stained_glass, gimp_stained_glass_preview(0)
#@gimp : Edges = float(20,0,100)
#@gimp : Shading = float(0.1,0,0.5)
#@gimp : Thin separators = bool(1)
#@gimp : Sep = separator()
#@gimp : Equalize = bool(1)
#@gimp : Colors = float(1,0,3)
#@gimp : Gamma = float(0,-1.2,1.2)
#@gimp : Contrast = float(1,0,4)
#@gimp : Brightness = float(0,-255,255)
#@gimp : Sep = separator(), Preview type = choice("Full","Forward horizontal","Forward vertical","Backward horizontal","Backward vertical","Duplicate horizontal","Duplicate vertical")
#@gimp : Sep = separator(), note = note("<small>Author: <i>David Tschumperl&#233;</i>.      Latest update: <i>2011/03/18</i>.</small>")
gimp_stained_glass :
  -repeat @#
    -local[$>]
      -split_opacity      #separate colors from opacity
     -local[0]         #work only on colors
        -stained_glass $1,$2,$3
        -normalize 0,255
        -if $4
         -equalize[-1]
       -endif
        -rgb2lab[-1]
       -shared[-1] 1,2
       -mul[-1] $5
       -remove[-1]
       -lab2rgb[-1]
        -apply_gamma[-1] {10^$6}
       -sub[-1] 128
       -mul[-1] $7
       -add[-1] {128+$8}
        -cut[-1] 0,255
      -endlocal
      -append c
    -endlocal
  -done

gimp_stained_glass_preview :
  -gimp_split_preview "-gimp_stained_glass $*",$-1

All the lines at the beginning, starting with #@gimp, are definitions: name of the command, parameters, etc.
The last lines specify the preview:
-preview the command with all the parameters ('$*' is substituted by a copy of the specified string of arguments)
-preview starts with no split ('$-1')
About the latter: did you ever play with the preview type? It's very nice the possibility to have the effect shown only on a half of the image (in many ways).

Now the body of the filter.

-repeat @# (@#’ is substituted by the current number of images in the list)

("-repeat" starts a loop which ends at the line "-done")
the initial line asks G'mic to apply the filter to ALL the images referred to in input;
well, one says: there is always only ONE image on which you can call a G'MIC filter from Gimp;
yes, that's true in Gimp language, not in G'mic language, because a Gimp image can have more than one layer and each layer is considered as an image by G'mic.
If you call G'mic starting from an image with two (or more) layers, then select "All" in Input/Output,
when running the filter all the layers are modified according to the filter
(in our case: all the layers will be transformed in a stained glass image).
Try:
1-open an image
2-duplicate the layer
3-select the filter (Pattern/Stained Glass)
4-run it (press OK) with all the default values (including the default Input/Output values)
result is: your image with ONLY the top layer transformed into a stained glass.
Now:
5-Ctrl+Z to reset your image at the status before calling the filter
6-reselect the filter (Filters/Re-Show "G'MIC")
7-change the option in Input Layers to "All"
result is: both layers of your image have been transformed into a stained glass.

-local[$>] ($> refers to the indice of the running ’repeat..done’ loop

("-local" start a capsule of code which end at "-endlocal")
all code that is encapsulated between a -local and a -endlocal is applied to the currently active image (layer in terms of Gimp) in the stack of images (layers).

-split_opacity

this command splits colour and opacity parts of the image;
this is necessary because the next command (-stained_glass, which performs the main function of the filter) requires to operate on a RGB image, without the A channel (without the transparency layer, in Gimp terms).
The user could have called the filter having in input RGBA layer(s)
(for instance, when experimenting with more layers than just the background).
Omitting this command, could therefore lead to abort the filter.
There are other commands which could have been used to avoid the opacity layer being on the game, for instance
-remove_opacity
but then the source image(s) would have been altered.
Instead, the -split_opacity keeps aside the opacity layer during the process but is then rejoined to the final image(s) by using the command -append c, at the end.

-local[0] starts a new capsule of code, which operates only on the colours, ignoring the opacity
this capsule will terminate with the -endlocal command before the -append c command, which restores the opacity.

-stained_glass $1,$2,$3

this is the real centre of the function. This command will be studied in detail on a next post.
Now, we continue with the next lines.

-normalize 0,255

we know very well already this command, so no need to re-discuss it.

-if $4
-equalize[-1]
-endif


Now the filter takes care of the fourth user parameter, which is a boolean value.
Thus the meaning of -if $4 is (as for many languages using boolean values): if the parameter was set to 1 (or true) ...
The equalisation command operates much like the Gimp Colors>Auto>Equalize
(from Gimp documentation: "The Equalize command automatically adjusts the brightness of colors across the active layer so that the histogram for the Value channel is as nearly flat as possible, that is, so that each possible brightness value appears at about the same number of pixels as every other value")

-rgb2lab[-1]

this command transforms the image from the RGB colour space to the Lab colour space.
As we know, RGB is composed by three "channels": Red, Green and Blue.
Lab also is composed by three "channels", which are: Lightness, "a" and "b";
"a" and "b" are arbitrary names, they could have been named as well Greta and Bob, but probably
better names could have been GM and BY, at least they would have been more mnemonic;
in fact, the "a" channel keeps the balance between Green and Magenta, while the "b" channel
keeps the balance between Blue and Yellow.

I stop here for now, the analysis will continue next days...

_________________
"Where am I ?"


Top
 Post subject: Re: G'MIC - tips and curiosities
PostPosted: Sat Mar 29, 2014 6:13 am  (#62) 
Offline
GimpChat Member
User avatar

Joined: Jan 20, 2013
Posts: 14835
Location: roma, italy
Tip #18 - part 3

OK, let's continue.
After the command RGB2LAB, the filter specifies:

-shared[-1] 1,2

Well, I have to confess that it's not a totally clear command, for me; anyhow I put here what I understand.
This command creates a "buffer" of part of the image cited, i.e. the image in Lab colour space, as output of the previous command.
Which parts are put into the buffer are defined by the parameters of the command, in this case they should be the second and third channels, the "a" and "b" channels (the colours channels).

-mul[-1] $5

This "shared" buffer of image [-1] is then multiplied by the filter parameter "Color" as set by the user (the fifth parameter).
As far as I understand, the effect applies not only to the buffer, but also to the "original" channels "a" and "b" of the Lab image, because they are "shared".
If some G'MIC guru likes to correct my understanding of the use of the command -shared, he/she is welcome

-remove[-1]

According to my understanding, the buffer is now useless so it is removed, because it only specifies which parts of an image should be affected by the commands which follow the -shared command; once those parts have been properly modified as required, the buffer itself is no more necessary.

-lab2rgb[-1]

The image is brought back to its original RGB colour space.

-apply_gamma[-1] {10^$6}

As we see, the user parameter is not taken directly as the value for applying gamma (the -apply_gamma command takes in input a positive parameter) but as the power of 10.
This clarifies why the input value of the filter has a range between -1.2 and 1.2.
According to my personal taste, as a user I would limit tha range between -0.3 and 0.3, which corresponds to a range (for the -apply_gamma command) between 0.5 and 2.0 approximately.

-sub[-1] 128
-mul[-1] $7

I consider these two lines of code together, because they implement -taken together- a kind of -contrast command (as far as I know G'MIC does not have an elementary -contrast command).
So to apply the contrast requested by the user, first all values are reduced by 128, which means that the image values shift from 0 : 255 range (of a "normal" Gimp image) to -128 : 127; then this range is multiplied by the input parameter "contrast".
One can say: well, if I let contrast = 1, values remain in the range -128 : 127; that's true, but the story does not stop here, we have to consider the next line of code:

-add[-1] {128+$8}

When applying the brightness requested by the user (which ranges from -255 to 255), values are added not only by the "brightness" value specified by also by 128, which restores what reduced by the -sub command.
In other words: if we leave the default values of 1 for the contrast and 0 for the brightness, we end up with the existing values (values - 128 + 128)

-cut[-1] 0,255

Because at this moment the values could have exceeded the range for a "normal" Gimp image,
which is 0-255, all values less than 0 are set to 0 and all values greater that 255 are set to 255.

-endlocal
-append c
-endlocal
-done

The first -endlocal ends the capsule containing the code affecting only the R,G,B channels, without the opacity channel which was set aside.
The next line (-append c) restores the opacity layer that was set aside.
The second -endlocal ends the capsule containing all the code as referred to one instance of the layers stack (images stack in G'mic terms).
The last line ends the -repeat loop.

And so, we also can say DONE, except that a next step will be to enter a second level of details, analysing the native -stained_glass command.

_________________
"Where am I ?"


Top
 Post subject: Re: G'MIC - tips and curiosities
PostPosted: Sat Mar 29, 2014 6:51 am  (#63) 
Offline
GimpChat Member

Joined: Sep 24, 2012
Posts: 275
Location: Scotland
I'd say you're right about the -shared command, it creates a new image in the stack which can be worked on as normal but doesn't actually have a space in memory of it's own; it just "points" to the section you pick from the original.

So for example you can work on a single channel of an existing image without using extra memory... anything you do to the shared image will alter that channel of the original.

Use with care though, it's one of the more advanced commands which can lead to unexpected behaviour (possibly even crashes although there are safeguards now).


Top
 Post subject: Re: G'MIC - tips and curiosities
PostPosted: Sat Mar 29, 2014 7:42 am  (#64) 
Offline
GimpChat Member
User avatar

Joined: Jan 20, 2013
Posts: 14835
Location: roma, italy
Thanks garagecoder!
I'm very happy to see you back here.
(I know you have a lot of ideas, but what about adding this one to your stack: implementing a G'mic filter similar and likely better than Ulead plug-in Particle -recently discussed on Gimpchat?)

_________________
"Where am I ?"


Top
 Post subject: Re: G'MIC - tips and curiosities
PostPosted: Sat Mar 29, 2014 10:00 am  (#65) 
Offline
GimpChat Member

Joined: Sep 24, 2012
Posts: 275
Location: Scotland
Thanks, I'm glad to be back :jumpclap
It's great you're still doing these tips!

Actually when I saw your post about particles I had a sudden urge to make exactly that, but alas for now I'm buried deep in another gmic related project :roll:

But I'm definitely keeping an eye on your posts :yup


Top
 Post subject: Re: G'MIC - tips and curiosities
PostPosted: Sat Mar 29, 2014 12:04 pm  (#66) 
Offline
GimpChat Member
User avatar

Joined: Mar 15, 2014
Posts: 115
Location: Brooklyn, NY
dinasset wrote:
Tip #18 - part two

-stained_glass $1,$2,$3

this is the real centre of the function. This command will be studied in detail on a next post.


Wheee! dinasset ventures deeper into the rabbit hole!

`Tis a congenial rabbit hole, though, filled with wondrous things.

I'm still new here, but I trust somebody's introduced you gmic_def.gmic, which
have the standard definitions of G'MIC commands. -stained_glass lives there.

I think I'm still in GimpChat purgatory; if I paste something which looks remotely
like a URL or code, The Gimp Chat Mommy catches me by the ear and accuses me
of all kinds of dire activity. It is my wont, however, to use the stand-alone gmic interpreter and
usually find it a rewarding experience to take the commands defined within gmic_def.gmic
and grow them, one command at a time, on a succession of gmic command lines
(working with a bash shell). It is somewhat like single-stepping through the code;
one gets to see how the command operates step-by-step. No harm, also, in copying
a command out of gmic_defs.gmic, renaming it to -my_stained_glass or somesuch,
and pasting it into your personal .gmic file. Then you can tweak it, make parts of it
subject to (additional) command line parameters and so forth. Someone ought to
write a tutorial on this at some point. (Now... why is it that everyone is pointing at me?)

Garry


Top
 Post subject: Re: G'MIC - tips and curiosities
PostPosted: Sat Mar 29, 2014 12:51 pm  (#67) 
Offline
GimpChat Member
User avatar

Joined: Jan 20, 2013
Posts: 14835
Location: roma, italy
grosood wrote:
dinasset wrote:
Tip #18 - part two

-stained_glass $1,$2,$3

this is the real centre of the function. This command will be studied in detail on a next post.


Wheee! dinasset ventures deeper into the rabbit hole!

`Tis a congenial rabbit hole, though, filled with wondrous things.

I'm still new here, but I trust somebody's introduced you gmic_def.gmic, which
have the standard definitions of G'MIC commands. -stained_glass lives there.

I think I'm still in GimpChat purgatory; if I paste something which looks remotely
like a URL or code, The Gimp Chat Mommy catches me by the ear and accuses me
of all kinds of dire activity. It is my wont, however, to use the stand-alone gmic interpreter and
usually find it a rewarding experience to take the commands defined within gmic_def.gmic
and grow them, one command at a time, on a succession of gmic command lines
(working with a bash shell). It is somewhat like single-stepping through the code;
one gets to see how the command operates step-by-step. No harm, also, in copying
a command out of gmic_defs.gmic, renaming it to -my_stained_glass or somesuch,
and pasting it into your personal .gmic file. Then you can tweak it, make parts of it
subject to (additional) command line parameters and so forth. Someone ought to
write a tutorial on this at some point. (Now... why is it that everyone is pointing at me?)

Garry


Thanks Garry!
Yes, I have all the definitions on my PC, and I work with those to understand the code.
As you have seen and as you says, first of all I explode the single lines of code, to make them more readable, for myself and for those who read my posts.
I "import" the filters I want to work on under "my_directory", created under:
Users/user/Appdata/Roaming/gmic text file
so I can made modifications, for testing purposes (not on the native commands, only on second level filters, those which show up in the menu of G'MIC-Gimp).
Let's see what will come out from the rabbit in the cylinder, as far as "-stained_glass" is concerned!

(about you: after a small amount of posts - I don't remember the exact number - you will be able to link whatever you like...)

_________________
"Where am I ?"


Top
 Post subject: Re: G'MIC - tips and curiosities
PostPosted: Sat Mar 29, 2014 12:55 pm  (#68) 
Offline
GimpChat Member
User avatar

Joined: Jan 20, 2013
Posts: 14835
Location: roma, italy
garagecoder wrote:
Thanks, I'm glad to be back :jumpclap
It's great you're still doing these tips!

Actually when I saw your post about particles I had a sudden urge to make exactly that, but alas for now I'm buried deep in another gmic related project :roll:

But I'm definitely keeping an eye on your posts :yup

Wow, I was almost sure that when I entered my first post on Ulead Particle you were somehow fascinated by the possibility to recreate it under G'mic! So, I'll wait ....

_________________
"Where am I ?"


Top
 Post subject: Re: G'MIC - tips and curiosities
PostPosted: Sun Mar 30, 2014 12:04 pm  (#69) 
Offline
GimpChat Member
User avatar

Joined: Jan 20, 2013
Posts: 14835
Location: roma, italy
Tip #18 - part four

And now, one step deeper: analysis of native command -stained_glass.
As for the filter, first of all we should see the code:

#@gmic stained_glass : _edges[%]>=0, shading>=0, is_thin_separators={ 0 | 1 }
#@gmic : Generate stained glass from selected images.
#@gmic : Default values: 'edges=40%', 'shading=0.2' and 'is_precise=0'.
#@gmic : $ image.jpg --stained_glass ,
stained_glass :
  -check "${1=40%}>=0 && ${2=0.2}>=0" -skip ${3=0}
  -echo[^-1] "Apply stained glass effect on image$?, with edges $1, shading $2 and thin-separators "@{-arg\ 1+!$3,enabled,disabled}"."
  -verbose -
  -repeat @#
  -local[$>]
    im={1+im}         # first im is the new variable; second im has the meaning "minimum value of the image"
   -add $im        # Ensure positiveness of image labels.
    --gradient_norm
   -ge[-1] $1
   -mul[-2] [-1]
    -distance[-1] 1
   -sharpen[-1] 1e10
   -neq[-1] 0
    -if $3
     -skeleton[-1] 0
   -endif
    -distance[-1] 1
   -watershed[-2] [-1]
   -sub[-2] $im
    -normalize[-1] 0,1 
   -pow[-1] $2
   -mul
  -endlocal
  -done
  -verbose +


Also in a native command the first lines start with a prefix, but in this case we see #@gmic instead of #@gimp.
That means that the instructions/definitions are addressed to G'MIC core, not to the Gimp+G'mic interface.

The first line describes the parameters and their characteristics:
1-the first parameter is called "edges" and must be a positive number (may be a percentage)
2-the second parameter is called "shading" and must be a positive number
3-the third parameter is called "is_thin_separators" and must be a boolean value, either 0 or 1

The second line is just a descriptive text of the effect produced by the command.

The third line describes the default values: 40% , 0.2 , 0

The fourth line is the example of use, as shown in the documentation.
(note: all the four lines are reported in the documentation).

Then starts the code.

stained_glass :

is the command name (or title)

-check "${1=40%}>=0 && ${2=0.2}>=0" -skip ${3=0}

this line checks the passed parameters and sets the defaults.
While the first two parameters have to be checked, the last one is not because it's a boolean value
and both possible values are acceptable (1 or 0, true or false, yes or not).

-echo[^-1] "Apply stained glass effect on image$?, with edges $1, shading $2 and thin-separators "@{-arg\ 1+!$3,enabled,disabled}"."

not sure, but I guess it's a comment displayed on the console when the command is executed from a command line.

-verbose -

reduces (-) the verbosity of the command, when executed from a command line.

-repeat @#
-local[$>]

we know already these lines of code.

im={1+im}

this is my understanding:
the first "im" defines a new local variable
the second "im" is the G'MIC predefined variable whose meaning is "minimum value of the image" (?)
the assignment set the local variable at 1 greater than the minimum (?).

-add $im # Ensure positiveness of image labels

I confess, I do not understand what's the meaning.
Can a G'MIC guru explain this line? thanks


--gradient_norm

Manual says: "Compute gradient norm of selected images".
This doesn't tell me anything (as written in many didactic cookbooks, a term should not be defined using the same term..., but this is the well known weakness of the entire manual).
Anyhow, let's look at the practical effects:
it produces a very nice grey edge-detection image, with many grey nuances.
We can see the result in attached image2 (source image is always the same).
It's somehow similar to the "edge" filter in Gimp with default values (see image3), except that the result
is greyscale.

-ge[-1] $1

the practical effect of this command is similar to a "threshold" filter in Gimp.
Using the value "20" (which is the value passed from the gimp_stained_glass filter,
if not altered by the user), creates an image (see image 2b)similar to the one produced in Gimp
by using (after the "edge" filter) the "threshold filter with default 128 (see image 3b).


continues...


Attachments:
images2-2b-3-3b.7z [564.85 KiB]
Downloaded 92 times

_________________
"Where am I ?"
Top
 Post subject: Re: G'MIC - tips and curiosities
PostPosted: Sun Mar 30, 2014 1:24 pm  (#70) 
Offline
GimpChat Member

Joined: Sep 24, 2012
Posts: 275
Location: Scotland
{im} is kind of a shorthand for @{-1,im}, which means literally the lowest value in the dataset (i.e. image) of the last item in the stack. Anything between the braces {} is treated as a math expression and math expressions allow certain quick substitutions, such as "im".

So if your last image [-1] had pixels like (60,30,40,50), {im} would be 30.

Following on from that, we have (perhaps a little confusing)

im={1+im}

which declares a new variable $im, this is separate from {im}. The dollar is the main difference in referencing them, so you can even do {$im+im} which is in fact adding two different variables.

Now when we do

-add $im

all we are doing is to add a single number - held in variable $im - to every data value (i.e. pixel) of all images in the current stack.

I hope I'm both correct and not confusing people even more!


Top
 Post subject: Re: G'MIC - tips and curiosities
PostPosted: Sun Mar 30, 2014 1:45 pm  (#71) 
Offline
GimpChat Member
User avatar

Joined: Jan 20, 2013
Posts: 14835
Location: roma, italy
thanks, garagecoder!
what you say is clear for me, but now I continue with your example:
- if image "has pixels like (60,30,40,50), {im} would be 30"
- so, $im -being defined as 1+im - is 31
- now, adding Sim to every data pixel, image values will be (91,61,71,81)
- what is the meaning of this step?
- why the original comments is "# Ensure positiveness of image labels"?
- what are the "labels"? (J&B is a "label" of a scotch whisky...

thanks again for your support

_________________
"Where am I ?"


Top
 Post subject: Re: G'MIC - tips and curiosities
PostPosted: Sun Mar 30, 2014 3:25 pm  (#72) 
Offline
GimpChat Member
User avatar

Joined: Jan 03, 2011
Posts: 1656
Hi, maybe I can be of some help here :)

First dinasset, I admire your courage. Trying to interpret the existing custom commands defined in G'MIC is a challenge by itself.
I didn't write all this with the thoughts it will be read and understood by someone else one day. My main goals when I write new custom commands is to get something that works (of course) in the more concise and efficient way as possible.

For your stained glass example, adding the minimum pixel value is in fact an error (that I will correct in the next version) :)
I should have substracted it instead, as I just want my pixels to be positive values (and I have no constraints on the upper bound).

For images that have already positive values, this has no incidence, but for images with negative values, I will probably get into some troubles with the -stained_glass command. Of course, -stained_glass is seldom used on those kind of images, so that's why I've never noticed this mistake before.
But this is still a bug. Thanks for having found it :)


Top
 Post subject: Re: G'MIC - tips and curiosities
PostPosted: Sun Mar 30, 2014 3:40 pm  (#73) 
Offline
GimpChat Member
User avatar

Joined: Mar 15, 2014
Posts: 115
Location: Brooklyn, NY
"given enough eyeballs, all bugs are shallow" -- Eric Raymond.

My two cents:

-gradient_norm:
It renders in white/light gray very steep slopes, or, put another way, very dramatic changes in intensity in any of an image's channels. Sort of like edge detection. I like to think of it as a slope finder, though, with the level of gray telling me how steep the slope is.

Here's a quick G'MIC illustration you could run through Custom code. Start with a black image:
-repeat @# -l[$>]
-gaussian 5,5
--gradient_norm
-normalize 0,255
-endl -done

-gaussian 5,5 -- makes a fuzzy spot of white, increasing in intensity toward the middle. Visualize looking straight down on a pile of sand. How white the image is reflects how deep the sand is. This is a test image.

--gradient_norm -- turns the first image into a doughnut, ring, what-have-you. Here, how white the image is reflects how steep slopes are in the previous image. It renders in white/light gray the regions in the first image that are rapidly changing from black to white (or white to black) At the very peak of the Gaussian pile, there is very little change -- we're at the top of the hill.

-normalize 0,255 -- of course, so we can see what is going on.

Couple or three posts back you used the word 'structure', which I think is a very apt word. These steep slopes are the initial structuring elements of the stained glass; they furnish the reference marks from which the -distance command (next) starts measuring. Then -sharpen, given its extremely high parameter, finalizes the structure, making a web-work of 'cames' out of the pattern produced by the distance command.

Garry


Top
 Post subject: Re: G'MIC - tips and curiosities
PostPosted: Sun Mar 30, 2014 3:42 pm  (#74) 
Offline
GimpChat Member

Joined: Sep 24, 2012
Posts: 275
Location: Scotland
Glad David was able to answer, I was already frowning at the code wondering what it meant haha :hehe
Yes indeed the custom commands are like a bottomless pit sometimes but some of the most intruiging little tricks can be learned from it ;)


Top
 Post subject: Re: G'MIC - tips and curiosities
PostPosted: Sun Mar 30, 2014 3:58 pm  (#75) 
Offline
GimpChat Member
User avatar

Joined: Jan 20, 2013
Posts: 14835
Location: roma, italy
Ronounours wrote:
Hi, maybe I can be of some help here :)

First dinasset, I admire your courage. Trying to interpret the existing custom commands defined in G'MIC is a challenge by itself.
I didn't write all this with the thoughts it will be read and understood by someone else one day. My main goals when I write new custom commands is to get something that works (of course) in the more concise and efficient way as possible.

For your stained glass example, adding the minimum pixel value is in fact an error (that I will correct in the next version) :)
I should have substracted it instead, as I just want my pixels to be positive values (and I have no constraints on the upper bound).


For images that have already positive values, this has no incidence, but for images with negative values, I will probably get into some troubles with the -stained_glass command. Of course, -stained_glass is seldom used on those kind of images, so that's why I've never noticed this mistake before.
But this is still a bug. Thanks for having found it :)


Thanks David!
Now I definitely understand better.
Glad to have helped a bit (it is part of the users' activities to contribute from time to time...)

Edit: I like to explain why I'm going through the definitions of existing commands:
1-I do not have a background in mathematics
2-G'MIC has been created by a great professor in mathematics/graphics (thanks, David!)
3-It has a lot of phantastic functions (ever user certainly agrees with this sentence)
4-G'MIC manual is written for people having background in mathematics
5-I started my way through G'MIC by reading the whole manual (except for 3-d commands, I'm not interested in those, at least at the moment)
6-I recognize to understand just as little as 10-15% of the manual (my fault)
7-Considering together point 3 and 6, which better way than reading through the existing excellent filters to make some step onward?
I choosed "Stained_Glass" because it's one of my preferred "distortions" of an image, and it's implemented in a very nice manner (thanks again, David!)

_________________
"Where am I ?"


Last edited by dinasset on Mon Mar 31, 2014 2:57 am, edited 1 time in total.

Top
 Post subject: Re: G'MIC - tips and curiosities
PostPosted: Sun Mar 30, 2014 4:00 pm  (#76) 
Offline
GimpChat Member
User avatar

Joined: Jan 20, 2013
Posts: 14835
Location: roma, italy
grosood wrote:
"given enough eyeballs, all bugs are shallow" -- Eric Raymond.

My two cents:

-gradient_norm:
It renders in white/light gray very steep slopes, or, put another way, very dramatic changes in intensity in any of an image's channels. Sort of like edge detection. I like to think of it as a slope finder, though, with the level of gray telling me how steep the slope is.

Here's a quick G'MIC illustration you could run through Custom code. Start with a black image:
-repeat @# -l[$>]
-gaussian 5,5
--gradient_norm
-normalize 0,255
-endl -done

-gaussian 5,5 -- makes a fuzzy spot of white, increasing in intensity toward the middle. Visualize looking straight down on a pile of sand. How white the image is reflects how deep the sand is. This is a test image.

--gradient_norm -- turns the first image into a doughnut, ring, what-have-you. Here, how white the image is reflects how steep slopes are in the previous image. It renders in white/light gray the regions in the first image that are rapidly changing from black to white (or white to black) At the very peak of the Gaussian pile, there is very little change -- we're at the top of the hill.

-normalize 0,255 -- of course, so we can see what is going on.

Couple or three posts back you used the word 'structure', which I think is a very apt word. These steep slopes are the initial structuring elements of the stained glass; they furnish the reference marks from which the -distance command (next) starts measuring. Then -sharpen, given its extremely high parameter, finalizes the structure, making a web-work of 'cames' out of the pattern produced by the distance command.

Garry


Thanks Garry!
Tomorrow I will perform the suggested test.
Now for me it's time to go to bed...(it is 11 p.m. here)

Edit: OK, I did the small experiment you suggested: it clarifies to me even better the behaviour of -gradient_norm, thanks.
About the next steps, I'll work on later.

_________________
"Where am I ?"


Top
 Post subject: Re: G'MIC - tips and curiosities
PostPosted: Mon Mar 31, 2014 1:50 pm  (#77) 
Offline
GimpChat Member
User avatar

Joined: Mar 15, 2014
Posts: 115
Location: Brooklyn, NY
gradient_norm was Topic of the Day over at Particular Art, so there are examples similar to the one above. In the sweet fullness of time Ronounours Magick Mirroring Machine will have it over at G'MIC Sourceforge too.

Garry


Top
 Post subject: Re: G'MIC - tips and curiosities
PostPosted: Mon Mar 31, 2014 2:00 pm  (#78) 
Offline
GimpChat Member
User avatar

Joined: Jan 20, 2013
Posts: 14835
Location: roma, italy
Tip #18 - part 5

Let's continue, just a bit.

-mul[-2] [-1]

the image we left at the end of previous post (image2b in the attached zip file) is now multiplied by the original image (slightly modified by adding $im); the effect can be seen in image2c,
Attachment:
image2c.png
image2c.png [ 104.1 KiB | Viewed 2280 times ]

which shows the edges with some colours coming from the original).
Note: the base structure of the image is image2b, which is B&W, because whatever was in the original image -once multiplied by the black pixels of image2b- becomes black (everything multiplied by zero gives zero), while wherever image2b has pixels not-zero (i.e. its edge structure) the pixel is multiplied by the colour pixel in the original image.
Note that it is the original image which is substituted by the image resulting from the multiplication, the "edge" image is kept.

-distance[-1] 1

as opposed to the previous command, this one is applied to the "edge"image.
I take from the post of Garry: "These steep slopes are the initial structuring elements of the stained glass; they furnish the reference marks from which the -distance command (next) starts measuring"
Why this command uses the parameter("isovalue" says the documentation) 1?
I let Garry and David (if they find some time for us) explain how this nice effect is obtained.
It looks as a blurred dream of an angel, with new pieces of information: look at image2d;
Attachment:
image2d.png
image2d.png [ 58.78 KiB | Viewed 2280 times ]

you will see "new" blurred lines starting from the angles between neck and shoulders, as well as "new" blurred polygons in the bottom side of the image.

-sharpen[-1] 1e10

after this command, suddenly a real "stained glass" structure comes out! look at image2e.
Attachment:
image2e.png
image2e.png [ 54.46 KiB | Viewed 2280 times ]

All the blurred pieces of informations, present in image2d, have been dramatically sharpened.
Wow!
(btw, my guru friends: which number does 1e10 correspond to? in my poor scientific calculator it says 27.1828...but this is certainly wrong, if I replace 1e10 by 27 in the command I get a much more limited sharpening; the result is approximated if I put 270000 instead..)

(continues)

_________________
"Where am I ?"


Top
 Post subject: Re: G'MIC - tips and curiosities
PostPosted: Mon Mar 31, 2014 2:03 pm  (#79) 
Offline
GimpChat Member
User avatar

Joined: Jan 03, 2011
Posts: 1656
Here it is : http://gmic.sourceforge.net/tutorial/_g ... norm.shtml

I need to find a way to group commands by themes, because the list of described command becomes quite large.
Thanks a lot Garry for this hard work you are doing day after day.


Top
 Post subject: Re: G'MIC - tips and curiosities
PostPosted: Mon Mar 31, 2014 2:07 pm  (#80) 
Offline
GimpChat Member
User avatar

Joined: Jan 20, 2013
Posts: 14835
Location: roma, italy
grosood wrote:
gradient_norm was Topic of the Day over at Particular Art, so there are examples similar to the one above. In the sweet fullness of time Ronounours Magick Mirroring Machine will have it over at G'MIC Sourceforge too.

Garry

thanks, Garry!
I will put an eye on there (mathematical expressions aside...!)

_________________
"Where am I ?"


Top
Post new topic Reply to topic  [ 99 posts ]  Go to page Previous  1, 2, 3, 4, 5  Next

All times are UTC - 5 hours [ DST ]



* Login  



Powered by phpBB3 © phpBB Group