It is currently Tue May 07, 2024 12:50 pm


All times are UTC - 5 hours [ DST ]



Post new topic Reply to topic  [ 21 posts ]  Go to page 1, 2  Next
Author Message
 Post subject: gimp plugin wavelet denoise
PostPosted: Tue Mar 24, 2015 5:42 am  (#1) 
Offline
GimpChat Member
User avatar

Joined: Jan 20, 2013
Posts: 14816
Location: roma, italy
GIMP Version: 2.8.14
Operating System: Windows
GIMP Experience: Basic Level

List any relevant plug-ins or scripts:
wavelet denoise (M.Rossini)



wavelet denoise (M.Rossini)

I'm a bit curious about the use of this filter in a NON-INTERACTIVE mode, because the procedure browser shows the filter details WITHOUT ANY PARAMETER, while calling it interactively there are many and very interesting options.

Hence my questions:
1-why there is no detailed interface to this plug-in?
2-someone expert on it (Prokoudine?) could possible extend the interface to include the parameters available online? (I don't know the complexity of such a request...)
3-when called inside a script (w/o parameters), which are the defaults applied? (I ask this because some denoising effect is performed on the image)

Thanks

_________________
"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: gimp plugin wavelet denoise
PostPosted: Tue Mar 24, 2015 7:17 am  (#2) 
Offline
Script Coder
User avatar

Joined: Dec 27, 2014
Posts: 508
@Dinasset
I don't think the author ever intended this plug-in to be used non-interactively ..it is really only intended for interactive use ..you load-up a picture, decide you want to reduce the noise level, so you invoke "Wavelet denoise...", play around with the settings until the preview shows something you like, then hit OK or Cancel. That is the nature of the beast.

If you run it non-interactively, it should just use the same values as the last interactive use, the same as doing <Image>Filters>Repeat "Wavelet denoise..." (ie. for this plug-in RUN-NONINTERACTIVE is the same as RUN-WITH-LAST-VALS).

Having said that, if there is a genuine case for using it non-interactively, it should not be too difficult to upgrade - all the denoising parameters are stored in a simple data structure which is stored by Gimp between invocations (using gimp_set_data() and gimp_get_data() ) the same as all other C plug-ins, and it should therefore be a relatively straightforward matter to set those values from user-supplied parameters when called non-interactively.


Top
 Post subject: Re: gimp plugin wavelet denoise
PostPosted: Tue Mar 24, 2015 7:29 am  (#3) 
Offline
GimpChat Founder
User avatar

Joined: May 22, 2008
Posts: 5242
Location: Gimpville
There is a smooth [wavelets] filter in G'MIC that's probably a bit more powerful than the plug-in. Might be an option for you to call non-interactively from a script.

_________________
“If you reach for the stars, you just might land on a decently sized hill.” - Stuart Hill


Top
 Post subject: Re: gimp plugin wavelet denoise
PostPosted: Tue Mar 24, 2015 7:51 am  (#4) 
Offline
GimpChat Member
User avatar

Joined: Jan 20, 2013
Posts: 14816
Location: roma, italy
jontait2 wrote:
@Dinasset
I don't think the author ever intended this plug-in to be used non-interactively ..it is really only intended for interactive use ..you load-up a picture, decide you want to reduce the noise level, so you invoke "Wavelet denoise...", play around with the settings until the preview shows something you like, then hit OK or Cancel. That is the nature of the beast.

If you run it non-interactively, it should just use the same values as the last interactive use, the same as doing <Image>Filters>Repeat "Wavelet denoise..." (ie. for this plug-in RUN-NONINTERACTIVE is the same as RUN-WITH-LAST-VALS).

Having said that, if there is a genuine case for using it non-interactively, it should not be too difficult to upgrade - all the denoising parameters are stored in a simple data structure which is stored by Gimp between invocations (using gimp_set_data() and gimp_get_data() ) the same as all other C plug-ins, and it should therefore be a relatively straightforward matter to set those values from user-supplied parameters when called non-interactively.

thanks, jontait2
do you mean that -in case I want to experiment using that filter in a .scm script- I can make use of "gimp-procedural-db-get-data" and "gimp-procedural-db-set-data"?
But in this case what sequence of data do I retrieve/put?
I don't know the data structure (string) of that filter, also I don't know about C code, I just write my scripts in .scm (sometimes .py)
So, I guess, for a very basic script-writer like me, I have to wait on an enhanced version of that filter...

_________________
"Where am I ?"


Last edited by dinasset on Tue Mar 24, 2015 7:57 am, edited 1 time in total.

Top
 Post subject: Re: gimp plugin wavelet denoise
PostPosted: Tue Mar 24, 2015 7:56 am  (#5) 
Offline
GimpChat Member
User avatar

Joined: Jan 20, 2013
Posts: 14816
Location: roma, italy
GnuTux wrote:
There is a smooth [wavelets] filter in G'MIC that's probably a bit more powerful than the plug-in. Might be an option for you to call non-interactively from a script.

Yes, thanks Gnutux, I know about that G'MIC filter, it's nice.
But I'm always jumping forth and back from gimp to gmic, so I am curious why the author (and/or any susequent maintainer) did not think about a use in a non-interactive way...It's a good gimp filter and if someone wants to write a script which performs many image enhancements and among those a wavelet denoising, why not?

_________________
"Where am I ?"


Top
 Post subject: Re: gimp plugin wavelet denoise
PostPosted: Tue Mar 24, 2015 8:23 am  (#6) 
Offline
Script Coder
User avatar

Joined: Dec 27, 2014
Posts: 508
dinasset wrote:
do you mean that -in case I want to experiment using that filter in a .scm script- I can make use of "gimp-procedural-db-get-data" and "gimp-procedural-db-set-data"?

No!
The gimp_set_data() and gimp_get_data() are libgimp functions used by C plug-ins to store and retrieve data, including run parameters. Nothing to do with PDB data, so you can't use those PDB procedures to access/change the values used by a plug-in.
What I meant was that we could enhance the "Wavelet denoise" plug-in to accept parameters in NONINTERACTIVE mode. But that means amending the source and building for the various platforms (Linux, Windows, etc).

BTW what operating system are you using?


Top
 Post subject: Re: gimp plugin wavelet denoise
PostPosted: Tue Mar 24, 2015 8:55 am  (#7) 
Offline
GimpChat Member
User avatar

Joined: Jan 20, 2013
Posts: 14816
Location: roma, italy
Windows 7 - 32bits

_________________
"Where am I ?"


Top
 Post subject: Re: gimp plugin wavelet denoise
PostPosted: Tue Mar 24, 2015 9:15 am  (#8) 
Offline
Script Coder
User avatar

Joined: Jun 22, 2010
Posts: 1171
Location: Here and there
jontait2 wrote:
No!
The gimp_set_data() and gimp_get_data() are libgimp functions used by C plug-ins to store and retrieve data, including run parameters. Nothing to do with PDB data, so you can't use those PDB procedures to access/change the values used by a plug-in.


I'm going to possibly disagree with you, mostly because you seem to have miss-read what dinnaset wrote: gimp-procedural-db-get-data not gimp_get_data()

This is what gets returned after running wavelet-denoise with default settings:
(gimp-procedural-db-get-data "plug-in-wavelet-denoise")
(136 #( 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 1 0 0 0 1 0 0 0 116 40 219 61 0 0 144 64 55 199 181 62 104 2 0 0 109 1 0 0 0 0 0 0 ))

All you have to do is decode all 136 numbers into the values passed in :!:

I've been experimenting with the Refocus plug-in (less parameters) and I can change the last remembered values using gimp-procedural-db-set-data

I have yet to work out the encoding.

I do however agree that the best option is to modify wavelet-denoise so that it can be run interactively, although I question whether it's sensible to run interactively as that implies batch processing and noise reduction is very subjective and "best" settings will vary between images.

Kevin


Last edited by paynekj on Tue Mar 24, 2015 9:16 am, edited 1 time in total.

Top
 Post subject: Re: gimp plugin wavelet denoise
PostPosted: Tue Mar 24, 2015 9:16 am  (#9) 
Offline
GimpChat Founder
User avatar

Joined: May 22, 2008
Posts: 5242
Location: Gimpville
dinasset wrote:
Yes, thanks Gnutux, I know about that G'MIC filter, it's nice.

Here is a script to call G'MIC's Smoothing [wavelets] non-interactively. I've included the first 3 parameters in a script-fu dialog for demonstration purposes. Maybe you will find this useful.

;
;gmic_wavelets.scm
;
; License: GPLv3 (c) Copyright 2013
;    This program is free software: you can redistribute it and/or modify
;    it under the terms of the GNU General Public License as published by
;    the Free Software Foundation, either version 3 of the License, or
;    (at your option) any later version.
;
;    This program is distributed in the hope that it will be useful,
;    but WITHOUT ANY WARRANTY; without even the implied warranty of
;    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
;    GNU General Public License for more details.
;
;    To view a copy of the GNU General Public License
;    visit: http://www.gnu.org/licenses/gpl.html
;
(define (gmic-wavelets img drawable threshold iterations scales)

  ; Start undo group
  (gimp-image-undo-group-start img)

  (let* (
         (copy-layer (car (gimp-layer-copy drawable TRUE)))
         )

   ; Add copy of layer to image
    (gimp-image-add-layer img copy-layer -1)

   ; Call GMIC
    (plug-in-gmic
                        1 ; Mode: interacive=0, non-interactive=1
                      img ; Input Image
                 drawable ; Inout Drawable (not used)
                        1 ; Input layers when using non-interactive (see below)
                          ; 0=none, 1=active, 2=all, 3=active & below
                          ; 4=active & above, 5=all visibles, 6=all invisibles
                          ; 7=all visibles (decr.), 8=all invisibles (decr.), 9=all (decr.)

          ; Build GMIC Command String (Run GIMP from terminal set GMIC to verbose to see command string)
                   (string-append
                   "-v - "                  ;  Required to work properly in Script-fu 
                   "-gimp_haar_smoothing "  ;  GMIC Filter name
            (number->string threshold) ","  ;  1 = Threshold
           (number->string iterations) ","  ; 10 = Iterations
               (number->string scales) ","  ; 10 = Scales
                                      "0,"  ;  0 = Channesl
                                      "0,"  ;  0 = Parallel Processing
                                     "24,"  ; 24 = Spacial Overlap
                                       "0"  ;  0 = Preview Type
                   )
    );end GMIC call
  )

  ; Flush display
  (gimp-displays-flush)

  ; End undo group
  (gimp-image-undo-group-end img)
  )

(script-fu-register "gmic-wavelets"
                    _"<Image>/Filters/G'MIC Wavelets..."
                    "Show how to call G'MIC Wavelets from a script"
                    ""
                    ""
                    ""
                    "*"
                    SF-IMAGE         "Image"        0
                    SF-DRAWABLE      "Drawable"     0
                    SF-ADJUSTMENT   _"Threshold"   '(1.00 0.00 10.00 .1 1.0 2 0)
                    SF-ADJUSTMENT   _"Iteration"   '(10 1 32  1 2 0 0)
                    SF-ADJUSTMENT   _"Scales"      '(10 2 10  1 2 0 0)
                    )

_________________
“If you reach for the stars, you just might land on a decently sized hill.” - Stuart Hill


Top
 Post subject: Re: gimp plugin wavelet denoise
PostPosted: Tue Mar 24, 2015 9:20 am  (#10) 
Offline
GimpChat Member
User avatar

Joined: Jan 20, 2013
Posts: 14816
Location: roma, italy
thanks Kevin
should I be one day enough relaxed to "understand" all that bulk of numbers and try to modify the string using the "set", I'll post here my tests

_________________
"Where am I ?"


Top
 Post subject: Re: gimp plugin wavelet denoise
PostPosted: Tue Mar 24, 2015 9:22 am  (#11) 
Offline
GimpChat Member
User avatar

Joined: Jan 20, 2013
Posts: 14816
Location: roma, italy
Thanks Gnutux for your input.
I wrote already a script using G'MIC wavelet, it works fine.
As I said I was willing to try Gimp...

_________________
"Where am I ?"


Top
 Post subject: Re: gimp plugin wavelet denoise
PostPosted: Tue Mar 24, 2015 9:26 am  (#12) 
Offline
GimpChat Founder
User avatar

Joined: May 22, 2008
Posts: 5242
Location: Gimpville
Oh, OK. Sorry, I misunderstood. I just thought you needed to run a wavelet filter non-interactively from a script and G'MIC seemed like a good option, since it's already there. Never like to re-invent the wheel. :hehe

_________________
“If you reach for the stars, you just might land on a decently sized hill.” - Stuart Hill


Top
 Post subject: Re: gimp plugin wavelet denoise
PostPosted: Tue Mar 24, 2015 9:55 am  (#13) 
Offline
GimpChat Member
User avatar

Joined: Jan 20, 2013
Posts: 14816
Location: roma, italy
I appreciate your help, Gnutux! Don't be sorry, I didn't say before I wrote already using G'MIC, I only said I knew it; that's the origin of the misunderstanding.
I'm still working on that Gimp-G'MIC filter, because denoising is just part of my goal: enhancing a photo under various aspects (I'm normally lazy, but also ambitious from time to time...hehehe!).
The whole thing will take long...

_________________
"Where am I ?"


Top
 Post subject: Re: gimp plugin wavelet denoise
PostPosted: Wed Mar 25, 2015 4:19 am  (#14) 
Offline
GimpChat Member
User avatar

Joined: Jan 20, 2013
Posts: 14816
Location: roma, italy
dinasset wrote:
thanks Kevin
should I be one day enough relaxed to "understand" all that bulk of numbers and try to modify the string using the "set", I'll post here my tests

Kevin, this morning a made a little test:
1-run the filter setting threshold to 10 and softness to 1
2-entered into the script-fu console the command
(gimp-procedural-db-get-data "plug-in-wavelet-denoise")
3-stored the output into a text file
4-run again the filter setting threshold to 5 and softness to 0.5
5-entered again the command into the console
6-appended the output into the previous text file
7-compared the two outputs

I hoped to find just two differences, related to the two parameters changed.
No, the differences are a lot, and the input values are not recognizable, at least for me

these are the data:
Script-Fu Console
statement entered (gimp-procedural-db-get-data "plug-in-wavelet-denoise") (as per Kevin)

output after input: threshold 10 and softness 1
-----------------------------------------------
(136 #(0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
36 <==== different
64 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
0 0 0 0 0 0 240 <==== different
63 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 1 0 0 0 1 0 0 0
113 5 172 <==== different
60
123 <==== different
164 155 60
2 7 44 <==== different
61 178 2 0 0 122 1 0 0 0 0 0 0))

§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§

output after input: threshold 5 and softness 0.5
------------------------------------------------

(136 #(0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 1 0 0 0 0 0
20 <==== different
64 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
248 255 255 255 255 255 223 <==== different
63 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 1 0 0 0 1 0 0 0
78 58 180 <==== different
60
49 <==== different
164 155 60
129 121 105 <==== different
61 178 2 0 0 122 1 0 0 0 0 0 0))

§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§


hence I will certainly not continue on this way
should some expert modify the code of the plug-in so that it can be called non-interactively with the same parameters available online, well
otherwise I will stay with my G'MIC wavelet denoise filter

_________________
"Where am I ?"


Top
 Post subject: Re: gimp plugin wavelet denoise
PostPosted: Wed Mar 25, 2015 4:50 am  (#15) 
Offline
Script Coder
User avatar

Joined: Jun 22, 2010
Posts: 1171
Location: Here and there
dinasset:

My experimenting yesterday leads me to the conclusion that the float values are being stored as double precision binary floats:- which are 8 bytes each.

For plug-in-refocus:
(40 #( 5 0 0 0 0 0 0 0   0 0 0 0 0 0 164 60  0 0 0 0 0 0 0 0  0 0 0 0 0 0 224 63  123 20 174 71 225 122 132 63 ))
Matrix (integer)=5 (5 0 0 0 0 0 0 0)
Radius (float)=0.0 (0 0 0 0 0 0 164 60)
Gauss (float)=0.0 (0 0 0 0 0 0 0 0)
Correlation (float)=0.5 (0 0 0 0 0 0 224 63)
Noise (float)=0.01 (123 20 174 71 225 122 132 63)


See: http://www.binaryconvert.com/convert_double.html

Kevin


Top
 Post subject: Re: gimp plugin wavelet denoise
PostPosted: Wed Mar 25, 2015 6:19 am  (#16) 
Offline
GimpChat Member
User avatar

Joined: Jan 20, 2013
Posts: 14816
Location: roma, italy
thanks Kevin
this important info could lead me to do some other experiment...

_________________
"Where am I ?"


Top
 Post subject: Re: gimp plugin wavelet denoise
PostPosted: Wed Mar 25, 2015 6:49 am  (#17) 
Offline
Script Coder
User avatar

Joined: Dec 27, 2014
Posts: 508
@Dinasset
The data stored by "plug-in-wavelet-denoise" is defined thus:
typedef struct
{
  double gray_thresholds[2];
  double gray_low[2];
  double colour_thresholds[4];
  double colour_low[4];
  guint colour_mode;
  gint preview_channel;
  gboolean preview_mode;
  gboolean preview;
  float times[3];
  gint winxsize, winysize;
} wavelet_settings;

So the data you retrieved with your second use of (gimp-procedural-db-get-data "plug-in-wavelet-denoise") corresponds like this:
0 0 0 0 0 0 0 0       gray_thresholds[0]
0 0 0 0 0 0 0 0         gray_thresholds[1]
0 0 0 0 0 0 0 0       gray_low[0]
0 0 0 0 0 0 0 0         gray_low[1]
1 0 0 0 0 0 0 20 64       colour_thresholds[0]
0 0 0 0 0 0 0 0        colour_thresholds[1]
0 0 0 0 0 0 0 0        colour_thresholds[2]
0 0 0 0 0 0 0 0       colour_thresholds[3]
248 255 255 255 255 255 223 63    colour_low[0]
0 0 0 0 0 0 0 0          colour_low[1]
0 0 0 0 0 0 0 0       colour_low[2]
0 0 0 0 0 0 0 0       colour_low[3]
0 0 0 0          colour_mode (0=YCBCR, 1=RGB, 2=LAB)
0 0 0 0            
1 0 0 0          
1 0 0 0            
78 58 180 60
49 164 155 60
129 121 105 61
178 2 0 0
122 1 0 0
0 0 0 0

The gray_threshold[] and gray_low[] values are for GRAY images and only the first value is actually used at present (as far as I can see).
The colour_threshold [] and colour_low[] values correspond to the colour channels shown in the dialog and are therefore dependent upon the colour_mode.
Note: the "low" values correspond to the "Softness" setting in the dialog.

So you can use (gimp-procedural-db-get-data ) to set the parameters if you want to, but this is a pretty obtuse way of doing it. You will still have to convert float values to bytes.

If you want to do it the "proper" way, here is a hacked version of the plugin source which accepts parameters in
NONINTERACTIVE mode:
Attachment:
wavelet-denoise-0.3.1-jthack.zip [103.96 KiB]
Downloaded 194 times
You can see the parameters listed in the Procedure Browser.

I've run this on Linux and it seems to work okay, but I cannot build it for Windows at the moment (my MINGW environment is broken ..must sort it out).
Perhaps somebody else (eg. Rod or Graechan) can build it for Windows 32bit.

Like Kevin, I'm still doubtful of the merits of trying to use this filter non-interactively.
Sounds a bit like .. http://xkcd.com/1503/


Top
 Post subject: Re: gimp plugin wavelet denoise
PostPosted: Wed Mar 25, 2015 7:19 am  (#18) 
Offline
GimpChat Member
User avatar

Joined: Jan 20, 2013
Posts: 14816
Location: roma, italy
many thanks jontait2, both for the info (which I can try to use...) and for the revised filter (for which I need to wait an .exe compiled for win 32)

let me say, I don't understand why this filter shouldn't be used in a script, if it is because you think the user should see interactively how the parameters changes act on the image, that's something true for the majority of the filters
(note that the equivalent G'MIC filter can be used inside a script)

_________________
"Where am I ?"


Top
 Post subject: Re: gimp plugin wavelet denoise
PostPosted: Wed Mar 25, 2015 7:25 am  (#19) 
Offline
Script Coder
User avatar

Joined: Dec 27, 2014
Posts: 508
No, the point is that, for any given image, you really only get the best results thru judging by eye the best settings for each color channel .. and there are considerable differences between images.
So, unless you have lots of images with exactly the same contrast/levels/exposure/color settings/etc it's difficult to see how using this filter non-interactively is going to produce useful results.


Top
 Post subject: Re: gimp plugin wavelet denoise
PostPosted: Wed Mar 25, 2015 7:37 am  (#20) 
Offline
GimpChat Member
User avatar

Joined: Jan 20, 2013
Posts: 14816
Location: roma, italy
correct, but you have the same difficulty with a lot of many other filters manipulating the "appearance" of the pixels in the image...
a reasonable script should define the parameters at a much higher level, for the common user, for instance:
- requested intensity of the denoising action: low, moderate, high...
and the filter should be able to translate into internal values which can reasonably provide an average good (=as expected) result for an amateur
then, the interactive filter is always there for the real photographers

_________________
"Where am I ?"


Top
Post new topic Reply to topic  [ 21 posts ]  Go to page 1, 2  Next

All times are UTC - 5 hours [ DST ]


   Similar Topics   Replies 
No new posts Attachment(s) Baby's first GEGL plugin - a very basic GEGL plugin anyone can make.

9

No new posts Can't get plugin to appear (mostly)

3

No new posts Attachment(s) Plugin superxBR

7

No new posts Attachment(s) eps plugin crashes

4

No new posts Attachment(s) Help! What's the plugin called?

7



* Login  



Powered by phpBB3 © phpBB Group