It is currently Wed Jul 03, 2024 1:23 pm


All times are UTC - 5 hours [ DST ]



Post new topic Reply to topic  [ 58 posts ]  Go to page Previous  1, 2, 3  Next
Author Message
 Post subject: Re: Gluas
PostPosted: Mon May 30, 2011 10:41 pm  (#21) 
Offline
GimpChat Member
User avatar

Joined: Jan 13, 2011
Posts: 2260
Location: Poland
Maybe for Ubuntu, well worth a try version 0.1.19 ?
http://pippin.gimp.org/plug-ins/gluas/files/

_________________
Image

Slava
Ukraini!


Top
 Post subject: Re: Gluas
PostPosted: Mon May 30, 2011 10:47 pm  (#22) 
Offline
Global Moderator
User avatar

Joined: Oct 06, 2010
Posts: 4050
I have those. I noticed the Japanese site had a couple that gimp-gluas doesn't have.

_________________
"In order to attain the impossible, one must attempt the absurd."
~ Miguel de Cervantes


Top
 Post subject: Re: Gluas
PostPosted: Tue May 31, 2011 4:03 am  (#23) 
Offline
GimpChat Member
User avatar

Joined: May 16, 2010
Posts: 14709
Location: USA
Night Vision :)

Image

_________________
Image
Edmund Burke nailed it when he said, "The only thing necessary for the triumph of evil is for good men to do nothing."


Top
 Post subject: Re: Gluas
PostPosted: Tue May 31, 2011 4:09 am  (#24) 
Offline
GimpChat Member
User avatar

Joined: May 16, 2010
Posts: 14709
Location: USA
Here is the Kuwahara filter with curves after ward set to a cone line.
Pretty cool grunge effect Lyle. :)

Image

_________________
Image
Edmund Burke nailed it when he said, "The only thing necessary for the triumph of evil is for good men to do nothing."


Top
 Post subject: Re: Gluas
PostPosted: Tue May 31, 2011 5:57 am  (#25) 
Offline
GimpChat Member

Joined: Apr 12, 2010
Posts: 5870
Fix the dogwaflle scripts should not be hard , replace the "dog" calls with a equivalent "gimp" call should fix, but i wonder if is worth the effort

may be more interesting port script as Kuwahara to gmic or mathmap (the language seems a bit more similar to MM ) that for sure may support it.

just in case somebody interested here the code


Kuwahara filter
-- origine : http://pippin.gimp.org/image_processing/chap_area.html#example_kuwahara


-- Kuwahara filter
--
--
-- Performs the Kuwahara Filter. This filter is an edge-preserving filter.
--
--
-- ( a  a  ab   b  b)
-- ( a  a  ab   b  b)
-- (ac ac abcd bd bd)
-- ( c  c  cd   d  d)
-- ( c  c  cd   d  d)
--
-- In each of the four regions (a, b, c, d), the mean brightness and the variance are calculated. The
-- output value of the center pixel (abcd) in the window is the mean value of that region that has the
-- smallest variance.
--
-- description copied from http://www.incx.nec.co.jp/imap-vision/library/wouter/kuwahara.html
--
-- implemented by Øyvind Kolås <oeyvindk@hig.no> 2004


-- the sampling window is:  width=size*2+1  height=size*2+1

size = 4

edge_duplicate = 1;

-- local function to get the mean value, and
-- variance from the rectangular area specified
function mean_and_variance (x0,y0,x1,y1)
local variance
local mean

local min         = 1.0
local max         = 0.0
local accumulated = 0
local count       = 0
   
local x, y

for y=y0,y1 do
   for x=x0,x1 do
     local v = get_value(x,y)

     accumulated   = accumulated + v
     count         = count + 1
     
     if v<min then min = v end
     if v>max then max = v end

    end
  end

  variance = max-min
  mean     = accumulated /count
   
  return mean, variance
end

-- local function to get the mean value, and
-- variance from the rectangular area specified
function rgb_mean_and_variance (x0,y0,x1,y1)
local variance
local mean
local r_mean
local g_mean
local b_mean

local min           = 1.0
local max           = 0.0
local accumulated_r = 0
local accumulated_g = 0
local accumulated_b = 0
local count         = 0
   
local x, y

for y=y0,y1 do
   for x=x0,x1 do
     local v     = get_value(x,y)
     local r,g,b = get_rgb (x,y)

     accumulated_r   = accumulated_r + r
     accumulated_g   = accumulated_g + g
     accumulated_b   = accumulated_b + b
     count         = count + 1
     
     if v<min then min = v end
     if v>max then max = v end

    end
  end

  variance = max-min
  mean_r   = accumulated_r /count
  mean_g   = accumulated_g /count
  mean_b   = accumulated_b /count
   
  return mean_r, mean_g, mean_b, variance
end

-- return the kuwahara computed value
function kuwahara(x, y, size)
  local best_mean     = 1.0
  local best_variance = 1.0

  local mean, variance
   
  mean, variance = mean_and_variance (x-size, y-size, x, y)   

  if variance < best_variance then
    best_mean     = mean
    best_variance = variance
  end
   
  mean, variance = mean_and_variance (x, y-size, x+size,y)

  if variance < best_variance then
    best_mean     = mean
    best_variance = variance
  end   
   
  mean, variance = mean_and_variance (x, y, x+size, y+size)

  if variance < best_variance then
    best_mean     = mean
    best_variance = variance
  end   
   
  mean, variance = mean_and_variance (x-size, y, x,y+size)

  if variance < best_variance then
    best_mean     = mean
    best_variance = variance
  end   

  return best_mean
end


-- return the kuwahara computed value
function rgb_kuwahara(x, y, size)
  local best_r, best_g, best_b
  local best_variance = 1.0

  local r,g,b, variance
   
  r,g,b, variance = rgb_mean_and_variance (x-size, y-size, x, y)   

  if variance < best_variance then
    best_r, best_g, best_b = r, g, b
   
    best_variance = variance
  end
   
  r,g,b, variance = rgb_mean_and_variance (x, y-size, x+size,y)

  if variance < best_variance then
    best_r, best_g, best_b = r, g, b
    best_variance = variance
  end   
   
  r,g,b, variance = rgb_mean_and_variance (x, y, x+size, y+size)

  if variance < best_variance then
    best_r, best_g, best_b = r, g, b
    best_variance = variance
  end   
   
  r,g,b, variance = rgb_mean_and_variance (x-size, y, x,y+size)

  if variance < best_variance then
    best_r, best_g, best_b = r, g, b
    best_variance = variance
  end   

  return best_r, best_g, best_b
end

function kuwahara(radius)
  for y=0, height-1 do
    for x=0, width-1 do
      r,g,b = rgb_kuwahara (x,y, radius)
      set_rgb (x,y, r,g,b)
    end
    progress (y/height)
  end
end

kuwahara(2)

_________________
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: Gluas
PostPosted: Tue May 31, 2011 6:05 am  (#26) 
Offline
GimpChat Member
User avatar

Joined: Jan 03, 2011
Posts: 1656
Is there any code visible for the Kuwahara effect ? I think this could be done in G'MIC ;)


Top
 Post subject: Re: Gluas
PostPosted: Tue May 31, 2011 6:06 am  (#27) 
Offline
Global Moderator
User avatar

Joined: Oct 06, 2010
Posts: 4050
It's hiding behind PC's spoiler

_________________
"In order to attain the impossible, one must attempt the absurd."
~ Miguel de Cervantes


Top
 Post subject: Re: Gluas
PostPosted: Tue May 31, 2011 6:08 am  (#28) 
Offline
GimpChat Member

Joined: Apr 12, 2010
Posts: 5870
David maybe the original C script (well look as C to me , but i may be wrong) is easier to port.
The Lua filter was derieved by this


here #include <stddef.h>
#include <imapio.h>
#include <stdimap.h>

/*-----------------------------------------------------------------
Kuwahara Filter

12/01/99
filename: kuwahara.lc
author : W.J.Bokhove
----------------------------------------------------------------*/

/*
M_DOCDEF kuwahara

NAME kuwahara

SYNOPSIS
void kuwahara(src, dst, lines)
sep uchar src[]; /* source image */ /*
sep uchar dst[]; /* destination image */ /*
uint lines; /* number of lines to work on */ /*

MEMORY CONSUMPTION
This function consumes about 22 lines of IMAP memory

DESCRIPTION
Performs the Kuwahara Filter. This filter is an edge-preserving filter.
( a a ab b b)
( a a ab b b)
(ac ac abcd bd bd)
( c c cd d d)
( c c cd d d)
In each of the four regions (a, b, c, d), the mean brightness and the
variance are calculated. The output value of the center pixel (abcd) in
the window is the mean value of that region that has the smallest variance.

M_DOCEND
*/


void kuwahara(sep uchar src[], sep uchar dst[], uint lines)
{
#define square(a) (a*a)
int i;
sep ulong dif;
sep uint dtmp1, dtmp2, dtmp3, dtmp4, acc;
sep uchar var[3], mean[3], vartmp, meantmp;

dst[0] = 0;
dst[1] = 0;
/* Calculate Variance and Mean of first 2 lines */
dtmp2 = square((src[0] - :>src[1]));
dtmp3 = square((src[0] - src[1]));
dtmp4 = square((src[0] - :<src[1]));
dif = :<dtmp2 + dtmp3 + :>dtmp4;
dtmp1 = square((src[1] - :>src[1]));
dif += dtmp1;
dif += :<dtmp1;
dtmp2 = square((src[1] - :>src[2]));
dif += dtmp2;
dtmp3 = square((src[1] - src[2]));
dif += dtmp3;
dtmp4 = square((src[1] - :<src[2]));
dif += dtmp4;
var[1] = dif;
dif = :<dtmp2 + dtmp3 + :>dtmp4;
dtmp1 = square((src[2] - :>src[2]));
dif += dtmp1;
dif += :<dtmp1;
dtmp2 = square((src[2] - :>src[3]));
dif += dtmp2;
dtmp3 = square((src[2] - src[3]));
dif += dtmp3;
dtmp4 = square((src[2] - :<src[3]));
dif += dtmp4;
var[2] = dif;
acc = src[0] + src[1] + src[2];
acc += (:<acc + :>acc);
mean[1] = acc / 9;
acc = src[2] + src[2] + src[3];
acc += (:<acc + :>acc);
mean[2] = acc / 9;

for (i=3 ; i<lines-1; i++ ) {
/* Calculate Variance */
dif = :<dtmp2 + dtmp3 + :>dtmp4;
dtmp1 = square((src[i] - :>src[i]));
dif += dtmp1;
dif += :<dtmp1;
dtmp2 = square((src[i] - :>src[i+1]));
dif += dtmp2;
dtmp3 = square((src[i] - src[i+1]));
dif += dtmp3;
dtmp4 = square((src[i] - :<src[i+1]));
dif += dtmp4;
var[3]= sqrtsepi(dif>>3);
/* Calculate Mean */
acc = src[i-1] + src[i] + src[i+1];
acc += (:<acc + :>acc);
mean[3] = acc / 9;
/* Find minimum variance and its mean */
vartmp = :>var[1];
meantmp = :>mean[1];
mif (:<var[1] < vartmp) {meantmp = :<mean[1]; vartmp = :<var[1];}
mif (:>var[3] < vartmp) {meantmp = :>mean[3]; vartmp = :>var[3];}
mif (:<var[3] < vartmp) meantmp = :<mean[3];
dst[i-1] = meantmp;
var[1] = var[2]; mean[1] = mean[2];
var[2] = var[3]; mean[2] = mean[3];
}
dst[lines-2] = 0;
dst[lines-1] = 0;

From http://web.archive.org/web/200803130937 ... uwahara.lc

_________________
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: Gluas
PostPosted: Tue May 31, 2011 8:27 am  (#29) 
Offline
GimpChat Member
User avatar

Joined: Jan 03, 2011
Posts: 1656
Ok, Thanks for the pointers. I've recoded it from scratch in G'MIC, it is quite short to perform in this beautiful language :)

#@gmic kuwahara : size>0
#@gmic : Apply Kuwahara filter of specified size on selected images.
#@gmic : $ image.jpg --kuwahara 5
kuwahara : -check $1>0
-e[^-1] "Apply Kuwahara filter of size $1 on image$?."
-v - -to_rgb -repeat @#
--dilate[0] $1 --erode[0] $1 -compose_channels[-1] min -compose_channels[-2] max --[-2,-1]
$1,1,1,1,{1/$1} -convolve[0] [-1] -transpose[-1] -convolve[0] [-1] -rm[-1]
-a[-2,-1] c
-f "v1=i(x-1,y-1,0,3,1); \
v2=i(x+1,y+1,0,3,1); \
v3=i(x-1,y+1,0,3,1); \
v4=i(x+1,y+1,0,3,1); \
vm=min(v1,v2,v3,v4); \
if(c>=3,i, \
if(vm==v1,i(x-1,y-1,0,c,1),
if(vm==v2,i(x+1,y-1,0,c,1),
if(vm==v3,i(x-1,y+1,0,c,1),
i(x+1,y+1,0,c,1)))))"
-channels[-1] 0,2
-mv[-1] 0 -done -v +

#@gimp Kuwahara filtering : gimp_kuwahara, gimp_kuwahara_preview(0)
#@gimp : Radius = int(3,1,30)
#@gimp : Channel(s) = choice("All","RGBA","RGB","Luminance","Blue/red chrominances","Blue chrominance","Red chrominance","Lightness","ab-components","a-component","b-component","Hue","Saturation","Value","Key","Alpha","ch-components","c-component","h-component")
#@gimp : sep = separator(), Preview type = choice("Full","Forward horizontal","Forward vertical","Backward horizontal","Backward vertical")
#@gimp : sep = separator(), note = note("<small>Author : <i>David Tschumperl&#233;</i>. Latest update : <i>2011/05/31</i>.</small>")
gimp_kuwahara :
-apply_channels "-kuwahara $1",$2,0

gimp_kuwahara_preview :
-gimp_split_preview "-gimp_kuwahara ${1--2}",$-1


I got this :

Image

Should be already available after filter update.


Top
 Post subject: Re: Gluas
PostPosted: Tue May 31, 2011 8:39 am  (#30) 
Offline
GimpChat Member

Joined: Apr 12, 2010
Posts: 5870
thank David

I am wrong or the original filter was basically equivalent to a Convolution Matrix preset ?
Something as the many presets (erode ,dilate,highpass,etc) that may be created by
http://docs.gimp.org/2.6/en/plug-in-convmatrix.html ?

_________________
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: Gluas
PostPosted: Tue May 31, 2011 8:41 am  (#31) 
Offline
GimpChat Member
User avatar

Joined: Sep 24, 2010
Posts: 12531
I agree; I think all the Gluas presets can be done (and better) in G'MIC if you know how to code. Gluas is quite old; want to say I vaguely remembered it in the old GIMP 1.2.x days. G'MIC is new and it's like comparing a corvette with a volkswagon beetle. lol

And PC Ninja'ed me. lol

:)

_________________
Lyle

Psalm 109:8

Image


Top
 Post subject: Re: Gluas
PostPosted: Tue May 31, 2011 8:47 am  (#32) 
Offline
GimpChat Member
User avatar

Joined: Jan 03, 2011
Posts: 1656
@PhotoComiX : not it is quite different than applying a convolution filter. In fact, this is quite a strange process, I really doubt it can be useful for image denoising for instance. but who knows...


Top
 Post subject: Re: Gluas
PostPosted: Tue May 31, 2011 8:54 am  (#33) 
Offline
GimpChat Member
User avatar

Joined: Sep 24, 2010
Posts: 12531
Hey David. Not sure what Kuwahara in Glaus is actually doing. It's almost like a combination of noise spread followed by and adaptive erosion or dilation depending on the value of the bits. Just not sure. Just tried out your new preset and it's not quite the same but cool none the less. What I find really cool with Kuwahara is to do the following. Dup, run the Glaus Kuwahara and then set that result to Grain Extract and copy visible. Delete the Glaus Kuwahar layer and then set the result layer to Grain Merge. Makes for a hyper sharpening effect. :)

_________________
Lyle

Psalm 109:8

Image


Top
 Post subject: Re: Gluas
PostPosted: Tue May 31, 2011 9:56 am  (#34) 
Offline
GimpChat Member
User avatar

Joined: Sep 24, 2010
Posts: 12531
Just found out that 0.1.20 doesn't run Decimation preset; bummer. Went back to 0.1.19 and all's well. Not sure what changes in 0.1.20 caused this preset to not work. Oh well. Like Decimation, so guess I'm sticking with 0.1.19 for now. :)

_________________
Lyle

Psalm 109:8

Image


Top
 Post subject: Re: Gluas
PostPosted: Tue May 31, 2011 10:49 am  (#35) 
Offline
GimpChat Member
User avatar

Joined: May 16, 2010
Posts: 14709
Location: USA
Yeah Glaus 01.19 seems to run most of them.
I agree GMIC could handle these way better and probably with cleaner code.
Thanks David for the new filter by the way. :)

_________________
Image
Edmund Burke nailed it when he said, "The only thing necessary for the triumph of evil is for good men to do nothing."


Top
 Post subject: Re: Gluas
PostPosted: Tue May 31, 2011 11:26 am  (#36) 
Offline
GimpChat Member
User avatar

Joined: Jan 03, 2011
Posts: 1656
I've just done a small correction, there was a bug in my code, sorry.
Now, this looks a little better.


Top
 Post subject: Re: Gluas
PostPosted: Tue May 31, 2011 11:31 am  (#37) 
Offline
Retired Staff
User avatar

Joined: May 22, 2008
Posts: 6947
Location: Somewhere in GIMP
Where is it? Is it something I need to put into my .gmic file?

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


Top
 Post subject: Re: Gluas
PostPosted: Tue May 31, 2011 11:33 am  (#38) 
Offline
GimpChat Member
User avatar

Joined: Jan 03, 2011
Posts: 1656
No, basically you should only click the 'Update filters' button, while the 'Internet' button is set.
You need also G'MIC >= 1.4.9.2.
The filter is located in folder 'Enhancement/Kuwahara filtering'.


Top
 Post subject: Re: Gluas
PostPosted: Tue May 31, 2011 11:36 am  (#39) 
Offline
Retired Staff
User avatar

Joined: May 22, 2008
Posts: 6947
Location: Somewhere in GIMP
Thanks! Found it.

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


Top
 Post subject: Re: Gluas
PostPosted: Tue May 31, 2011 11:40 am  (#40) 
Offline
GimpChat Member
User avatar

Joined: May 16, 2010
Posts: 14709
Location: USA
Looks great David! :)
Image

_________________
Image
Edmund Burke nailed it when he said, "The only thing necessary for the triumph of evil is for good men to do nothing."


Top
Post new topic Reply to topic  [ 58 posts ]  Go to page Previous  1, 2, 3  Next

All times are UTC - 5 hours [ DST ]



* Login  



Powered by phpBB3 © phpBB Group