It is currently Tue Jul 23, 2024 6:20 pm


All times are UTC - 5 hours [ DST ]



Post new topic Reply to topic  [ 15 posts ] 
Author Message
 Post subject: Average layer - help from ofnuts appreciated (solved, thanks)
PostPosted: Wed Jun 18, 2014 9:56 am  (#1) 
Offline
GimpChat Member
User avatar

Joined: Jan 20, 2013
Posts: 14816
Location: roma, italy
I just downloaded from Gimp Registry an old script "Average Layer", which looks interesting in certain cases.
I went through all the indications posted (on the Gimp Registry) by Panoworks (who says he got it run), but it doesn't show up in my Gimp.
I wanted to post a comment on Gimp Registry but it's currently impossible to create an account (you Ofnuts told why to another user, who was asking the same).
So -last chance- I would very much appreciate if Ofnuts could help me in one of these ways:
- if he has (or can have) a running copy of that plug-in, pls post here that amended copy (maybe it differs from my copy, amended according to Panoworks indications); I can also do the opposite and post my amended version here
- if he knows problems which are additional to those indicated by Panowork, pls tell them to me

(the only difference with what indicated by Panoworks is that I put the plug-in inside my User folder, not on the main Gimp folder; but it is detected during Gimp loading phases...)

thanks a lot

_________________
"Where am I ?"


Last edited by dinasset on Thu Jun 19, 2014 1:35 am, edited 1 time in total.

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: Average layer - help from ofnuts appreciated (if possible)
PostPosted: Wed Jun 18, 2014 10:59 am  (#2) 
Offline
Script Coder
User avatar

Joined: Oct 25, 2010
Posts: 4757
1) it requires the scipy package

2) strangely, its core function takes image and drawable as first parameters, but they aren't declared in the parameter list. And the parameter list is using a strange syntax (array instead of tuples, but that could work... or not). So that should at least be:
   [
        [PF_IMAGE, "image", "Input image", None],
        [PF_DRAWABLE, "drawable", "Input drawable", None],
   [PF_RADIO, "meantype", "Choose mean method", "arith", (
            ("A_rithmetical", "arith"),
            ("_Geometrical", "geom"),
            ("_Harmonic","harm"),
            ("M_edian","median"),
            ("_Mode", "mode"))],
   [PF_TOGGLE, "as_new_image", "Paste as new image", 1],
   [PF_TOGGLE, "only_visible_layers", "Only use visible layers", 1],
   [PF_SPINNER, "cutoff", "Cut off extreme values (percent).\n At least one value is left, \npercentage is rounded (floor) to whole layers", 10, (0,100,5)],
   [PF_SPINNER, "side", "Cut off side (dark (0), bright (1), both(2))", 2, (0,2,1)]
   ],

_________________
Image


Top
 Post subject: Re: Average layer - help from ofnuts appreciated (if possible)
