It is currently Wed Aug 12, 2026 1:33 pm


All times are UTC - 5 hours [ DST ]



Post new topic Reply to topic  [ 18 posts ] 
Author Message
 Post subject: @ Garagecoder Stitching images
PostPosted: Wed May 29, 2013 7:11 am  (#1) 
Offline
GimpChat Member
User avatar

Joined: Jan 20, 2013
Posts: 14831
Location: roma, italy
@garagecoder
Thanks for your support.
I tried to post a PM about this topic but (unless I'm wrong) I can't attach files on that, so I created this new topic.
If of no interest for anybody else, you can delete it afterwards.
So, what I'm trying to do using G'MIC is the following:
- open an image (see original)
- call my python script which does the following:
- - mask-fade the right part of the image for the input value of desired pixels (here 100)
- - create a new image with a width which corresponds almost to the double of the original width - pixels of fading
(new space is transparent)
- - paste the faded original as a layer, left justified
- - flip the faded original
- - paste the flipped original as a layer, right justified
- - flatten the new image (see stitched)

first attachment:
Attachment:
Original.png
Original.png [ 298.32 KiB | Viewed 3556 times ]


second attachment:
Attachment:
Stiched.png
Stiched.png [ 475.83 KiB | Viewed 3556 times ]


thanks for your support

edit: I mentioned what I do now (call my python) to detail the steps, I obviously don't want to call the python from inside a gmic command, but do all the steps using only gmic commands...

_________________
"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: @ Garagecoder Stitching images
PostPosted: Wed May 29, 2013 7:50 am  (#2) 
Offline
GimpChat Member

Joined: Sep 24, 2012
Posts: 275
Location: Scotland
OK that shouldn't be too difficult, I'm working just now but will reply properly as soon as I can! In the mean time perhaps another gmic scripter can chip in :)


Top
 Post subject: Re: @ Garagecoder Stitching images
PostPosted: Wed May 29, 2013 8:50 am  (#3) 
Offline
GimpChat Member
User avatar

Joined: Jan 03, 2011
Posts: 1656
I gave a try, not sure if this is exactly what you want, just let me know.
Filter is under 'Testing/Ronounours/Faded mirror' and looks like this :

Attachment:
gmic_faded_mirror.png
gmic_faded_mirror.png [ 177.84 KiB | Viewed 3493 times ]


Just refresh your filters and it should appear.

PS : This is the piece of code I wrote for this effect : http://pastebin.com/g1MGD2Dh


Top
 Post subject: Re: @ Garagecoder Stitching images
PostPosted: Wed May 29, 2013 9:28 am  (#4) 
Offline
GimpChat Member
User avatar

Joined: Jan 20, 2013
Posts: 14831
Location: roma, italy
Excellent Ronounours! Done some trials and it looks as I like...
Now I will have a look to your code (to understand the commands...)
Thanks!!!

_________________
"Where am I ?"


Top
 Post subject: Re: @ Garagecoder Stitching images
PostPosted: Wed May 29, 2013 9:39 am  (#5) 
Offline
GimpChat Member
User avatar

Joined: Jan 03, 2011
Posts: 1656
Reading the code is maybe not the easiest thing to do in G'MIC (esp. mine... :(, as I don't comment it very much and use a lot the shortcuts for the command names).
Basically, what I did is to create an image of linear weights and I pre-multiplied the image values with these weights. I append the weight map to the pre-multiplied image (so it may have 4 or 5 channels), I resize it to the final size, mirror it and add the two togethers. Finally, I divide each image pixel by the sum of the corresponding weights to get the final result.
Nothing really outstanding :)


Top
 Post subject: Re: @ Garagecoder Stitching images
PostPosted: Wed May 29, 2013 9:58 am  (#6) 
Offline
GimpChat Member
User avatar

Joined: Jan 03, 2011
Posts: 1656
That's the point with G'MIC scripts. When we are used to code in G'MIC, it often takes more time to explain what it does than writing it (~5 mn to write the script in this case).


Top
 Post subject: Re: @ Garagecoder Stitching images
PostPosted: Wed May 29, 2013 10:54 am  (#7) 
Offline
GimpChat Member
User avatar

Joined: Jan 20, 2013
Posts: 14831
Location: roma, italy
Thanks Ronounours!!!
I understand the concepts you expressed (more or less....)
Should you find another ten minutes and a ton of patience, it could be fascinating and extremely useful to get your code commented line by line (what I'm saying!, no, term by term for poor beginners in gmic!). I saw that there are already other gmic curious....
In any case, your command is perfect and I like also the possibility to use it on y-axis, because I'm interested on creating water-reflections, like in the attached image, created with one of my python
Attachment:
WaterReflected.png
WaterReflected.png [ 431.11 KiB | Viewed 3442 times ]

_________________
"Where am I ?"


Top
 Post subject: Re: @ Garagecoder Stitching images
PostPosted: Wed May 29, 2013 11:03 am  (#8) 
Offline
GimpChat Member
User avatar

Joined: Jan 03, 2011
Posts: 1656
Note there is already something similar in the plug-in :

Image

Not sure I'll have the time to create a commented version of my code. I'll try.


Top
 Post subject: Re: @ Garagecoder Stitching images
PostPosted: Wed May 29, 2013 12:28 pm  (#9) 
Offline
GimpChat Member

Joined: Sep 24, 2012
Posts: 275
Location: Scotland
Ah I get home and there's even a filter done :D

I'll try to provide some comment on the code, with all commands in long form:

-repeat @# -local[$>] #repeat by number of images in stack, deal with each one separately (locally)
-if {$1==0} # if they have selected X-axis
100%,1,1,1,"a=1/(1-w*$2%);b=-a*(w-1);a*x+b" #create new single horizontal line of pixels in a fade (it is still classed as an image)
-cut[-1] 0.01,1 # cut values to range 0.01 minimum to 1 maximum
-mul[-2] [-1] # multiply original image by the fade
-resize[-1] 100%,[-2] # resize the fade to be full image size
-append c # append the fade as an alpha channel
-resize {2*w-w*$3%},100%,1,100%,0 # resize to twice width minus fade
--mirror x # create a new mirror image
-else # if they have selected Y-axis
1,100%,1,1,"a=1/(1-h*$2%);b=-a*(h-1);a*y+b" #create new single vertical line of pixels in a fade (it is still classed as an image)
-cut[-1] 0.01,1
-resize[-1] [-2],100%
-mul[-2] [-1]
-append c
-resize 100%,{2*h-h*$3%},1,100%,0
--mirror y
-endif
-add # add all images together (literally add the values)
-split[-1] c,-{s-1} # split alpha channel to separate image
-div[-2,-1] # divide image by the alpha channel
-endl -done # end of local section, end of loop


I'm sure David can correct me if I'm wrong ;)


Last edited by garagecoder on Wed May 29, 2013 1:40 pm, edited 1 time in total.

Top
 Post subject: Re: @ Garagecoder Stitching images
PostPosted: Wed May 29, 2013 12:39 pm  (#10) 
Offline
GimpChat Member
User avatar

Joined: Jan 20, 2013
Posts: 14831
Location: roma, italy
thanks GC!
I'll read carefully your comments

_________________
"Where am I ?"


Top
 Post subject: Re: @ Garagecoder Stitching images
PostPosted: Wed May 29, 2013 1:29 pm  (#11) 
Offline
GimpChat Member
User avatar

Joined: Jan 03, 2011
Posts: 1656
Thanks GC, you are all right. Maybe I can say that the 'weight' image is added to the current image whether it has an alpha-channel or not, resulting in an image that can have 4 or 5 channels.
At the end, with the final division, this last channel disappears. That means your input image can have an alpha channel too, it will be kept and processed as any other channel by this filter.


Top
 Post subject: Re: @ Garagecoder Stitching images
PostPosted: Wed May 29, 2013 1:37 pm  (#12) 
Offline
GimpChat Member

Joined: Sep 24, 2012
Posts: 275
Location: Scotland
I knew I was missing something with that last bit, that's why I kept to just the command description. You have a habit of using subtle/clever ways of dealing with things that I don't always spot :coolthup


Top
 Post subject: Re: @ Garagecoder Stitching images
PostPosted: Wed May 29, 2013 2:04 pm  (#13) 
Offline
GimpChat Member
User avatar

Joined: Jan 03, 2011
Posts: 1656
Maybe because I'm not afraid (anymore :)) of manipulating images with more than 4 channels. Four channels have been a limitation in many image processing libraries, so it has becoming not very intuitive to add even more channels to images we are working on, but the experience I had so far with CImg and G'MIC tells me it is often very interesting to do that kind of stuffs.


Top
 Post subject: Re: @ Garagecoder Stitching images
PostPosted: Thu May 30, 2013 2:13 am  (#14) 
Offline
GimpChat Member
User avatar

Joined: Jan 20, 2013
Posts: 14831
Location: roma, italy
Hi Ron & GC
I started playing with the new gmic script kindly provided by Ron and commented by GC, and - what is my primary objective - I started also trying to understand each piece of code in order to be able to steal and create something.
First step I'm concentrated on is performing the fading effect.
So I tried to copy only that part but I didn't get any fading effect, so I came back to the full script FadedMirror and played with the values on fading and overlapping.
By doing so I noticed that the fading effect operates only on the overlapped part, if zero overlapping is chosen, even entering 100% fading no fading occurs.
I attach here 3 images:
1-original
2-faded-mirrored with parameters 0,0,0 (=x-axis, fading=0, overlap=0)
3-faded-mirrored with parameter 0,100,0 (=x-axis, fading=100, overlap=0)
images resulting from 2 and 3 are identical (alias: no fading in both cases)
Attachment:
original.png
original.png [ 1.33 KiB | Viewed 1699 times ]
Attachment:
FadedMirror_0_0_0.png
FadedMirror_0_0_0.png [ 2.16 KiB | Viewed 1699 times ]
Attachment:
FadedMirror_0_100_0.png
FadedMirror_0_100_0.png [ 2.39 KiB | Viewed 1699 times ]

_________________
"Where am I ?"


Top
 Post subject: Re: @ Garagecoder Stitching images
PostPosted: Thu May 30, 2013 2:22 am  (#15) 
Offline
GimpChat Member
User avatar

Joined: Jan 20, 2013
Posts: 14831
Location: roma, italy
(continued)
To be more specific:
a - the new gmic function operates exactly as I like, for the purpose of stitching one image with itself reversed (in fact, in my simple python I had only one parameter, valid both for fading and overlapping)
b - my question in on the possibility for me to derive from there only the fading function to copy and paste it in another gmic function
What do I have to change from the first part of the code?
Many thanks...
(I attach here an image created manually with the result I thought would have been with 0,100,0; I repeat, not to alter the function which is perfect as it is, but to understand the code)
Attachment:
FadedMirrorManually_0_100_0.png
FadedMirrorManually_0_100_0.png [ 47.32 KiB | Viewed 1698 times ]

_________________
"Where am I ?"


Top
 Post subject: Re: @ Garagecoder Stitching images
PostPosted: Thu May 30, 2013 2:23 am  (#16) 
Offline
GimpChat Member
User avatar

Joined: Jan 20, 2013
Posts: 14831
Location: roma, italy
PostScriptum: the image appears here with a fading into white, but is really fades into transparent....

_________________
"Where am I ?"


Top
 Post subject: Re: @ Garagecoder Stitching images
PostPosted: Thu May 30, 2013 7:27 am  (#17) 
Offline
GimpChat Member
User avatar

Joined: Jan 03, 2011
Posts: 1656
Well, that is a slightly different algorithm in your case I suppose, as it involves the explicit creation of an alpha channel.
I would write something as :
foo :
  -remove_opacity[-1]
  100%,1,1,1,"255*(1-x/w)"
  -resize[-1] [-2],[-2]
  -append[-2,-1] c
  --mirror[-1] x
  -append[-2,-1] x

to return a 4-channel image with an alpha channel like this :


Attachments:
toto.png
toto.png [ 3.09 KiB | Viewed 1687 times ]
Top
 Post subject: Re: @ Garagecoder Stitching images
PostPosted: Thu May 30, 2013 8:01 am  (#18) 
Offline
GimpChat Member
User avatar

Joined: Jan 20, 2013
Posts: 14831
Location: roma, italy
Many thanks Ron!!

_________________
"Where am I ?"


Top
Post new topic Reply to topic  [ 18 posts ] 

All times are UTC - 5 hours [ DST ]



* Login  



Powered by phpBB3 © phpBB Group