It is currently Sat May 04, 2024 1:58 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: G'MIC - tips and curiosities
PostPosted: Wed Jun 19, 2013 7:50 am  (#1) 
Offline
GimpChat Member
User avatar

Joined: Jan 20, 2013
Posts: 14816
Location: roma, italy
Hi all G'MIC lovers, especially novice coders.
I open this new topic because the previous one (Reference Manual) I opened some times ago seems better reserved to scientists.
This one will be for those who are novice and curious about the fantastic but cryptic G'MIC language.
Anyone of those are invited to post here tips coming out from their (limited) experience.
Experts are welcome for correcting errors on what we are saying and adding experience (please, don't be too cryptic, for novices plain explanations are better understood...).
Each tip will be numbered, so comments can be referencing the specific tip, without the necessity to "quote" previous entries.
So, let's start....

_________________
"Where am I ?"


Share on Facebook Share on Twitter Share on Orkut Share on Digg Share on MySpace Share on Delicious Share on Technorati
Top
 Post subject: Re: G'MIC - tips and curiosities
PostPosted: Wed Jun 19, 2013 7:55 am  (#2) 
Offline
GimpChat Member
User avatar

Joined: Jan 20, 2013
Posts: 14816
Location: roma, italy
Tip #1
This one is not really a tip (neither a curiosity) but an important warning.
As some of you have learned from posts on the "Reference Manual" topic,
keep in mind that all images on the Handbook are normalized (0,255) before being printed, so do not rely on getting the same results when trying to apply the code examples unless you at the end of your trial code enter the additional command -normalize 0,255

_________________
"Where am I ?"


Top
 Post subject: Re: G'MIC - tips and curiosities
PostPosted: Wed Jun 19, 2013 8:31 am  (#3) 
Offline
GimpChat Member

Joined: Sep 24, 2012
Posts: 275
Location: Scotland
Tip #2
How do I add a new blank image filled with the color I want?
The short answer is like this:

800,600,1,3 # Add a new image 800x600 with 3 channels (i.e. for RGB)
-fc[-1] 255,0,0 # fill it with red

-or-

100%,100%,1,3 # Add a new image the same size as the last on the image list, 3 channels
-fc[-1] 0,255,0 # fill it with green


But don't forget:
An "image" can represent anything you want, it could be HSV/YcBcR/CMYK etc. or might not contain an image at all!
So it's wrong to think of a G'MIC image as always being red green blue :yup


Top
 Post subject: Re: G'MIC - tips and curiosities
PostPosted: Wed Jun 19, 2013 9:02 am  (#4) 
Offline
GimpChat Member
User avatar

Joined: Jan 20, 2013
Posts: 14816
Location: roma, italy
tip #3
how do I get a non-blank new rgb image with a single command?
- I want white: enter 100,100,1,3,255
- I want some nuance of grey: enter 100,100,1,3,128 or any other number between 1 and 254
- I'm curious and I enter: 100,100,1,3,128,64,32: wow!
I get a fantastic chess-board with any single pixel coloured in triplets like this:
1°pixel (and 4°...and 7°...) coloured with Red128+Green64+Blu32
2°pixel (and 5°...and 8°...) coloured with Red64+Green32+Blu128
3°pixel (and 6°...and 9°...) coloured with Red32+Green128+Blu64
Any use of this curiosity? well, if you need chess-boards tri-coloured you can create one
with the initial numers of how many squares you like (BUT ATTENTION! NONE OF THE TWO NUMBERS
REPRESETING WIDTH AND HEIGHT HAS TO BE A MULTIPLE OF 3 !!!) then enter the command -resize
to get the image size you want
- what about an initial value multiple of 3? Well, try: you will get a b/w image with
the three numbers (128,64,32) used as nuances of grey
if the number representing the width is multiple of 3,
the image results "striped" because - as in the previous example - the image is considered
like a unidimensional series of pixels, so that after the last one of the first row
the first one of the second row continues the series...
if the width is not multiple of 3, you get a chess-board in 3 different grey nuances
Any use of this second curiosity? If you need a striped image, do as above, but in this case
width must be a multiple of 3

I put here some results (using the resize, after the initial image is created)


Attachments:
GMIC_tests_new_image.7z [1.7 KiB]
Downloaded 183 times

_________________
"Where am I ?"
Top
 Post subject: Re: G'MIC - tips and curiosities
PostPosted: Wed Jun 19, 2013 9:56 am  (#5) 
Offline
Retired Staff
User avatar

Joined: May 22, 2008
Posts: 6947
Location: Somewhere in GIMP
This is a good idea but some instruction about where to put those commands would be nice. Most G'MIC users are not coders.

_________________
Image
World War IV will be fought with sticks and stones. - Albert Einstein


Top
 Post subject: G'MIC command line and general use info
PostPosted: Wed Jun 19, 2013 10:19 am  (#6) 
Offline
Global Moderator
User avatar

Joined: Nov 16, 2011
Posts: 5128
Location: Metro Vancouver, BC
Some G'MIC command line and general use information.

_________________
Image
Gimp 2.8.18, Linux, median user
Gimp Chat Tutorials Index
Spirit Bear (Kermode)


Top
 Post subject: Re: G'MIC - tips and curiosities
PostPosted: Wed Jun 19, 2013 10:19 am  (#7) 
Offline
GimpChat Member
User avatar

Joined: Jan 20, 2013
Posts: 14816
Location: roma, italy
here is a link, where to find first instructions on creating a G'MIC filter
http://zonderr.wordpress.com/2010/11/13 ... c-plug-in/

_________________
"Where am I ?"


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

Joined: Jan 20, 2013
Posts: 14816
Location: roma, italy
you can also experiment commands following these steps:
-open gimp
-open an image (no matter, even new one empty)
-go to filters
-select gmic
-when gmic opens:
-select "various"
-then select "custom code (local)"
-you may remove whatever you find in there
-then put your command(s)
-select "update" to see result in preview window or
-select "apply" / "OK" to have it executed

_________________
"Where am I ?"


Top
 Post subject: Re: G'MIC - tips and curiosities
PostPosted: Wed Jun 19, 2013 11:38 am  (#9) 
Offline
Retired Staff
User avatar

Joined: May 22, 2008
Posts: 6947
Location: Somewhere in GIMP
Thank you Odin and dinasset. This looks like something interesting to play with. :bigthup

_________________
Image
World War IV will be fought with sticks and stones. - Albert Einstein


Top
 Post subject: Re: G'MIC - tips and curiosities
PostPosted: Wed Jun 19, 2013 12:47 pm  (#10) 
Offline
GimpChat Member

Joined: Oct 21, 2012
Posts: 13
Hi everyone,

the post I wanted to write "looks too spamy for a new user" so I can't tell that every tuto from zonderr.wordpress has been copied and sometimes improved on the official wiki so it is probably better to direct people there.


Top
 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: 14816
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: 14816
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: 14816
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: 14816
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 85 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: 14816
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: 14816
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 1447 times ]


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

_________________
"Where am I ?"


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 ]


   Similar Topics   Replies 
No new posts Any tips for managing an 'epic' map? I appear to be CPU bound.

0



* Login  



Powered by phpBB3 © phpBB Group