It is currently Tue Jun 09, 2026 5:47 am


All times are UTC - 5 hours [ DST ]



Post new topic Reply to topic  [ 99 posts ]  Go to page 1, 2, 3, 4, 5  Next
Author Message
 Post subject: Re: G'MIC - tips and curiosities
PostPosted: Wed Jun 19, 2013 1:06 pm  (#11) 
Offline
GimpChat Member

Joined: Sep 24, 2012
Posts: 275
Location: Scotland
Hi Zonder :)

I assume this is the page you mean:

http://sourceforge.net/p/gmic/wiki/How% ... 20plug-in/

I'm also keeping an eye on this thread for anything to add to the wiki ;)


Top
 Post subject: Re: G'MIC - tips and curiosities
PostPosted: Thu Jun 20, 2013 1:34 am  (#12) 
Offline
GimpChat Member
User avatar

Joined: Jan 20, 2013
Posts: 14831
Location: roma, italy
tip #4
what I say here sounds very trivial for G'MIC coders, but because as I said this topic is for novices who want to experiment, let's put it.
In image manipulation the capability to blend layers is very much common, so this tip is related to the command -blend.
Using G'MIC console under GIMP (as indicated on a previous post) do the following:
-open a new image in GIMP (no matter, make it transparent, we use it only for the dimensions)
-start G'MIC -> various -> custom code (local)
-enter 100%,100%,1,3 #create a new image(layer) same dimension, black by default
-enter -fill_color[1] 255,0,0 #fill the new layer with red (note: using positive numbers for
referencing images, [0] is the original, [1]...[n] are the additional ones created by yourself)
-enter 100%,100%,1,3 #create a new image(layer) same dimension, black by default
-enter -fill_color[2] 0,255,0 #fill the new layer with green
-enter --blend[1,2] add,0.50 #this will create a new layer with both colours blended
how are they blended?
a)the mode is "add"
b)the opacity is 50% of one layer over 100% of the other one (please note: it is clearly stated in the Handbook, the opacity should be entered as a value 0...1; do not make the easy mistake to enter 50 instead of 0.5; you wouldn't get any error, but simply the 50 is taken as 1)
c)which layer (which colour) is taken at 50%? green, so that you get an orange with red at 255 value and green at 127 value, but
d)NOT BECAUSE YOU ENTERED blend[1,2], what you put is irrelevant, even if you put blend[2,1] you get the same result, so remember:
e)the order in which images(layers) are considered is fixed UNLESS YOU EXPLICITLY CHANGE THE ORDER, so the command always take the younger as the one to which apply the indicated opacity
f)to change the order you may use an additional parameter in the -blend command, but to be more explicit (for a novice the clarity is always important) you may..
g)enter -reverse[1,2] #before blending, by this way you get a yellow-green with green at 255 value and red at 127 value.
I do not put examples, you may experiment yourself in the command window

_________________
"Where am I ?"


Top
 Post subject: Re: G'MIC - tips and curiosities
PostPosted: Thu Jun 20, 2013 11:45 am  (#13) 
Offline
GimpChat Member
User avatar

Joined: Jan 20, 2013
Posts: 14831
Location: roma, italy
Tip #5
Let's talk about a command not immediately understandable in its behaviour: -threshold
You may use it with two different options in the first parameter (the threshold value)
and with two different options in the second parameter (hard or soft)

1° parameter:
A)entering an absolute value (let's assume: 100)
in this case all values in the image (in a RGB image the single values of R, G, B in each pixel)
are reduced of that value (negative results become zeroes)
for example an area of pixels with values R250+G150+B50 becomes an area of values R150+G50+B0
B)entering a percentage (let's assume 40%)
in this case the command performs a search for the highest value actually present in the image,
then to this maximum the percentage is applied and the result becomes the absolute threshold value;
assuming there is at least one value of 255, the threshold of 40% is calculated as 102 (40% of 255)
then the previous algorithm is applied, so the mentioned area will become an area of values
R148+G48+B0
this clarifies that the percentage is not applied to the single values as one could have expected

2° parameter:
A)0=hard (default)
in this case all values which ended up in the previous algorithm to a positive number >0
are converted to 1; thus the image will have only 0 and 1 values in each colour of an RGB pixel
B)1=soft (you must enter it to replace default)
in this case all values previously calculated remain as calculated
In both cases it is recommended to enter afterwards the command
-normalize 0,255
Well, in case you selected a small value and soft-mode, you may also look at the transformed
image without normalizing it (maybe you like it);
if you opted for the default hard-mode the -normalize command is mandatory, otherwise you get
only a black screen.

