Commit ea0e9231 authored by Marc Lehmann's avatar Marc Lehmann
Browse files

see plug-ins/perl/Changes

parent 2ef8ec29
Revision history for Gimp-Perl extension.
- region functions (except data) wrongly returned transposed matrices.
Now the order of dimensions is bpp <- width <- height.
- implemented and added examples/gouge.
1.098 Wed Jul 21 20:57:12 CEST 1999
- do not try to compile gimp_personal_rc_file without gimp-1.1.
- fixed old prefix detection.
......
......@@ -39,7 +39,7 @@ sub import {
my $pkg = shift;
my $feature;
local $Gimp::in_query=($ARGV[0] eq "-gimp");
local $Gimp::in_query=(@ARGV and $ARGV[0] eq "-gimp");
while(defined (my $feature = shift)) {
$feature=~s/^://;
need($feature);
......
......@@ -1846,7 +1846,7 @@ gimp_pixel_rgn_get_row(pr, x, y, width)
int y
int width
CODE:
RETVAL = new_pdl (width, 0, pr->bpp);
RETVAL = new_pdl (0, width, pr->bpp);
gimp_pixel_rgn_get_row (pr, RETVAL->data, x, y, width);
OUTPUT:
RETVAL
......@@ -1858,7 +1858,7 @@ gimp_pixel_rgn_get_col(pr, x, y, height)
int y
int height
CODE:
RETVAL = new_pdl (0, height, pr->bpp);
RETVAL = new_pdl (height, 0, pr->bpp);
gimp_pixel_rgn_get_col (pr, RETVAL->data, x, y, height);
OUTPUT:
RETVAL
......@@ -1871,7 +1871,7 @@ gimp_pixel_rgn_get_rect(pr, x, y, width, height)
int width
int height
CODE:
RETVAL = new_pdl (width, height, pr->bpp);
RETVAL = new_pdl (height, width, pr->bpp);
gimp_pixel_rgn_get_rect (pr, RETVAL->data, x, y, width, height);
OUTPUT:
RETVAL
......@@ -1914,7 +1914,7 @@ gimp_pixel_rgn_set_rect(pr, pdl, x, y)
int y
CODE:
old_pdl (&pdl, 2, pr->bpp);
gimp_pixel_rgn_set_rect (pr, pdl->data, x, y, pdl->dims[pdl->ndims-1], pdl->dims[pdl->ndims-2]);
gimp_pixel_rgn_set_rect (pr, pdl->data, x, y, pdl->dims[pdl->ndims-2], pdl->dims[pdl->ndims-1]);
pdl *
gimp_pixel_rgn_data(pr,newdata=0)
......
......@@ -104,4 +104,5 @@ embedxpm
logo.xpm
examples/frame_reshuffle
examples/frame_filter
examples/gouge
......@@ -8,7 +8,7 @@ $|=1;
# not yet: magick
qw(windy.pl prep4gif.pl webify.pl PDB alpha2color.pl tex-to-float ditherize.pl
border.pl view3d.pl feedback.pl xachlego.pl xachshadow.pl parasite-editor
scratches.pl blowinout.pl terral_text xachvision.pl perlcc
scratches.pl blowinout.pl terral_text xachvision.pl perlcc gouge
sethspin.pl animate_cells image_tile yinyang stamps font_table
perlotine randomblends innerbevel fit-text guidegrid roundrectsel
repdup centerguide stampify goldenmean triangle billboard mirrorsplit
......
#!/usr/bin/perl
# implements some algorithms described in
# http://www.biocomputer.com/Thesis.html
use Gimp::Feature 'pdl';
use Gimp 1.098;
use Gimp::Fu;
use Gimp::Util;
use PDL::LiteF;
register "gouge_smooth",
"smooth (low pass filter) an image using the gouge algorithm",
"Low-Pass filtering (smoothing) using a fast algorithm found in a paper by James O. Gouge.",
"Marc Lehmann",
"Marc Lehmann <pcg\@goof.com>",
"19990723",
"<Image>/Filters/Blur/Gouge",
"RGB*, GRAY*",
[],
sub {
my($image,$drawable)=@_;
Gimp->progress_init ("Gouge smoothing...");
my @bounds = $drawable->mask;
my @off = $drawable->offsets;
$bounds[2]-- if $bounds[0]+$bounds[2] >= ($drawable->offsets)[0]+$drawable->width;
$bounds[3]-- if $bounds[1]+$bounds[3] >= ($drawable->offsets)[1]+$drawable->height;
{
my $src = new PixelRgn ($drawable->get,@bounds[0,1],$bounds[2]+1,$bounds[3]+1,0,0);
my $dst = new PixelRgn ($drawable->get,@bounds,1,1);
my $bpp = $src->bpp > 1 ? ":," : "";
$iter = Gimp->pixel_rgns_register ($dst);
do {
my ($x,$y,$w,$h)=($dst->x,$dst->y,$dst->w,$dst->h);
my $reg = $src->get_rect($x,$y,$w+1,$h+1)->convert(short);
$dst->data(($reg->slice("${bpp}0:-2,0:-2")+
$reg->slice("${bpp}1:-1,0:-2")+
$reg->slice("${bpp}1:-1,1:-1")+
$reg->slice("${bpp}0:-2,1:-1"))>>2);
Gimp->progress_update (($dst->y-$bounds[1])/$bounds[2]);
} while (Gimp->pixel_rgns_process ($iter));
}
Gimp->progress_update (1);
$drawable->merge_shadow (1);
$drawable->update (@bounds);
();
};
register "gouge_contrast",
"contrast enhance an image using the gouge algorithm",
"Contrast Enhance an image using a fast algorithm found in a paper by James O. Gouge.",
"Marc Lehmann",
"Marc Lehmann <pcg\@goof.com>",
"19990723",
"<Image>/Filters/Enhance/Contrast",
"RGB*, GRAY*",
[],
sub {
my($image,$drawable)=@_;
Gimp->progress_init ("Gouge contrast enhancing...");
my @bounds = $drawable->mask;
my @off = $drawable->offsets;
$bounds[2]-- if $bounds[0]+$bounds[2] >= ($drawable->offsets)[0]+$drawable->width;
$bounds[3]-- if $bounds[1]+$bounds[3] >= ($drawable->offsets)[1]+$drawable->height;
{
my $src = new PixelRgn ($drawable->get,@bounds[0,1],$bounds[2]+1,$bounds[3]+1,0,0);
my $dst = new PixelRgn ($drawable->get,@bounds,1,1);
my $bpp = $src->bpp > 1 ? ":," : "";
$iter = Gimp->pixel_rgns_register ($dst);
do {
my ($x,$y,$w,$h)=($dst->x,$dst->y,$dst->w,$dst->h);
my $reg = $src->get_rect($x,$y,$w+1,$h+1)->convert(short);
my $T = $reg->slice("${bpp}0:-2,0:-2");
my $D = $reg->slice("${bpp}1:-1,1:-1");
$dst->data((($T<<1)-$D)->clip(0,255));
Gimp->progress_update (($dst->y-$bounds[1])/$bounds[2]);
} while (Gimp->pixel_rgns_process ($iter));
}
Gimp->progress_update (1);
$drawable->merge_shadow (1);
$drawable->update (@bounds);
();
};
register "gouge_edge",
"detect edges in an image using the gouge algorithm",
"Detect edges in the image using a fast algorithm found in a paper by James O. Gouge. It is similar to Sobel, yet sharper.",
"Marc Lehmann",
"Marc Lehmann <pcg\@goof.com>",
"19990723",
"<Image>/Filters/Edge-Detect/Gouge",
"RGB*, GRAY*",
[],
sub {
my($image,$drawable)=@_;
Gimp->progress_init ("Gouge edge detection...");
my @bounds = $drawable->mask;
my @off = $drawable->offsets;
$bounds[2]-- if $bounds[0]+$bounds[2] >= ($drawable->offsets)[0]+$drawable->width;
$bounds[3]-- if $bounds[1]+$bounds[3] >= ($drawable->offsets)[1]+$drawable->height;
{
my $src = new PixelRgn ($drawable->get,@bounds[0,1],$bounds[2]+1,$bounds[3]+1,0,0);
my $dst = new PixelRgn ($drawable->get,@bounds,1,1);
my $bpp = $src->bpp > 1 ? ":," : "";
$iter = Gimp->pixel_rgns_register ($dst);
do {
my ($x,$y,$w,$h)=($dst->x,$dst->y,$dst->w,$dst->h);
my $reg = $src->get_rect($x,$y,$w+1,$h+1)->convert(short);
my $T = $reg->slice("${bpp}0:-2,0:-2");
my $R = $reg->slice("${bpp}1:-1,0:-2");
my $D = $reg->slice("${bpp}1:-1,1:-1");
$dst->data(abs(cat($T-$R,$T-$D))
->convert(byte)
->mv(!!$bpp+2,0)
->maximum);
Gimp->progress_update (($src->y-$bounds[1])/$bounds[2]);
} while (Gimp->pixel_rgns_process ($iter));
}
Gimp->progress_update (1);
$drawable->merge_shadow (1);
$drawable->update (@bounds);
();
};
exit main;
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment