"Fossies" - the Fresh Open Source Software Archive  

Source code changes of the file "Libtmp/Image2D/image2d.pd" between
PDL-2.078.tar.gz and PDL-2.079.tar.gz

About: PDL (Perl Data Language) aims to turn perl into an efficient numerical language for scientific computing (similar to IDL and MatLab).

image2d.pd  (PDL-2.078):image2d.pd  (PDL-2.079)
skipping to change at line 629 skipping to change at line 629
if (norm>0) { /* Patch */ if (norm>0) { /* Patch */
$b(m=>i,n=>j) = tmp/norm; $b(m=>i,n=>j) = tmp/norm;
} }
} /* if: bad() */ } /* if: bad() */
} /* for: i */ } /* for: i */
} /* for: j */ } /* for: j */
%} /* broadcastloop */ %} /* broadcastloop */
', # Code ', # Code
); );
pp_def('patchbad2d', pp_def('patchbad2d',
Doc=><<'EOD', Doc=><<'EOD',
=for ref =for ref
patch bad pixels out of 2D images containing bad values patch bad pixels out of 2D images containing bad values
=for usage =for usage
$patched = patchbad2d $data; $patched = patchbad2d $data;
Pixels are replaced by the average of their non-bad neighbours; Pixels are replaced by the average of their non-bad neighbours;
if all neighbours are bad, the output is set bad. if all neighbours are bad, the output is set bad.
If the input ndarray contains I<no> bad values, then a straight copy If the input ndarray contains I<no> bad values, then a straight copy
is performed (see L</patch2d>). is performed (see L</patch2d>).
=cut
EOD EOD
BadDoc => BadDoc =>
'patchbad2d handles bad values. The output ndarray I<may> contain 'patchbad2d handles bad values. The output ndarray I<may> contain
bad values, depending on the pattern of bad values in the input ndarray.', bad values, depending on the pattern of bad values in the input ndarray.',
HandleBad => 1, HandleBad => 1,
Pars => 'a(m,n); [o]b(m,n);', Pars => 'a(m,n); [o]b(m,n);',
CopyBadStatusCode => '', # handled by BadCode
Code => Code =>
'int i1,j1, flag = 0; 'int i1,j1, flag = 0;
PDL_Indx m_size = $SIZE(m), n_size = $SIZE(n); PDL_Indx m_size = $SIZE(m), n_size = $SIZE(n);
broadcastloop %{ broadcastloop %{
loop(n) %{ loop(n) %{
loop(m) %{ loop(m) %{
$GENERIC(a) a_val = $a(); $GENERIC(a) a_val = $a();
PDL_IF_BAD(if ( !$ISGOODVAR(a_val,a) ) { PDL_IF_BAD(if ( !$ISGOODVAR(a_val,a) ) {
double tmp = 0; PDL_Indx norm=0; double tmp = 0; PDL_Indx norm=0;
for(j1=-1; j1<=1; j1++) { for(j1=-1; j1<=1; j1++) {
skipping to change at line 801 skipping to change at line 795
$xcen() = sumx/sum; $xcen() = sumx/sum;
$ycen() = sumy/sum; $ycen() = sumy/sum;
} }
' '
); );
pp_addhdr(' pp_addhdr('
void AddEquiv ( PDL_Long* equiv, PDL_Long i, PDL_Long j); void AddEquiv ( PDL_Long* equiv, PDL_Long i, PDL_Long j);
'); ');
pp_add_exported('', 'crop');
pp_addpm(<<'EOPM');
=head2 crop
=for ref
Return bounding box of given mask in an C<indx> ndarray, so it can broadcast.
Use other operations (such as L<PDL::Bad/isgood>, or
L<PDL::Primitive/eqvec> with a colour vector) to create a mask suitable
for your application.
=for example
$x1x2y1y2 = crop($image);
=cut
*crop = \&PDL::crop;
sub PDL::crop {
my ($mask) = @_;
$mask->xchg(0,1)->orover->_which_int(my $out = null, null);
$out->badflag(1); $out->badvalue(-1);
my ($x1, $x2) = $out->minmaximum;
$mask->orover->_which_int($out = null, null);
$out->badflag(1); $out->badvalue(-1);
my ($y1, $y2) = $out->minmaximum;
$x1->cat($x2, $y1, $y2)->mv(-1,0);
}
EOPM
pp_add_exported('', 'cc8compt','cc4compt'); pp_add_exported('', 'cc8compt','cc4compt');
pp_addpm(<<'EOPM'); pp_addpm(<<'EOPM');
=head2 cc8compt =head2 cc8compt
=for ref =for ref
Connected 8-component labeling of a binary image. Connected 8-component labeling of a binary image.
Connected 8-component labeling of 0,1 image - i.e. find separate Connected 8-component labeling of 0,1 image - i.e. find separate
 End of changes. 5 change blocks. 
6 lines changed or deleted 30 lines changed or added

Home  |  About  |  Features  |  All  |  Newest  |  Dox  |  Diffs  |  RSS Feeds  |  Screenshots  |  Comments  |  Imprint  |  Privacy  |  HTTP(S)