get current image when implementing a Command interface

classic Classic list List threaded Threaded
4 messages Options
Reply | Threaded
Open this post in threaded view
|

get current image when implementing a Command interface

Carnë Draug-2
Hi

I'm trying to write an ImageJ plugin but I'm failing at the most basic
step which I thought would be getting the current image (last selected
image). I am using the @Parameter annotation to get a Dataset and
implementing a Command interface but I'm unsure of what it's
happening. Using:

  @Parameter
  private Dataset dataset;

as suggested on the tutorials [1], seems to use what the image was
when opened. After reading the javadocs [2], I have tried to set
persist to false but go no change.

Please, consider my very small case which should simply print the
image data type [3] (it requires closing the text window after each
call). I open the sample image "blobs" and the plugin will print
"8-bit" (expected). Then I open the sample "CT" and it prints "16-bit"
(expected). I then select the blobs image, run it again but get
"16-bit" (that was a surprise, I guess it's choosing the last opened
image). So I change the CT to 8-bit using "Edit > Type", run the
plugin again but still get back "16-bit" (uh! I have no idea of what's
going on).

I'm probably doing something very stupid as I'm still getting to grips
with java. Could anyone explain to me how to get the current image? I
did found the ImageJ1 getCurrentImage() method but I'm trying to use
ImgLib2 to later on get a RandomAccessible and implement some
N-dimensional algorithms.

Thank you,
Carnë

[1] https://github.com/imagej/imagej-tutorials/blob/master/simple-commands/src/main/java/ComputeStats.java
[2] http://jenkins.imagej.net/job/SciJava-common-javadoc/javadoc/org/scijava/plugin/Parameter.html
[3] http://pastebin.com/ZVt1YsJ0

_______________________________________________
ImageJ-devel mailing list
[hidden email]
http://imagej.net/mailman/listinfo/imagej-devel
Reply | Threaded
Open this post in threaded view
|

Re: get current image when implementing a Command interface

Curtis Rueden
Hi Carnë,

> I open the sample image "blobs" and the plugin will print "8-bit"
> (expected). Then I open the sample "CT" and it prints "16-bit"
> (expected). I then select the blobs image, run it again but get
> "16-bit"

This is a bug in the ImageJ2 legacy layer, responsible for keeping the ImageJ2 data structures in sync with ImageJ 1.x. Could you please file an issue at https://github.com/imagej/imagej-legacy/issues ?

Thank you,
Curtis


On Thu, Aug 14, 2014 at 12:18 PM, Carnë Draug <[hidden email]> wrote:
Hi

I'm trying to write an ImageJ plugin but I'm failing at the most basic
step which I thought would be getting the current image (last selected
image). I am using the @Parameter annotation to get a Dataset and
implementing a Command interface but I'm unsure of what it's
happening. Using:

  @Parameter
  private Dataset dataset;

as suggested on the tutorials [1], seems to use what the image was
when opened. After reading the javadocs [2], I have tried to set
persist to false but go no change.

Please, consider my very small case which should simply print the
image data type [3] (it requires closing the text window after each
call). I open the sample image "blobs" and the plugin will print
"8-bit" (expected). Then I open the sample "CT" and it prints "16-bit"
(expected). I then select the blobs image, run it again but get
"16-bit" (that was a surprise, I guess it's choosing the last opened
image). So I change the CT to 8-bit using "Edit > Type", run the
plugin again but still get back "16-bit" (uh! I have no idea of what's
going on).

I'm probably doing something very stupid as I'm still getting to grips
with java. Could anyone explain to me how to get the current image? I
did found the ImageJ1 getCurrentImage() method but I'm trying to use
ImgLib2 to later on get a RandomAccessible and implement some
N-dimensional algorithms.

Thank you,
Carnë

[1] https://github.com/imagej/imagej-tutorials/blob/master/simple-commands/src/main/java/ComputeStats.java
[2] http://jenkins.imagej.net/job/SciJava-common-javadoc/javadoc/org/scijava/plugin/Parameter.html
[3] http://pastebin.com/ZVt1YsJ0

_______________________________________________
ImageJ-devel mailing list
[hidden email]
http://imagej.net/mailman/listinfo/imagej-devel


_______________________________________________
ImageJ-devel mailing list
[hidden email]
http://imagej.net/mailman/listinfo/imagej-devel
Reply | Threaded
Open this post in threaded view
|

Re: get current image when implementing a Command interface

Carnë Draug-2
On 14 August 2014 21:47, Curtis Rueden <[hidden email]> wrote:

> Hi Carnë,
>
> On Thu, Aug 14, 2014 at 12:18 PM, Carnë Draug <[hidden email]>
> wrote:
>> I open the sample image "blobs" and the plugin will print "8-bit"
>> (expected). Then I open the sample "CT" and it prints "16-bit"
>> (expected). I then select the blobs image, run it again but get
>> "16-bit"
>
> This is a bug in the ImageJ2 legacy layer, responsible for keeping the
> ImageJ2 data structures in sync with ImageJ 1.x. Could you please file an
> issue at https://github.com/imagej/imagej-legacy/issues ?
>

I have just done so [1]. But were all the 3 problems the result of the same bug?

1) it was picking the last opened image instead of last active;
2) it was giving the data type of the image when opened and not the
current data type;
3) running the same plugin on the same image would do no nothing if
the window was still open

Or are these different bugs and I should report them separately?

Also, then how do I use the ImageJ2 libraries to get the current
image? How do I go around to get a RandomAccessible out of an opened
image if I plan to implement an net.imagej.ops.Op that handles ND
images?

Carnë

[1] https://github.com/imagej/imagej-legacy/issues/81

_______________________________________________
ImageJ-devel mailing list
[hidden email]
http://imagej.net/mailman/listinfo/imagej-devel
Reply | Threaded
Open this post in threaded view
|

Re: get current image when implementing a Command interface

Curtis Rueden
Hi Carnë, ​

I have just done so

Thank you!

But were all the 3 problems the result of the same bug?

Probably two separate yet related issues, actually. I wrote up an explanation on the GitHub issue:

Regards,
Curtis


On Fri, Aug 15, 2014 at 8:32 AM, Carnë Draug <[hidden email]> wrote:
On 14 August 2014 21:47, Curtis Rueden <[hidden email]> wrote:
> Hi Carnë,
>
> On Thu, Aug 14, 2014 at 12:18 PM, Carnë Draug <[hidden email]>
> wrote:
>> I open the sample image "blobs" and the plugin will print "8-bit"
>> (expected). Then I open the sample "CT" and it prints "16-bit"
>> (expected). I then select the blobs image, run it again but get
>> "16-bit"
>
> This is a bug in the ImageJ2 legacy layer, responsible for keeping the
> ImageJ2 data structures in sync with ImageJ 1.x. Could you please file an
> issue at https://github.com/imagej/imagej-legacy/issues ?
>

I have just done so [1]. But were all the 3 problems the result of the same bug?

1) it was picking the last opened image instead of last active;
2) it was giving the data type of the image when opened and not the
current data type;
3) running the same plugin on the same image would do no nothing if
the window was still open

Or are these different bugs and I should report them separately?

Also, then how do I use the ImageJ2 libraries to get the current
image? How do I go around to get a RandomAccessible out of an opened
image if I plan to implement an net.imagej.ops.Op that handles ND
images?

Carnë

[1] https://github.com/imagej/imagej-legacy/issues/81


_______________________________________________
ImageJ-devel mailing list
[hidden email]
http://imagej.net/mailman/listinfo/imagej-devel