PolygonRoi getContainedPoints() ???

Previous Topic Next Topic
 
classic Classic list List threaded Threaded
5 messages Options
Reply | Threaded
Open this post in threaded view
|

PolygonRoi getContainedPoints() ???

Kenneth Sloan-3
Looking at the API, I see a method:
 java.awt.Point[] getContainedPoints()

defined in “Roi” (and inherited in PolygonRoi)

But, this code:
======================================
// qAFPolygon is a Polygon

  PolygonRoi qAFPolygonRoi = new PolygonRoi(qAFPolygon, Roi.POLYGON);
  java.awt.Point[] qAFCoords = qAFPolygonRoi.getContainedPoints();
======================================
fails with the following errors:

 [javac] java.awt.Point[] qAFCoords = qAFPolygonRoi.getContainedPoints();
    [javac]                                          ^
    [javac]   symbol:   method getContainedPoints()
    [javac]   location: variable qAFPolygonRoi of type PolygonRoi

I’ve tried variants that *should* work the same - and they do - they all get the same error.


Poking around, I see an old (2016) thread where “getContainedPoints” is referenced as if it did not exist.  The thread proceeds to offer up a solution using a mask.

Am I simply using an out-of-date ImageJ (I’m using the latest FIJI)?  Is “getContainedPoints” a new feature not in my version?  (hmmm - “about” says Fiji version 1.0 - can that be right?)

If so (since I have to deliver to a customer who will also use this version), I’m going to proceed to implement the mask method.

If not - what have I gotten wrong (this time?)

Allow me to take the opportunity to thank thoses who helped with the last problem, which was, of course, a classic “face palm”.  Armed with the knowledge that my code snippet was correct, it was easy to find the gross error elsewhere.


In the short term, I think I’ll implement a private “getContainedPoints”, using a mask.  That should, at least, work.  If the real “getContainedPoints” shows up, I can switch.

--
Kenneth Sloan
[hidden email] <mailto:[hidden email]>
Vision is the art of seeing what is invisible to others.





--
ImageJ mailing list: http://imagej.nih.gov/ij/list.html
Reply | Threaded
Open this post in threaded view
|

Re: PolygonRoi getContainedPoints() ???

ctrueden
Hi Ken,

The getContainedPoints() feature was added in 1.51a, released 3 May 2016.
(See release notes [1].) Fiji currently ships with 1.51n.

In my tests with an up-to-date Fiji, the following Groovy script works when
you have an image open with a polygon ROI drawn on it:

  #@ ImagePlus imp
  pts = imp.getRoi().getContainedPoints()
  println(pts)

Regards,
Curtis

[1] https://imagej.nih.gov/ij/notes.html

--
Curtis Rueden
LOCI software architect - https://loci.wisc.edu/software
ImageJ2 lead, Fiji maintainer - https://imagej.net/User:Rueden
Did you know ImageJ has a forum? http://forum.imagej.net/


On Thu, Oct 26, 2017 at 7:26 PM, Kenneth Sloan <[hidden email]>
wrote:

> Looking at the API, I see a method:
>  java.awt.Point[] getContainedPoints()
>
> defined in “Roi” (and inherited in PolygonRoi)
>
> But, this code:
> ======================================
> // qAFPolygon is a Polygon
>
>   PolygonRoi qAFPolygonRoi = new PolygonRoi(qAFPolygon, Roi.POLYGON);
>   java.awt.Point[] qAFCoords = qAFPolygonRoi.getContainedPoints();
> ======================================
> fails with the following errors:
>
>  [javac]        java.awt.Point[] qAFCoords = qAFPolygonRoi.
> getContainedPoints();
>     [javac]                                               ^
>     [javac]   symbol:   method getContainedPoints()
>     [javac]   location: variable qAFPolygonRoi of type PolygonRoi
>
> I’ve tried variants that *should* work the same - and they do - they all
> get the same error.
>
>
> Poking around, I see an old (2016) thread where “getContainedPoints” is
> referenced as if it did not exist.  The thread proceeds to offer up a
> solution using a mask.
>
> Am I simply using an out-of-date ImageJ (I’m using the latest FIJI)?  Is
> “getContainedPoints” a new feature not in my version?  (hmmm - “about” says
> Fiji version 1.0 - can that be right?)
>
> If so (since I have to deliver to a customer who will also use this
> version), I’m going to proceed to implement the mask method.
>
> If not - what have I gotten wrong (this time?)
>
> Allow me to take the opportunity to thank thoses who helped with the last
> problem, which was, of course, a classic “face palm”.  Armed with the
> knowledge that my code snippet was correct, it was easy to find the gross
> error elsewhere.
>
>
> In the short term, I think I’ll implement a private “getContainedPoints”,
> using a mask.  That should, at least, work.  If the real
> “getContainedPoints” shows up, I can switch.
>
> --
> Kenneth Sloan
> [hidden email] <mailto:[hidden email]>
> Vision is the art of seeing what is invisible to others.
>
>
>
>
>
> --
> ImageJ mailing list: http://imagej.nih.gov/ij/list.html
>