Uses:
1)using soft-mode + normalize you get colours somehow "stretched" and "contrasted", you may
experiment on images lacking of vivacity
-threshold 25%,1
-normalize 0,255
2)using hard-mode + normalize you get a nice kind of "cartoonized" image, having 8 colours:
black, white, red, green, blue, cyan, yellow and magenta (you may understand this by thinking
about the fact that each hard value is either 1 or 0 and there are 3 values - r g b - so 2 to the
power of 3 is 8: rgb hard=000 or 001 or 010 or 011 or 100 or 101 or 110 or 111, which after normalization become: 0 0 0 / 0 0 255 / 0 255 0 / 0 255 255 / 255 0 0 / 255 0 255 / 255 255 0 / 255 255 255,
alias: black blue green cyan red magenta yellow white)
normally a good result is obtained using 50% as first parameter, thus:
-threshold 50%,0
-normalize 0,255
experiment on G'MIC console

_________________
"Where am I ?"


Top
 Post subject: Re: G'MIC - tips and curiosities
PostPosted: Thu Jun 20, 2013 12:02 pm  (#14) 
Offline
GimpChat Member

Joined: Oct 21, 2012
Posts: 13
@Garacoder: yep, thank you.


Top
 Post subject: Re: G'MIC - tips and curiosities
PostPosted: Thu Jun 20, 2013 12:28 pm  (#15) 
Offline
GimpChat Member

Joined: Sep 24, 2012
Posts: 275
Location: Scotland
Came here to vent a little... just began adding a page on the wiki for these tips, had a couple paragraphs written and layed out nice then *bam* server error :yell
SF seems to be running like crap for me the last couple days so think I'll leave it until I calm down and they finish the updates. Keep up the good work though dinasset!

Edit: managed to get it working this time:

http://sourceforge.net/p/gmic/wiki/Tips ... riosities/

Still needs a bit of formatting but at least it's on now :)


Top
 Post subject: Re: G'MIC - tips and curiosities
PostPosted: Fri Jun 21, 2013 2:55 am  (#16) 
Offline
GimpChat Member
User avatar

Joined: Jan 20, 2013
Posts: 14831
Location: roma, italy
tip #6
let's talk about the command -max
(you find its description on page 61-62 of the Handbook)
It' very generic and can be used for many purposes, I refer explicitly to example 76,
which is able to "fade" an open image.
So, open an image in Gimp, start G'MIC->Various->Custom code (local).
Enter the command of the example:
-max 'R=((x/w-0.5)^2+(y/h-0.5)^2)^0.5;255*R'

warning: verify that the symbol ^ - as entered from your keyboard - corresponds to
the hexadecimal value x'5e' (thanks to GC for his invaluable help on that)

as you can see, the image is faded out from the centre towards the corners
in fact, the formula create like a b/w fading mask starting from black at the centre,
then for each pixel the command chooses between the values in the image and the values
in the mask defined by the formula.
So you see grey pixels overriding the image pixels around the centre
(none close to the centre, a lot close to the corners).

Assume you have an image where the centre of attention is NOT the centre of the image.
In this case you may change the formula on the first and second "0.5" you find in it:
- reducing the first 0.5 moves the centre of the attention to the left
- increasing the first 0.5 moves the centre of attention to the right
- reducing the second 0.5 moves the centre of the attention to the top
- increasing the second 0.5 moves the centre of attention to the bottom

So, if you enter the command modified as such:
-max 'R=((x/w-0.25)^2+(y/h-0.25)^2)^0.5;255*R'
you get an image with the centre of the attention on the top-left quadrant
if you enter the command modified as such:
-max 'R=((x/w-0.75)^2+(y/h-0.75)^2)^0.5;255*R'
you get an image with the centre of the attention on the bottom-right quadrant

Now, assume you want a centre of attention smaller or larger.
In this case you have to play with the last 0.5 in the formula:
- reducing that value you reduce the centre of attention area
- increasing that value you enlarge the centre of attention area
Let's experiment with:
-max 'R=((x/w-0.50)^2+(y/h-0.50)^2)^0.25;255*R'
-max 'R=((x/w-0.50)^2+(y/h-0.50)^2)^0.75;255*R'
and you will see the effects.

_________________
"Where am I ?"


Top
 Post subject: Re: G'MIC - tips and curiosities
PostPosted: Sat Jun 22, 2013 5:29 am  (#17) 
Offline
GimpChat Member
User avatar

Joined: Jan 20, 2013
Posts: 14831
Location: roma, italy
Tip #7

about command -resize

part A)

creating a pattern then applying -resize

#open gimp
#create an image 30*30, black
#select G'MIC -> various -> custom code (local)
#remove what you find in
#enter:
(1,0,0;0,1,0;0,0,1^0,1,0;0,0,1;1,0,0^0,0,1;1,0,0;0,1,0)
#this command creates a new image 3*3 with colours R G B ; B R G ; G B R
-normalize 0,255 #for safety, as usual
-resize[1] [0],3 #this is the command under examination
#in this case: resize the newly created pattern to the base image dimensions
#using linear interpolation
-keep[1] #just to see only the newly created image
#set output mode: new image
#set OK

now, we will tests other resizing options, just replacing the command -resize
-resize[1] [0],0,0 #we get the "canvas" (let me call it this way) resized
#but the pattern is not rescaled, left 3*3 at the top-left corner
#first 0 means no interpolation, second 0 means boundary black
-resize[1] [0],0,1 #we get the "canvas" (let me call it this way) resized
#but the pattern is not rescaled, left 3*3 at the top-left corner
#first 0 means no interpolation, second parameter=1 means
#boundary extended with the colours of the last pixel (we see a lot
#of red because the bottom right pixel is red)
-resize[1] [0],0,2 #we get the "canvas" (let me call it this way) resized
#and filled completely by the pattern 3*3
#first 0 means no interpolation, second parameter=2 means
#boundary extended with replications
-resize[1] [0],1,0 #we get the 3*3 pattern rescaled 30*30
-resize[1] [0],2,0 #same as with 1
-resize[1] [0],3,0 #we get the 3*3 pattern rescaled 30*30
#and colours nicely interpolated
-resize[1] [0],3,1 #same as above, with a different interpolation of the boundaries
#you can put 5 or 6 in the previous 2 examples and you will get almost same results
#as with 3; the difference is in the interpolation (linear, bicubic, lanczos)
-resize[1] [0],4,0 #we get a black grid interpolating the 3*3 pattern
#in this case, due to the big resizing (10 to 1),
#the grid is big and occupies 9/10 of the image


part B)

applying -resize to an existing image

#open gimp
#open your image
#experiment with:
--resize 300%,200%,1,3,0,2 #you get your image replicated six times (3*2)
#or
--resize 110%,110%,1,3,4,0 #you get a grid interpolated (10% only)
#you may also apply again interpolation 4 on the already interpolated image
-resize 150%,150%,1,3,4,0 #you get a nice kind of double grid
#also try
--resize 110%,110%,1,3,0,1 #you get a kind of frame with the boundary #extended (having added 0.5,0.5 the image is centred)

#OK, now continue as you like (if you like...)

#I attach a folder with my tests.
#all images have been saved with the name: pattern-resize-n(-m) or image-resize-n(-m)
#where n is the interpolation type, m(shown if not zero) is the boundary type

#note: interpolation 3, 5, 6 (linear, bicubic, lanczos)
#are the usual resizing interpolation types
#found in almost all image processing software


Attachments:
Tests-resize.7z [1.4 MiB]
Downloaded 108 times

_________________
"Where am I ?"
Top
 Post subject: Re: G'MIC - tips and curiosities
PostPosted: Sat Jun 22, 2013 7:41 am  (#18) 
Offline
GimpChat Member
User avatar

Joined: Jan 03, 2011
Posts: 1656
Very interesting to see how you think dinasset. Please keep on writing about your feelings :)


Top
 Post subject: Re: G'MIC - tips and curiosities
PostPosted: Sun Jun 23, 2013 1:34 am  (#19) 
Offline
GimpChat Member
User avatar

Joined: Jan 20, 2013
Posts: 14831
Location: roma, italy
(thanks, David, for your comment)

tip #8

Some simple commands to be used for photo aspect modification.

Many (if not all) of the following effects are available in "ready-to-go" filters,
but I prefer discuss here of "native" commands you can insert in your G'MIC experiments.

-vignette

this command is shown in the handbook without indication of the default parameters:
strength, minimum radius, maximum radius
by experimenting it seems the defaults are: 100,70,90
so, you can increase or reduce the "black" of the mask by increasing/reducing
the first value
the radius parameters are referring to the "untouched" area of the image,
and must be values in the range 0-100
so you can shrink or enlarge the untouched area by reducing/increasing delta radius,
that is: the difference between the two values
note: even if the first radius is said to be "minimum" and the second one "maximum",
what really matters is the difference between the two;
so you get the same result with 100,40,80 as with 100,80,40
if the two radius have equal values, no vignette occurs;
if you have a photo with a well centred point of interest (well, it should be the case,
otherwise vignetting is not appropriate), I found a nice result with:
-vignette 200,50,100


-texturize_paper

this command has no parameter, but a very nice effect, as if the photo was printed
on a paper with a rough surface


-texturize_canvas

this command has three parameters: amplitude, fibrousness, emboss-level;
also the defaults are specified: 20, 3, 0.6
defaults produce very nice effect, as if the photo was printed
on a canvas, like a painting
but -as the real canvas a real painter finds in a shop- texture may vary a lot;
so, you may do some experiment: I like to increase the first value but not the others:
I like the result of
-texturize_canvas 50
but it's a matter of taste


note that with this command -as well as with the previous one- you get different
results even if you do not change parameters, i.e. G'MIC creates the texture
to a certain extent "randomly" (at least: this is the effect running it in the
G'MIC console and hitting "update" without changing parameters, try it)


(...continues...)

_________________
"Where am I ?"


Top
 Post subject: Re: G'MIC - tips and curiosities
PostPosted: Sun Jun 23, 2013 9:41 am  (#20) 
Offline
GimpChat Member
User avatar

Joined: Jan 20, 2013
Posts: 14831
Location: roma, italy
tip #8 (continues)

another couple of commands which could be useful to transform a little bit your photos are:
-light_patch
-shadow_patch
I like them to increase the atmosphere of a garden with trees, especially the first one.
The second one can be added with a very low level of shadow,
(which correspond to a high level of the single parameter: "opacity" (?!).

In the example -I show you to get a feeling of what can you end up with- I used:
-light_patch 20,0.8,2.1 #density, darkness, lightness (defaults are: 10,0.9,1.7
-shadow_patch 0.8 #opacity, default is 0.7

image before (photo-montage)
Attachment:
Fuji_20041019_Image007_JS.JPG
Fuji_20041019_Image007_JS.JPG [ 236.24 KiB | Viewed 3232 times ]


image after the two commands
Attachment:
Fuji_20041019_Image007_JS_lightpatch.JPG
Fuji_20041019_Image007_JS_lightpatch.JPG [ 252.36 KiB | Viewed 3232 times ]

_________________
"Where am I ?"


Top
 Post subject: Re: G'MIC - tips and curiosities
PostPosted: Mon Jun 24, 2013 9:34 am  (#21) 
Offline
GimpChat Member

Joined: Oct 21, 2012
Posts: 13
documentation tip:
if you look for a command in the reference web page (my post look too spamy to give your the URL) add two spaces in your search bar, it will make things easier.

For example, look for "-append" and you'll find too many things, look for " -append" and you'll find the command help.


Top
 Post subject: Re: G'MIC - tips and curiosities
PostPosted: Mon Jun 24, 2013 1:29 pm  (#22) 
Offline
GimpChat Member
User avatar

Joined: Jan 20, 2013
Posts: 14831
Location: roma, italy
Tip #9

today we talk about a "funny" command:

-uniform_distribution

I call it "funny" because -if I play with the second parameter- I may get funny results.
Certainly they are not funny for a scientist, but we talk among non-scientist gimp users.
Anyhow, to avoid confusion, we will strictly adhere to a basic rule:
because the second parameter is the "spectrum" (which is the name of the fourth
dimension of an image, i.e. the "channels") we will use this second parameter:
a) set to 3 when we play with an RGB image
b) set to 4 when we play with an RGBA image
The first parameter defines the number of colour-levels, which for us become stripes.
First of all we set the environment:
(1)open a new gimp image, white, RGB, default 640x400 pixels
(2)start GMIC console (you know how to) and set output to "new image"
(3)enter this sequence of commands (after having cleaned the area)
-----------------------------------------------------------------------------
(4)-uniform_distribution 64,3 #as in the example on page 34 of the handbook
#this will create an image 64x1x1x3
(5)-normalize[1] 0,255 #as usual
(6)-resize[1] [0] #expand the created image to the gimp image
(7)-keep[1] #to have as output only the new image
-----------------------------------------------------------------------------

case A) RGB image
With the shown parameters we get an image 640x400x1x3 filled with coloured stripes.
You see 64 stripes (=1°parameter), in 4 groups, with colours moving from dark to light.
Each group can be considered subdivided in 4 sub-groups.
Each of the 4 sub-groups contains 4 stripes
The colours vary as such:
(r)the red varies on each stripe with a sequence of 0 - 85 -170 -255
(g)the green varies on each sub-group with a sequence of 0 - 85 -170 -255
(b)the blue varies on each group with a sequence of 0 - 85 -170 -255

case B) RGBA image
(1) modify step 1 to get an RGBA image (use Layer->Transparency->Add alpha channel)
(4) modify step 4 to set the second parameter to 4 (-uniform_distribution 64,4)
You still see 64 stripes, but in 3 groups subdivided in 3 sub-groups.
Each sub-group has 7 stripes, except the first one wich has 8 stripes
(or -maybe- there is an initial group of one stripe only, you cannot distinguish)
The first group(1+7*3 stripes) is totally transparent, because of alpha set to 0.
The second group shows an alpha of 127.
The third group shows an alpha of 255 (full colours).
We will consider the last group for colour analysis (for the other two apply alpha).
In this third group the colours vary as such:
(r)the red varies on each stripe but not with an equal sequence on the sub-groups
(g)the green varies with the sequence 0-0-0-127-127-255 along each sub-stripe
(b)the blue varies regularly among groups with value 0-127-255
Maybe that -having an additional channel- the number of stripes has to different.

What to do?
It's up to you.
I play converting those images to gimp palettes and mapping one of my images with them.
You can see the result.
Attachment:
IMAGE-mapped-unidistr.jpg
IMAGE-mapped-unidistr.jpg [ 243.48 KiB | Viewed 2467 times ]

_________________
"Where am I ?"


Top
 Post subject: Re: G'MIC - tips and curiosities
PostPosted: Sun Jun 30, 2013 10:12 am  (#23) 
Offline
GimpChat Member
User avatar

Joined: Jan 20, 2013
Posts: 14831
Location: roma, italy
Tip #10

Let' talk about gradients (in Gimp language).
One could say: well, there are fantastic gradients in Gimp, why that?
Right, but -afaik- Gmic is not able to access Gimp resources, so if one likes to create a custom Gmic command self-standing, it's better to know how to create gradients to be used for overlaying images and so on.

Recall: to define a new image with predefined colours we need:
- 2 parenthesis outside ( ..... )
- a string of numbers inside where:
-- points on the same row are separated by commas (,)
-- columns are separated by semicolons (;)
-- colours are separated by the symbol ^
Values "per-se" are irrelevant, what's important is the proportion among them.
At the end we will insert the command -normalize to get visible values.

I write down here some examples of gradients:
note the full sequence of commands is written only on gradient 1, for the other only the line related to the gradient is shown
______________________________________________________________________

#gradient 1 (generic)

(2,2,0;2,2,0;0,0,0^0,2,2;2,2,2;2,2,0^0,0,0;0,0,2;0,2,2)
-normalize[1] 0,255
-resize[1] [0],3
-keep[1]

#corners:
#top-left=red
#top-right=green
#bottom-left=green
#bottom-left=blu

#mid-points:
#top=yellow
#left=yellow
#right=cyan
#bottom=cyan
___________________________________________________________________

#gradient 2 (landscape)
(0,0,0;0,0,0;3,3,3^0,0,0;3,3,3;1,1,1^2,2,2;3,3,3;0,0,0)

#top-line=blue
#mid-line=cyan
#bottom-line=red-orange
__________________________________________________________________

#gradient 3 (seascape)
(0,0,0;1,1,1;0,0,0^1,1,1;3,3,3;2,2,2^2,2,2;3,3,3;2,2,2)

#top-line=blue
#mid-line=cyan
#bottom-line=red-orange
________________________________________________________________________

#gradient 4 (blue-cyan vignette)
(0,3,3,0;2,5,5,2;2,5,5,2;0,3,3,0^1,3,3,1;3,5,5,3;3,5,5,3;1,3,3,1^1,3,3,1;3,5,5,3;3,5,5,3;1,3,3,1)

#corners="dirty"-blue-cyan
#mid-points="dirty" white
________________________________________________________________________

#gradient 5 (red-orange vignette)
(3,8,8,3;3,11,11,3;3,11,11,3;3,6,6,3^0,2,2,0;2,8,8,2;2,8,8,2;0,2,2,0^0,0,0,0;1,5,5,1;1,5,5,1;0,0,0,0)

#corners="dirty"-red
#mid-points="dirty"-orange
=====================================================
attached a zipped folder


Attachments:
gradients.7z [65.86 KiB]
Downloaded 90 times

_________________
"Where am I ?"
Top
 Post subject: Re: G'MIC - tips and curiosities
PostPosted: Tue Jul 02, 2013 2:42 pm  (#24) 
Offline
GimpChat Member
User avatar

Joined: Jan 20, 2013
Posts: 14831
Location: roma, italy
Tip #11

Today we talk about a rarely mentioned command: -name
It does neither create nor modify an image.
So, why to talk about it?
Well, as said many times, this topic is for non-scientist candidate coders in GMIC world, thus clarity is very important for us.
As it is recommended among us to use -at least during the initial period of experiments-:
a) one line per command
b) the full-text command instead of the abbreviated one (-remove not -rm, -reverse not -rv, ...),
so it could be useful to use
c) the command -name to better understand the code, especially when it becomes complex.

Here an example.

(assume we call GMIC after having created a new image in GIMP, white)

we enter:
-name[0] white_image # from now on, we can refer to the image received in input as "white_image"

then we enter:
[white_image]x3 # we ask GMIC to create 3 copies of the received image

then we rename all three copies as such:
-name[1] first_copy
-name[2] second_copy
-name[3] third_copy


we like to fill the copies with different colours, so we enter:
-fill_color[first_copy] 255 # pure red
-fill_color[second_copy] 0,255 # pure green
-fill_color[third_copy] 0,0,255 # pure blue

well, better now if we rename those three copies with more meaningful names, so we enter:
-name[first_copy] red,1 # the ,1 stays for renamed ("is_modified")
-name[second_copy] green,1
-name[third_copy] blue,1

OK, now we now which layers we manage, so let's enter:
-reverse[green,red] # we reverse the order between the second and the first copy
# after this command, the series of layers will be:
# white, green, red, blue

we enter a command which will verify the order we imposed to the layers
the blend command blends each pair of layers on the stack
we use average-mode to better verify values of colours
--blend average # two new layers are created:
# the first new layer comes from blending white and green
# the second new layer comes from blending red and blue
we double-check the result using the colour-picker tool of gimp
on the first new (fifth in the list) we find the colour: 127,255,127 OK
on the second new (sixth in the list) we find the colour: 127,0,127 OK

we could also play again and enter a new:
--blend average # other three new layers are created:
# the first two are exactly the same as before
# the third one comes from blending the pale green (fifth layer) and the purple (sixth layer)
we double-check again with the colour-picker and we find the colour: 127,127,127 OK

Have fun!

_________________
"Where am I ?"


Top
 Post subject: Re: G'MIC - tips and curiosities
PostPosted: Tue Jul 02, 2013 3:15 pm  (#25) 
Offline
GimpChat Member

Joined: Apr 12, 2010
Posts: 5870
I found very useful this commands also when writing filters :
when a filter create several "virtual images" (i say virtual because the final result will be only one image created by their combinations ), or in other words a complex layerstack often i found tricky guess their position in the layerstack (i mean for me is often tricky , not sure why but i tend to misplace at least 1, and that 1 of course misplace others in a chain reaction )

-name each of this images helped me a lot, ...
as examples if you see that is something wrong in the layerstack , if your virtual-images/layers (never sure how to call them) are named ,i.e. " BG" "middle" "Top Layer" will be easy use the command -move to correct and place everything in the right place .

PS
you will not find -name in my finished filters, but i used often in the wip stage .

_________________
My 3D Gallery on Deviantart http://photocomix2.deviantart.com/
Main gallery http://www.flickriver.com/photos/photocomix-mandala/
Mandala and simmetry http://www.flickriver.com/photos/photocomix_mandala/

Image

Mrs Wilbress


Top
 Post subject: Re: G'MIC - tips and curiosities
PostPosted: Tue Jul 02, 2013 4:27 pm  (#26) 
Offline
GimpChat Member

Joined: Sep 24, 2012
Posts: 275
Location: Scotland
It's great to have all this dinasset, I'm sure some people who were a little scared to try things will have a go now. It's becoming one of the biggest pages on the wiki too :bigthup

http://sourceforge.net/p/gmic/wiki/Tips ... riosities/

Still needs some tidying which I'll get around to sometime :yup


Top
 Post subject: Re: G'MIC - tips and curiosities
PostPosted: Wed Jul 03, 2013 8:49 am  (#27) 
Offline
GimpChat Member
User avatar

Joined: Jan 20, 2013
Posts: 14831
Location: roma, italy
many thanks, PC!
many thanks, GC!
I hope this can help some new candidate coder in GMIC...

_________________
"Where am I ?"


Top
 Post subject: Re: G'MIC - tips and curiosities
PostPosted: Wed Jul 03, 2013 2:38 pm  (#28) 
Offline
GimpChat Member
User avatar

Joined: Jan 20, 2013
Posts: 14831
Location: roma, italy
Attachment:
CLEANED-LUMACHROMA.JPG
CLEANED-LUMACHROMA.JPG [ 289.88 KiB | Viewed 2366 times ]
Attachment:
CLEANED-RGB.JPG
CLEANED-RGB.JPG [ 328.39 KiB | Viewed 2366 times ]
Attachment:
ORIGINAL.JPG
ORIGINAL.JPG [ 1.16 MiB | Viewed 2366 times ]
Tip #12

Today we will enter into photo manipulation/enhancement.
At first, a very useful denoising command:
-bilateral
This works better than other "traditional" methods:
- it does not blur the image
- it does not create halos
because it preserves edges (does not average pixels across edges).
Warning: this "quality" may become a "defect" when command is used with high values.
Result could be a "cartoonised" image.
The command uses two parameters:
a) the "space" (extension of the area around each pixel to be used for averaging)
b) the "range" (the minimum amplitude for considering an "edge")

We detail two approaches:
1 - applying the denoising function to each colour channel separately.
(it's known that noise is greater on red and blue channels than on the green one)
2 - applying the denoising function separately on luma and chroma
(it's known that we may blur colours more than luminosity)

Case 1

enter the following sequence of commands:
--split[0] c # the input image is split into 3 layers: R,G,B
# we use the naming command as already learned
-name[1] red
-name[2] green
-name[3] blue
# now we call -bilateral with different values for each colour
-bilateral[red] 2.5,5
-bilateral[green] 1.25,2.5
-bilateral[blue] 3.75,7.5
# small values for green, higher values for red and blue
# now we recombine the 3 layers into a single RGB image
--append[blue,green,red] c
# we give it a name
-name[4] cleaned
# we save only the result, discarding the rest
-keep[cleaned]

The first value can be better entered as a percentage of image space, for example:

--split[0] c
-name[1] red
-name[2] green
-name[3] blue
-bilateral[red] 1%,7
-bilateral[green] 0.25%,3
-bilateral[blue] 1.5%,10
--append[blue,green,red] c
-name[4] cleaned
-keep[cleaned]



Case 2 using YCbCr to split the image (luma-chroma)

-rgb2ycbcr # split the image into 3 layers, 1 for luma, 2 for chroma
--split[0] c
-name[1] luma
-name[2] chromaB
-name[3] chromaR
-bilateral[luma] 1.25,1.25
-bilateral[chromaB] 8.75,8.75
-bilateral[chromaR] 8.75,8.75

# low values for luma, higher values for chroma
--append[luma,chromaB,chromaR] c
-name[4] cleaned
-ycbcr2rgb[cleaned]
-keep[cleaned]


also in this case, we better use percentage as first parameter

-rgb2ycbcr
--split[0] c
-name[1] luma
-name[2] chromaB
-name[3] chromaR
-bilateral[luma] 0.25%,3
-bilateral[chromaB] 3%,10
-bilateral[chromaR] 3%,10
--append[luma,chromaB,chromaR] c
-name[4] cleaned
-ycbcr2rgb[cleaned]
-keep[cleaned]

-------------------------------------------------------------------
I place here one example, but you may play with your images and changing values

_________________
"Where am I ?"


Top
 Post subject: Re: G'MIC - tips and curiosities
PostPosted: Wed Jul 03, 2013 6:31 pm  (#29) 
Offline
GimpChat Member

Joined: Apr 12, 2010
Posts: 5870
I saw only now tip 10 ... thank that code snippet may be really handy !

_________________
My 3D Gallery on Deviantart http://photocomix2.deviantart.com/
Main gallery http://www.flickriver.com/photos/photocomix-mandala/
Mandala and simmetry http://www.flickriver.com/photos/photocomix_mandala/

Image

Mrs Wilbress


Top
 Post subject: Re: G'MIC - tips and curiosities
PostPosted: Wed Jul 03, 2013 8:14 pm  (#30) 
Offline
GimpChat Member

Joined: Feb 13, 2013
Posts: 86
Most images have more noise in the shadows. A simple method of changing the noise reduction strength in the shadows is to us the -apply_gamma command before the noise reduction, and then again afterwards to reverse the initial gamma change.

-apply_gamma 0.7 # makes image darker and reduces contrast in the shadows

# rest of the filter goes here.


-apply_gamma {1/0.7} # Reverses the gamma change at the start to give correct brightness.



This works because the gamma change reduces the contrast between dark pixels, and increases the contrast between light pixels, so the bilateral filter smooths darker parts of the image more than the lighter parts.

A gamma value less than 1 will increase the noise reduction in the shadows, a gamma value greater than 1 will have the opposite effect and the highlights will have more noise reduction. A value of one will have no effect.


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

All times are UTC - 5 hours [ DST ]



* Login  



Powered by phpBB3 © phpBB Group