App-PLab
view release on metacpan or search on metacpan
if ( $ax >= 0 && $ay >= 0 && $ax < $w->{IVx} && $ay < $w->{IVy}) {
if ( $w-> rpt_toggle( $ax, $ay)) {
$self-> begin_paint;
$self-> color( $w->{ini}->{Color_Points});
my $p = ( 6 * $self-> zoom < 1) ? 1 : ( 6 * $self-> zoom);
$self-> ellipse( $x, $y, $p, $p);
$self-> end_paint;
$w-> sb_text( "New reference point: $ax $ay");
} else {
my $p = ( 32 * $self-> zoom < 1) ? 1 : ( 32 * $self-> zoom);
$self-> invalidate_rect( $x - $p, $y - $p, $x + $p, $y + $p);
$w-> sb_text( "Reference point deleted: $ax $ay");
}
$w-> sb_points();
}
}
$self-> clear_event;
}
sub IV_MouseUp
bin/MorphometryI view on Meta::CPAN
return unless $w-> {recWindow};
my $r = $w-> {recWindow};
my $i = $w-> {ini};
$i-> {UFThreshold} = $r-> Union-> value;
$i-> {BinThreshold} = $r-> Binary-> value;
$i-> {EdgeSize} = $r-> Edge-> value;
$i-> {MinArea} = $r-> Min-> value;
$i-> {MaxArea} = $r-> Max-> value;
}
sub win_validate
{
my ( $w, $silent) = @_;
my ( $min, $max, $edge);
my ( $umax, $umin, $j, $iptr);
return unless defined $w-> {file};
$w-> win_syncrecdata;
$umin = $w-> {ini}-> {MinArea};
$umax = $w-> {ini}-> {MaxArea};
bin/MorphometryI view on Meta::CPAN
{
my $w = $_[0];
my $xmlname = $w-> win_extname( $w-> {file});
return 1 unless $w-> {modified};
if ( open F, "> $xmlname") {
my $waitPtr = $::application-> pointer;
$::application-> pointer( cr::Wait);
$w-> sb_text("saving $xmlname");
$w-> win_validate(1);
$w-> win_syncrecdata;
my $image = $w-> IV-> image;
if ( $w->{ini}->{CalcBrightness} && $w->{ini}->{EqualBrightness}) {
# subtracting low frequencies
$w-> sb_text("Equalizing background ...");
my $i1 = Prima::IPA::Global::butterworth( $image,
low => 1,
homomorph => 0,
power => 2,
cutoff => 20,
bin/MorphometryI view on Meta::CPAN
my ( $ax, $ay) = $self-> screen2point( $x, $y);
if ( $w-> rpt_toggle( $ax, $ay)) {
$self-> begin_paint;
$self-> color( $w->{pointColor});
my $p = ( 6 * $self-> zoom < 1) ? 1 : ( 6 * $self-> zoom);
$self-> fill_ellipse( $x, $y, $p, $p);
$self-> end_paint;
$w-> sb_text( "New reference point: $ax $ay");
} else {
my $p = ( 32 * $self-> zoom < 1) ? 1 : ( 32 * $self-> zoom);
$self-> invalidate_rect( $x - $p, $y - $p, $x + $p, $y + $p);
$w-> sb_text( "Reference point deleted: $ax $ay");
}
$w-> modified( 1);
$self-> clear_event;
return;
}
{
#starting freehand session
$w-> iv_entermode( $self, 1);
bin/MorphometryI view on Meta::CPAN
[ EditRemovePoints => "Clear all ~points" => sub {
$_[0]-> rpt_clear;
$_[0]-> IV-> repaint;
$_[0]-> modified( 1);
}, ],
[],
[ '-EditToggleMode' => "~Toggle points <-> drawings" => 'F11'=>'F11' => sub { $_[0]-> iv_cancelmode( $_[0]-> IV); $_[0]-> iv_togglemode( $_[0]-> IV)}],
[],
[ 'EditInvertImage' => '~Invert image' => sub { $_[0]-> win_set_negative( $_[0]-> {ini}-> {InvertImage} ? 0 : 1); } ],
[ '-EditValidate' => "~Validate contours" => 'Ctrl+Enter'=> km::Ctrl|kb::Enter ,
sub { $_[0]-> win_validate(0) }],
[ EditRecSetup => "Recognition ~setup" => sub { $_[0]-> win_showrec; }, ],
[ '-EditApplyContours' => "~Apply contours" => 'Alt+Enter'=> km::Alt|kb::Enter , q(win_applycontours)],
[],
[ 'EditHack' => "~Outline convex ~hull" => q(win_outline_convex_hull)],
);
my $w = MorphoWindow-> create(
visible => 0,
menuItems => [
$wfil,
bin/PrAverB view on Meta::CPAN
$iv-> {transaction} = undef;
$iv-> capture(0);
$w-> IV_xorpoly( $iv) unless $_[0]->{rectLike};
$w-> IV_xorrect( $iv);
$iv-> repaint;
$w-> modified( 1);
}
sub repaint
{
$_[0]-> {IV}-> invalidate_rect( $_[0]-> get_screen_bounds);
}
sub on_paint
{
my ( $me, $w, $iv, $canvas) = @_;
my @r = $iv-> point2screen( @{$_-> {rect}});
push @r, @r[0,1];
$canvas-> polyline(\@r);
if ( defined $me->{number}) {
$canvas-> text_out( $me->{number}, $iv-> point2screen( $me->{bounds}->[0], $me->{bounds}->[1]));
my ( $bx, $by) = @{ $w->{ branches}->[ $bn]->[ -2]};
my ( $left, $bottom, $right, $top) = ( $ox, $oy, $ox, $oy);
$left = $ex if $left > $ex;
$left = $bx if $left > $bx;
$bottom = $ey if $bottom > $ey;
$bottom = $by if $bottom > $by;
$right = $ex if $right < $ex;
$right = $bx if $right < $bx;
$top = $ey if $top < $ey;
$top = $by if $top < $by;
$self-> invalidate_rect( $self-> point2screen( $left, $bottom, $right + 1, $top + 1));
}
}
else{
my ( $mindist, $bn, $i);
my ( $rr);
for ( $i = 0; $i <= $#{ $w->{ branches}}; $i++) {
my ( $lmd, $j);
my ( $left, $bottom, $right, $top) = ( @{ $w->{ branches}->[ $i]->[ 0]}, @{ $w->{ branches}->[ $i]->[ 0]});
for ( $j = 0; $j < $#{ $w->{ branches}->[ $i]}; $j++) {
my ( $x1, $y1, $x2, $y2) = ( @{ $w->{ branches}->[ $i]->[ $j]},
}
if ( ( ! defined( $mindist)) || ( $mindist > $lmd)) {
$mindist = $lmd;
$bn = $i;
$rr = [ $left, $bottom, $right + 1, $top + 1];
}
}
if ( defined( $mindist) && ( $mindist <= 10)) {
if ( ( ! defined( $w->{ binfo}->{ nearestBranch})) || ( $w->{ binfo}->{ nearestBranch} != $bn)) {
$w->{ binfo}->{ nearestBranch} = $bn;
$self-> invalidate_rect( $self-> point2screen( @{ $w->{ binfo}->{ prevActiveRect}}))
if defined $w->{ binfo}->{ prevActiveRect};
$self->invalidate_rect( $self-> point2screen( @$rr));
$w->{ binfo}->{ prevActiveRect} = $rr;
}
}
elsif ( defined $w->{ binfo}->{ nearestBranch}) {
undef $w->{ binfo}->{ nearestBranch};
$self->invalidate_rect( $self-> point2screen( @{ $w->{ binfo}->{ prevActiveRect}}))
if defined $w->{ binfo}->{ prevActiveRect};
undef $w->{ binfo}->{ prevActiveRect};
}
}
}
sub IV_MouseClick
{
my ( $w, $self, $btn, $mod, $x, $y, $dbl) = @_;
# adding new point
$ax = int($ax);
$ay = int($ay);
push @$ary, "$ax $ay";
$w-> {"n$layer"}++;
$w-> {"total$layer"}++;
}
my $zp = $self-> zoom * $w->{ini}->{PointSize};
$zp = 4 if $zp < 4;
($x1, $x2, $y1, $y2) = map { ($_ - $zp - 2, $_ + $zp + 2); } ($ax,$ay);
$self-> invalidate_rect( $self-> point2screen( $x1, $y1, $x2, $y2));
}
$w-> update_state;
}
sub update_state
{
my $w = $_[0];
my $cp = $w-> ToolBar-> CellsProcesses;
if ( !defined $w-> {file})
{
lib/App/PLab/ImageApp.pm view on Meta::CPAN
{
$_[1]-> rectangle( 0, 0, 153, 101);
$_[1]-> stretch_image( 1, 1, 152, 100, $_[0]-> {canvas});
}
package App::PLab::TrImageViewer;
use vars qw(@ISA);
@ISA = qw(Prima::ImageViewer);
sub invalidate_rect
{
my ( $self, @r) = @_;
my $w = $self-> owner;
$w-> ivm_repaint( $self) if $w-> {magnify};
$self-> SUPER::invalidate_rect( @r);
}
sub end_paint
{
my $self = $_[0];
$self-> SUPER::end_paint;
my $w = $self-> owner;
$w-> ivm_repaint( $self) if $w-> {magnify};
}
lib/App/PLab/MorphometryI.pod view on Meta::CPAN
=back
=head2 Objects and background
Program is capable of collecting information of two different kinds of contours, namely
I<objects> and I<backgrounds>. Their difference is only when calculations take place,
in visual representaions they differs only in the color drawn. Default object color is green, background -
yellow. It could be changed in Preferences, Appearance bookmark.
Before program calculates data, it has to validate the contours drawn in some way. This is accomplished
using image-processign algorithm, that leaves only closed contours. This function activated either by
"Edit/Validate contours" command or implicitly when closing and image.
=for podview <img src="mIc1.gif">
=for podview <img src="mIc2.gif">
The contour in picures above is an example of the algorithm.
As shown from above, to quickly get rid of the unneeded closed contour, it's enough to break it.
( run in 0.272 second using v1.01-cache-2.11-cpan-4d50c553e7e )