--
ImageJ mailing list: http://imagej.nih.gov/ij/list.html
Reply | Threaded
Open this post in threaded view
|

Re: PolygonRoi getContainedPoints() ???

Kenneth Sloan-3
Hmmm…I just downloaded a brand new Fiji two days ago - and you saw the compiler output.
I start with a PolygonRoi and ask for the get.ContainedPoints() method.  The compiler spits up
and says “no such method”.

It confirms that “qAFPolygonRok” has type PolygonRoi, but it can’t find getContainedPoints.

I’ll dig deeper - but now that I have the work-around (and the plugin) working, I
may see this drop deeper into my stack.  I expect that for at least the next week I’ll
be tweaking the high level behavior of the plugin…and then analyzing the data it generates.

Just tried to manually update ImageJ and it says I’m running: v1.15n and offerss to upgrade to V1.51r.

I’ll update and try again…tomorrow.

There’s also the minor issue that you are testing with a script.  I’m compiling a java plugin.  Is it possible
getContainedPoints() works in scripts, but not in compiled code?


Ahhh…there’s one more possibility.  I inherited this development environment from students who have long since disappeared.
It occurs to me that they may have squirreled away a private copy of ImageJ to compile against - which is not necessarily the
ImageJ I’m running on.  This sounds promising.

Off I go to chase this down…

Thanks very much for your help.  As with the last case, the knowledge that it works properly for you makes me more likely to drill
down and look for other, more esoteric reasons.  I appreciate your time, and your quick response time.

--
Kenneth Sloan
[hidden email] <mailto:[hidden email]>
Vision is the art of seeing what is invisible to others.




> On Oct 26, 2017, at 22:51 , Curtis Rueden <[hidden email]> wrote:
>
> Hi Ken,
>
> The getContainedPoints() feature was added in 1.51a, released 3 May 2016.
> (See release notes [1].) Fiji currently ships with 1.51n.
>
> In my tests with an up-to-date Fiji, the following Groovy script works when
> you have an image open with a polygon ROI drawn on it:
>
>  #@ ImagePlus imp
>  pts = imp.getRoi().getContainedPoints()
>  println(pts)
>
> Regards,
> Curtis
>
> [1] https://imagej.nih.gov/ij/notes.html <https://imagej.nih.gov/ij/notes.html>
>
> --
> Curtis Rueden
> LOCI software architect - https://loci.wisc.edu/software <https://loci.wisc.edu/software>
> ImageJ2 lead, Fiji maintainer - https://imagej.net/User:Rueden <https://imagej.net/User:Rueden>
> Did you know ImageJ has a forum? http://forum.imagej.net/ <http://forum.imagej.net/>
>
>
> On Thu, Oct 26, 2017 at 7:26 PM, Kenneth Sloan <[hidden email] <mailto:[hidden email]>>
> wrote:
>
>> Looking at the API, I see a method:
>> java.awt.Point[] getContainedPoints()
>>
>> defined in “Roi” (and inherited in PolygonRoi)
>>
>> But, this code:
>> ======================================
>> // qAFPolygon is a Polygon
>>
>>  PolygonRoi qAFPolygonRoi = new PolygonRoi(qAFPolygon, Roi.POLYGON);
>>  java.awt.Point[] qAFCoords = qAFPolygonRoi.getContainedPoints();
>> ======================================
>> fails with the following errors:
>>
>> [javac]        java.awt.Point[] qAFCoords = qAFPolygonRoi.
>> getContainedPoints();
>>    [javac]                                               ^
>>    [javac]   symbol:   method getContainedPoints()
>>    [javac]   location: variable qAFPolygonRoi of type PolygonRoi
>>
>> I’ve tried variants that *should* work the same - and they do - they all
>> get the same error.
>>
>>
>> Poking around, I see an old (2016) thread where “getContainedPoints” is
>> referenced as if it did not exist.  The thread proceeds to offer up a
>> solution using a mask.
>>
>> Am I simply using an out-of-date ImageJ (I’m using the latest FIJI)?  Is
>> “getContainedPoints” a new feature not in my version?  (hmmm - “about” says
>> Fiji version 1.0 - can that be right?)
>>
>> If so (since I have to deliver to a customer who will also use this
>> version), I’m going to proceed to implement the mask method.
>>
>> If not - what have I gotten wrong (this time?)
>>
>> Allow me to take the opportunity to thank thoses who helped with the last
>> problem, which was, of course, a classic “face palm”.  Armed with the
>> knowledge that my code snippet was correct, it was easy to find the gross
>> error elsewhere.
>>
>>
>> In the short term, I think I’ll implement a private “getContainedPoints”,
>> using a mask.  That should, at least, work.  If the real
>> “getContainedPoints” shows up, I can switch.
>>
>> --
>> Kenneth Sloan
>> [hidden email] <mailto:[hidden email]> <mailto:[hidden email] <mailto:[hidden email]>>
>> Vision is the art of seeing what is invisible to others.
>>
>>
>>
>>
>>
>> --
>> ImageJ mailing list: http://imagej.nih.gov/ij/list.html <http://imagej.nih.gov/ij/list.html>
>>
>
> --
> ImageJ mailing list: http://imagej.nih.gov/ij/list.html <http://imagej.nih.gov/ij/list.html>

--
ImageJ mailing list: http://imagej.nih.gov/ij/list.html
Reply | Threaded
Open this post in threaded view
|

Re: PolygonRoi getContainedPoints() ???

ctrueden
Hi Ken,

> I inherited this development environment from students who have long
> since disappeared. It occurs to me that they may have squirreled away
> a private copy of ImageJ to compile against - which is not necessarily
> the ImageJ I’m running on.  This sounds promising.

I would encourage you to look at modeling your project after this example
template:
     https://github.com/imagej/example-legacy-plugin

This project works in the major IDEs as well as from the CLI with proper
dependency management.

Regards,
Curtis

--
Curtis Rueden
LOCI software architect - https://loci.wisc.edu/software
ImageJ2 lead, Fiji maintainer - https://imagej.net/User:Rueden
Did you know ImageJ has a forum? http://forum.imagej.net/


On Thu, Oct 26, 2017 at 11:20 PM, Kenneth Sloan <[hidden email]>
wrote:

