Hello David,

thank you for the detailed explanations.

What I actually would like is looping over images and annotating them
with lines (and perhaps text). It is a Prima application with callbacks.
It is meant to facilitating picking borders (or other features) on the
image, enabling (or hiding) some of those annotations.

Well, there are annotation classes and I have managed by now to get the
basics.

What I would like is pixel-wise transparency, like in RGBA or similar,
so that what is below is partially visible, the 32 bit one you mentioned.

Here's my test code. Ingo

#!/usr/bin/perl


use PDL::Graphics::Prima;
use Prima qw(Application);
use strict;
use PDL;
use 5.10.0;

my $img=rvals(100,100);

my $mw=Prima::MainWindow->create(
    text  => 'Graph Test',
    size  => [300, 300],
);


my
$nl=pnote::Line(x1=>{pct=>0},y1=>{pct=>0.5},x2=>{pct=>1},y2=>{pct=>0.5},
colors=>cl::LightBlue,lineWidths=>10,);
my $ip=$mw->insert('Plot', -img=>ds::Grid($img,
        x_bounds=>[0,299],
        y_bounds=>[0,299],
        plotType=> pgrid::Matrix(palette=>pal::Rainbow) ,
        ),
        -note=>ds::Note($nl),
        pack=> { fill => 'both', expand => 1}
        );


$ip->set(onMouseMove=>sub {
    my ($self, $button,$x_pixel, $y_pixel) = @_;
    # update x and y mouse pos
    #my $x=$xdim*$self->x->pixels_to_relatives($x_pixel);
    #my $y=$ydim*$self->y->pixels_to_relatives($y_pixel);
        $nl->{x1}={raw=>$x_pixel};
        $nl->{y1}={raw=>$y_pixel};


        $nl->draw($self,1);

} );


run Prima;



On 2/22/22 19:40, David Mertens wrote:
Hello Ingo,

I'm not quite sure I understand exactly what you're trying to do, so
I'll spell out a few options.

First, it is fairly easy to load images using Prima, then to use
Prima's Drawable API to draw lines (see the line(), lines(), or
polyline() functions, or the ), place text, and overlay other images.
For the latter, see text_out() for the most basic, draw_text() for
slightly fancier, text_wrap() for fancier yet with wrapping, and
finally the various shaped text functions. You can put one image atop
another using put_image(), put_image_indirect(), or stretch_image().
Note: I am not sure how well Prima handles overlaying images with
transparent pixels. I had a back-and-forth a few years ago urging
Dmitry to have an image format that included per-pixel alpha data
(32-bit would be sufficient), but I don't know if he ever implemented
that. I've been out of PDL/Prima stuff for a few years and I'm still
getting up to speed with everything Dmitry's done with Prima over that
time.

Second, perhaps you want to put images onto a PDL::Graphics::Prima
plot? In that case note that the plots are drawn in asciibetical order
by dataset name. Datasets that you want drawn above others should have
a name (or prefix) that sorts later. So "a_map" and "b_lines" would
draw the lines after the map.

Third, if you're "plotting" an image using PDL::Graphics::Prima, you
can get per-pixel transparency by setting transparent pixels to
BAD---bad values are simply skipped by the "matrix" drawing datasets.
I've meant to make it possible to set a color for bad values and
haven't gotten there yet, l but for now you can use it for transparency.

I hope that helps. If not, if you could give me a few more details on
what exactly you're trying to accomplish, I can give more specific
ideas---or work on adding features to PDL::Graphics::Prima if needed.

David

On Tue, Feb 22, 2022 at 6:10 AM Ingo Schmid <[email protected]> wrote:

    Hi,

    I was looking for a way to overlay images or an image with
    annotations like e.g. lines or text. I can add them as datasets to
    the same plot but the topmost always wins and the rest is hidden
    below.

    The only workaround I have found is editing the image itself, but
    that is messing with data flow.

    Best wishes Ingo

    _______________________________________________
    pdl-general mailing list
    [email protected]
    https://lists.sourceforge.net/lists/listinfo/pdl-general



--
 "Debugging is twice as hard as writing the code in the first place.
  Therefore, if you write the code as cleverly as possible, you are,
  by definition, not smart enough to debug it." -- Brian Kernighan
_______________________________________________
pdl-general mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/pdl-general

Reply via email to