PostPosted: Wed Jun 18, 2014 11:32 am  (#3) 
Offline
GimpChat Member
User avatar

Joined: Jan 20, 2013
Posts: 14816
Location: roma, italy
Yes, I have appropriately installed the scipy package (on Python and Gimp)
Yes, I added IMAGE and DRAWABLE as parameters

also I can tell you I did the following:
- edited with a specialized editor : no syntax errors found
- passed totally (registration excluded) through the python console, without any error...

_________________
"Where am I ?"


Top
 Post subject: Re: Average layer - help from ofnuts appreciated (if possible)
PostPosted: Wed Jun 18, 2014 12:18 pm  (#4) 
Offline
Script Coder
User avatar

Joined: Oct 25, 2010
Posts: 4757
This registration works for me:
register(
        "average_layer",
        "Compute average layer v1.1",
        "Compute average layer offering different statistical approaches.\n Arithmetical mean with cutoff equals winsorized mean.\n Try to use cutoff on both sides with different means \n to remove unwanted objects in a series of photographs.\n Mode is quite slow, but works (Take your time!).",
        "Elmar W. Hoefner",
        "Licensed under GPLv3",
        "May 2008",
        "Average Layer",
        "RGB*, GRAY*",
   [
        (PF_IMAGE, "image", "Input image", None),
        (PF_DRAWABLE, "drawable", "Input drawable", None),
   [PF_RADIO, "meantype", "Choose mean method", "arith", (
            ("A_rithmetical", "arith"),
            ("_Geometrical", "geom"),
            ("_Harmonic","harm"),
            ("M_edian","median"),
            ("_Mode", "mode"))],
   [PF_TOGGLE, "as_new_image", "Paste as new image", 1],
   [PF_TOGGLE, "only_visible_layers", "Only use visible layers", 1],
   [PF_SPINNER, "cutoff", "Cut off extreme values (percent).\n At least one value is left, \npercentage is rounded (floor) to whole layers", 10, (0,100,5)],
   [PF_SPINNER, "side", "Cut off side (dark (0), bright (1), both(2))", 2, (0,2,1)]
   ],
        [],
        do_the_work,
        menu="<Image>/Image",
        )

_________________
Image


Top
 Post subject: Re: Average layer - help from ofnuts appreciated (if possible)
PostPosted: Wed Jun 18, 2014 12:51 pm  (#5) 
Offline
GimpChat Member
User avatar

Joined: Jan 20, 2013
Posts: 14816
Location: roma, italy
Thanks for your support, Ofnuts.
I pasted your registration lines onto my copy of the plug-in, but still it doesn't show up.
So, there must be something wrong in my python "system", because it's not the first python plug-in which doesn't work in my PC.
Maybe you remember my other posts on DRITool and Selector.
All "normal" python plug-ins work perfectly, some of the oldest which make use of non traditional coding may fail...even after adding required extra routines.
I don't know what to do. Uninstall/Reinstall Python 2.7 ? or something else?

_________________
"Where am I ?"


Top
 Post subject: Re: Average layer - help from ofnuts appreciated (if possible)
PostPosted: Wed Jun 18, 2014 2:23 pm  (#6) 
Offline
GimpChat Member
User avatar

Joined: Jan 20, 2013
Posts: 14816
Location: roma, italy
I made a step forward (I hope so!)
Using the python console, after having loaded the whole plug-in (without errors, as previously) I entered the 3 test command lines provided inside the plug-in:
img=gimp.image_list()[-1]
draw=img.layers[0]
do_the_work(img,draw,"arith",1,1,30,0)

after the call to the main module (do_the_work) I got the following error:
global name 'floor' is not defined
by googling, I got the information that to use floor inside a plug-in there must be an
import math
before
thus, I added this line of code at the beginning of the plug-in
unfortunately, the error persists, which means that floor is not global, so the use of it inside the class Averager is not accepted
how can I make it global? or: may I put the "import math" inside the class Averager instead of putting it as the first line of code?

_________________
"Where am I ?"


Top
 Post subject: Re: Average layer - help from ofnuts appreciated (if possible)
PostPosted: Wed Jun 18, 2014 2:27 pm  (#7) 
Offline
Script Coder
User avatar

Joined: May 07, 2014
Posts: 4041
Location: Canada
try
import math

then math.floor instead of floor.

_________________
TinT


Top
 Post subject: Re: Average layer - help from ofnuts appreciated (if possible)
PostPosted: Wed Jun 18, 2014 2:51 pm  (#8) 
Offline
Script Coder
User avatar

Joined: Oct 25, 2010
Posts: 4757
The plugin has:
from math import floor

at the top (this syntax allows you to use "floor" directly (instead of "math.floor"). In the python-fu console, try:
from math import floor
floor(4.3)


Where did you get the scipy module? Are you positive it's compatible with the Python 2.7 in Gimp and that's not a version for Python 3?

_________________
Image


Top
 Post subject: Re: Average layer - help from ofnuts appreciated (if possible)
PostPosted: Wed Jun 18, 2014 2:55 pm  (#9) 
Offline
GimpChat Member
User avatar

Joined: Jan 20, 2013
Posts: 14816
Location: roma, italy
I downloaded it from the link provided in the Registry
I do not have the "from math import floor"
and now there came out errors concerning scipy
so there must be also an "import scipy" somewhere
could you attach here the version you are running, Ofnuts? thanks a lot

_________________
"Where am I ?"


Top
 Post subject: Re: Average layer - help from ofnuts appreciated (if possible)
PostPosted: Wed Jun 18, 2014 3:06 pm  (#10) 
Offline
GimpChat Member
User avatar

Joined: Jan 20, 2013
Posts: 14816
Location: roma, italy
I see now, I will download directly from Registry
I'll let you know

_________________
"Where am I ?"


Top
 Post subject: Re: Average layer - help from ofnuts appreciated (solved, thanks)
PostPosted: Thu Jun 19, 2014 7:58 am  (#11) 
Offline
GimpChat Member
User avatar

Joined: Jan 20, 2013
Posts: 14816
Location: roma, italy
First of all:
yesterday I wrote a final note saying THANKS to Ofnuts, because the problem was solved, and detailing that i did the following:
1-redownloaded (I don't know what happened during the first download)
2-reapplied the modifications proposed by Ofnuts concerning the registration
3-reapplied the modification proposed on Gimp Registry by PanoWorks concernig median
and the script showed up!
But today I don't see any more that post (?!)

Well, I take this opportunity (of saying again thanks) to illustrate with an example what that plug-in does:
- I took one of my images
- I duplicated the layer 3 times
- on each of the four layers I put an extraneous element (a pepper), in different positions, to simulate what happens to multiple photos having a moving extraneous object (a car, for instance), which has to be removed
- I run the filter
- the pepper is no more there

I attach here the input (in xcf format) and the output (which you can see also without downloading/unzipping)
Seems to be a useful filter in certain circumstances.

Attachment:
input-to-average.7z [309.1 KiB]
Downloaded 71 times


Attachment:
output-from-average.JPG
output-from-average.JPG [ 99.79 KiB | Viewed 1258 times ]


Thanks for the support in installing it and make it running!

_________________
"Where am I ?"


Top
 Post subject: Re: Average layer - help from ofnuts appreciated (solved, thanks)
PostPosted: Thu Jun 19, 2014 8:03 am  (#12) 
Offline
GimpChat Member
User avatar

Joined: Sep 24, 2010
Posts: 12535
Looks like it could be used as a way to get rid of people in a scene so long as they are moving. :)

_________________
Lyle

Psalm 109:8

Image


Top
 Post subject: Re: Average layer - help from ofnuts appreciated (solved, thanks)
PostPosted: Thu Jun 19, 2014 8:08 am  (#13) 
Offline
GimpChat Member
User avatar

Joined: Jan 20, 2013
Posts: 14816
Location: roma, italy
True! I was just saying a passing car, but it could be used for a multi-picture of a city square with passing people (not a hundred, I guess! otherwise you have to take hundreds of photos...) and make it appear empty!

_________________
"Where am I ?"


Top
 Post subject: Re: Average layer - help from ofnuts appreciated (solved, thanks)
PostPosted: Thu Jun 19, 2014 10:25 am  (#14) 
Offline
Script Coder
User avatar

Joined: Oct 25, 2010
Posts: 4757
dinasset wrote:
True! I was just saying a passing car, but it could be used for a multi-picture of a city square with passing people (not a hundred, I guess! otherwise you have to take hundreds of photos...) and make it appear empty!


Why don't you just erase the people in one layer, so that the part without them shows from the layer below... Automating locating the differences between layers and using that to make a selection to punch holes in the appropriate places would give a better result.

Averaging layers has its uses, but mostly to reduce noise.

_________________
Image


Top
 Post subject: Re: Average layer - help from ofnuts appreciated (solved, thanks)
PostPosted: Thu Jun 19, 2014 10:35 am  (#15) 
Offline
GimpChat Member
User avatar

Joined: Jan 20, 2013
Posts: 14816
Location: roma, italy
Yes, but sometimes it's not an easy task; it would have been easy in my example-case, because I put the four peppers each other enough far to remove it one by one, but in case of real photos with people walking or car passing over, there is a lot of overlay on the disturbing objects among the various shots. Anyhow, I don't even know -so far- if in those cases the plug-in works appropriately.
Good point the one about noise reduction; it's something that also high-end cameras perform in their hardware when taking long lasting shots. Having an equivalent tool in software is a nice opportunity. Thanks for recalling this use

_________________
"Where am I ?"


Top
Post new topic Reply to topic  [ 15 posts ] 

All times are UTC - 5 hours [ DST ]


   Similar Topics   Replies 
No new posts Attachment(s) Outline Layer Contents by Ofnuts

2

No new posts Attachment(s) Scripting my head into a wall - Any help would be appreciated

1

No new posts Attachment(s) Get average color of selection

6

No new posts Attachment(s) Made An Animated GIF With An Ofnuts Script

35

No new posts How do I script a new white layer to the bottom of the layer stack

7



* Login  



Powered by phpBB3 © phpBB Group