> Hmmm…I just downloaded a brand new Fiji two days ago - and you saw the
> compiler output.
> I start with a PolygonRoi and ask for the get.ContainedPoints() method.
> The compiler spits up
> and says “no such method”.
>
> It confirms that “qAFPolygonRok” has type PolygonRoi, but it can’t find
> getContainedPoints.
>
> I’ll dig deeper - but now that I have the work-around (and the plugin)
> working, I
> may see this drop deeper into my stack.  I expect that for at least the
> next week I’ll
> be tweaking the high level behavior of the plugin…and then analyzing the
> data it generates.
>
> Just tried to manually update ImageJ and it says I’m running: v1.15n and
> offerss to upgrade to V1.51r.
>
> I’ll update and try again…tomorrow.
>
> There’s also the minor issue that you are testing with a script.  I’m
> compiling a java plugin.  Is it possible
> getContainedPoints() works in scripts, but not in compiled code?
>
>
> Ahhh…there’s one more possibility.  I inherited this development
> environment from students who have long since disappeared.
> It occurs to me that they may have squirreled away a private copy of
> ImageJ to compile against - which is not necessarily the
> ImageJ I’m running on.  This sounds promising.
>
> Off I go to chase this down…
>
> Thanks very much for your help.  As with the last case, the knowledge that
> it works properly for you makes me more likely to drill
> down and look for other, more esoteric reasons.  I appreciate your time,
> and your quick response time.
>
> --
> Kenneth Sloan
> [hidden email] <mailto:[hidden email]>
> Vision is the art of seeing what is invisible to others.
>
>
>
>
> > On Oct 26, 2017, at 22:51 , Curtis Rueden <[hidden email]> wrote:
> >
> > Hi Ken,
> >
> > The getContainedPoints() feature was added in 1.51a, released 3 May 2016.
> > (See release notes [1].) Fiji currently ships with 1.51n.
> >
> > In my tests with an up-to-date Fiji, the following Groovy script works
> when
> > you have an image open with a polygon ROI drawn on it:
> >
> >  #@ ImagePlus imp
> >  pts = imp.getRoi().getContainedPoints()
> >  println(pts)
> >
> > Regards,
> > Curtis
> >
> > [1] https://imagej.nih.gov/ij/notes.html <https://imagej.nih.gov/ij/
> notes.html>
> >
> > --
> > Curtis Rueden
> > LOCI software architect - https://loci.wisc.edu/software <
> https://loci.wisc.edu/software>
> > ImageJ2 lead, Fiji maintainer - https://imagej.net/User:Rueden <
> https://imagej.net/User:Rueden>
> > Did you know ImageJ has a forum? http://forum.imagej.net/ <
> http://forum.imagej.net/>
> >
> >
> > On Thu, Oct 26, 2017 at 7:26 PM, Kenneth Sloan <[hidden email]
> <mailto:[hidden email]>>
> > wrote:
> >
> >> Looking at the API, I see a method:
> >> java.awt.Point[] getContainedPoints()
> >>
> >> defined in “Roi” (and inherited in PolygonRoi)
> >>
> >> But, this code:
> >> ======================================
> >> // qAFPolygon is a Polygon
> >>
> >>  PolygonRoi qAFPolygonRoi = new PolygonRoi(qAFPolygon, Roi.POLYGON);
> >>  java.awt.Point[] qAFCoords = qAFPolygonRoi.getContainedPoints();
> >> ======================================
> >> fails with the following errors:
> >>
> >> [javac]        java.awt.Point[] qAFCoords = qAFPolygonRoi.
> >> getContainedPoints();
> >>    [javac]                                               ^
> >>    [javac]   symbol:   method getContainedPoints()
> >>    [javac]   location: variable qAFPolygonRoi of type PolygonRoi
> >>
> >> I’ve tried variants that *should* work the same - and they do - they all
> >> get the same error.
> >>
> >>
> >> Poking around, I see an old (2016) thread where “getContainedPoints” is
> >> referenced as if it did not exist.  The thread proceeds to offer up a
> >> solution using a mask.
> >>
> >> Am I simply using an out-of-date ImageJ (I’m using the latest FIJI)?  Is
> >> “getContainedPoints” a new feature not in my version?  (hmmm - “about”
> says
> >> Fiji version 1.0 - can that be right?)
> >>
> >> If so (since I have to deliver to a customer who will also use this
> >> version), I’m going to proceed to implement the mask method.
> >>
> >> If not - what have I gotten wrong (this time?)
> >>
> >> Allow me to take the opportunity to thank thoses who helped with the
> last
> >> problem, which was, of course, a classic “face palm”.  Armed with the
> >> knowledge that my code snippet was correct, it was easy to find the
> gross
> >> error elsewhere.
> >>
> >>
> >> In the short term, I think I’ll implement a private
> “getContainedPoints”,
> >> using a mask.  That should, at least, work.  If the real
> >> “getContainedPoints” shows up, I can switch.
> >>
> >> --
> >> Kenneth Sloan
> >> [hidden email] <mailto:[hidden email]> <mailto:
> [hidden email] <mailto:[hidden email]>>
> >> Vision is the art of seeing what is invisible to others.
> >>
> >>
> >>
> >>
> >>
> >> --
> >> ImageJ mailing list: http://imagej.nih.gov/ij/list.html <
> http://imagej.nih.gov/ij/list.html>
> >>
> >
> > --
> > ImageJ mailing list: http://imagej.nih.gov/ij/list.html <
> http://imagej.nih.gov/ij/list.html>
>
> --
> ImageJ mailing list: http://imagej.nih.gov/ij/list.html
>

--
ImageJ mailing list: http://imagej.nih.gov/ij/list.html
Reply | Threaded
Open this post in threaded view
|

Re: PolygonRoi getContainedPoints() ???

Kenneth Sloan-3
Curtis-

Thanks for the pointer.  In the last hour, I think I’ve verified that my problems have to do
with keeping a private copy of ij.jar.

I’m on the road tomorrow, but have some free time over the weekend.

My problem is that I’m supporting a fair number of legacy java plugins written by a long
string of students over the years.  I have “retired”, which essentially means that
student support has disappeared and there is now ONE programmer on staff (that would be me).

Oh yeah…most of my “customers” use Macs (as do I) - but a couple of very important
collaborators use WinDoze machines.  I have only a virtual PC, which I *only* use to make the final
compile to distribute .jar files for PC users.

So…I’ve tried to keep it simple by cutting and pasting and following the (not always
perfect) decisions made over the last 10 years by that long string of students…  One of
thoses decisions was “ant”.  I have no idea if it’s a good solution - but I’m reasonably
competent at editing build.xml files and following along blindly.  Except for the
times when things like the cached ij.jar file leap up and bite me.

I suppose I need to bite the bullet and pick a new development/distribution environment.
I can leave the stable plugins in the old system, and build new plugins in
a brand new environment.

Oh yeah…did I mention that I have EMACS in my fingers and develop most of my stand-alone Java programs
using the old faithful “javac *.java”?  20 years ago I was a makefile wizard, but no longer.
So…I find myself stuck between two worlds.  I have never warmed up to modern IDE’s - but
that’s probably based on lots of bad experiences with very early attempts.  In most of my (non-ImageJ)
Java development I’m a big fan of lots and lots of sharing and duplication of SOURCE code.
90% of the code in my projects is code that I have written - and it is all always subject to
constant tweaking - even at the cost of multiple versions.  When I re-use other people’s code
I always prefer SOURCE code that I can modify to suit my needs.

Time to learn a few new tricks, perhaps.

Anyway - I think we’ve solved my API problems.  In the short term, I’m happy with my workaround.
It actually looks like one of those methods which is simple for the user to write, and therefore
doesn’t really need to be cluttering up the API.  It was only a few lines of code, which I was
prepared to write…until I chanced to see the getContainedPoints() listed in the API.  That
looked like it would save me a half an hour.  Didn’t turn out that way.  But - no harm.
The plugin under development is working and ready for customer testing.  I have two more on
the drawing board.

I’ll probably try to “fix” the current development environment (but only minimally)
- and then bite the bullet and start doing all new development in a new environment.

So - here are the constraints:

a) the editor *must* be EMACS
b) final products are .jar files for Mac (all testing done here) and WinDoze (delivery only)
c) just  for grins…some of my “customers” use things like TrakEm, which they claim imposes
   restrictions on exactly what version of Java they can have installed on their machines.
   I don’t know how real these constraints are, but “the customer is always right”
d) we’re talking relatively small programs - a few hundred lines of code at the most.
e) Java only - no “scripting language of the month”, please.

I’ll check out your suggestion.  I appreciate the help.

--
Kenneth Sloan
[hidden email] <mailto:[hidden email]>
Vision is the art of seeing what is invisible to others.

 
--
ImageJ mailing list: http://imagej.nih.gov/ij/list.html