Hi Padraig,<div><br></div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left-width:1px;border-left-color:rgb(204,204,204);border-left-style:solid;padding-left:1ex"><br>With a view to moving to imgLib2 and ImageJ2 I have been going through the Javadoc to try to display an image perform more complicated tasks.</blockquote>

<div><br></div><div>We have added a simple tutorial on how to load and display a dataset in ImageJ2:</div><div><br></div><div>    <a href="https://github.com/imagej/imagej-tutorials/tree/master/load-and-display-dataset">https://github.com/imagej/imagej-tutorials/tree/master/load-and-display-dataset</a></div>

<div><br></div><div>You use the IOService to read in a Dataset, which is the data portion of an ImagePlus (no display or UI attached). You can then choose to display that dataset if you want using the DisplayService.</div>

<div><br></div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left-width:1px;border-left-color:rgb(204,204,204);border-left-style:solid;padding-left:1ex"><br>Ideally I would like to use Swing and get a Canvas containing the image and to be able to put this on a JFrame.</blockquote>

<div><br></div><div>We have focused a lot on headless operation so far, so you can create a headless ImageJ context, load a dataset, and create a display for that dataset, all headless. And if you plug in the Swing (or other) UI, the display will be automatically visualized using that interface.</div>

<div><br></div><div>However, thus far, we have not focused on an API for manually working with UI-specific objects such as JPanels. We really need another layer of services for that—in this case, probably a SwingService that can deliver things like SwingDisplayPanels and SwingDisplayWindows on demand.</div>

<div><br></div><div>At the moment you could do something like the following, but there are still bugs:</div><div><br></div><div><div><span class="Apple-tab-span" style="white-space:pre">                </span>final IOService ioService = context.getService(IOService.class);</div>

<div><span class="Apple-tab-span" style="white-space:pre">              </span>final Dataset data = ioService.loadDataset("data.tif");</div><div><br></div><div><span class="Apple-tab-span" style="white-space:pre">           </span>final ImageDisplay display = new DefaultImageDisplay();</div>

<div><span class="Apple-tab-span" style="white-space:pre">              </span>display.setContext(context);</div><div><span class="Apple-tab-span" style="white-space:pre">         </span>display.display(data);</div><div><br></div><div><span class="Apple-tab-span" style="white-space:pre">              </span>final ThreadService threadService = context.getService(ThreadService.class);</div>

<div><span class="Apple-tab-span" style="white-space:pre">              </span>threadService.queue(new Runnable() {</div><div><br></div><div><span class="Apple-tab-span" style="white-space:pre">                        </span>@Override</div><div><span class="Apple-tab-span" style="white-space:pre">                    </span>public void run() {</div>

<div><span class="Apple-tab-span" style="white-space:pre">                              </span>final SwingImageDisplayViewer displayViewer =</div><div><span class="Apple-tab-span" style="white-space:pre">                                        </span>new SwingSdiImageDisplayViewer();</div>

<div><span class="Apple-tab-span" style="white-space:pre">                              </span>final SwingDisplayWindow displayWindow = new SwingDisplayWindow();</div><div><span class="Apple-tab-span" style="white-space:pre">                           </span>displayViewer.view(displayWindow, display);</div>

<div><span class="Apple-tab-span" style="white-space:pre">                              </span>final SwingDisplayPanel displayPanel = displayViewer.getPanel();</div><div><br></div><div><span class="Apple-tab-span" style="white-space:pre">                            </span>final JFrame myFrame = new JFrame("My Frame");</div>

<div><span class="Apple-tab-span" style="white-space:pre">                              </span>myFrame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);</div><div><span class="Apple-tab-span" style="white-space:pre">                              </span>myFrame.getContentPane().setLayout(new BorderLayout());</div>

<div><span class="Apple-tab-span" style="white-space:pre">                              </span>myFrame.getContentPane().add(displayPanel);</div><div><span class="Apple-tab-span" style="white-space:pre">                          </span>myFrame.pack();</div><div><span class="Apple-tab-span" style="white-space:pre">                              </span>myFrame.setVisible(true);</div>

<div><span class="Apple-tab-span" style="white-space:pre">                      </span>}</div><div><span class="Apple-tab-span" style="white-space:pre">            </span>});</div></div><div><br></div><div>And it is certainly not the final API for this layer of functionality.</div>

<div><br></div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left-width:1px;border-left-color:rgb(204,204,204);border-left-style:solid;padding-left:1ex"> </blockquote><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left-width:1px;border-left-color:rgb(204,204,204);border-left-style:solid;padding-left:1ex">

I have gone through the ImageJ2 javadoc and I have found a range of classes that seem relevant such as Defaultdataset, SwingSdiImageDisplayViewer, SwingDisplayPanel but</blockquote><div><br></div><div>We are working on fleshing out the javadoc more, but ultimately tutorials are going to be a better route to learning the system if you don't already have some grounding in the basic ImageJ2 design. There will be some new tutorials in the next few weeks, with many more by the beta5 release in October.</div>

<div><br></div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left-width:1px;border-left-color:rgb(204,204,204);border-left-style:solid;padding-left:1ex"> </blockquote><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left-width:1px;border-left-color:rgb(204,204,204);border-left-style:solid;padding-left:1ex">

I keep running into errors with Services that don't exist because I am probably not using ImageJ2 as intended. </blockquote><div><br></div><div>Those errors are likely due to your classpath configuration. Are you using Maven for managing your project dependencies? If not, for simplicity, you could try using the imagej-2.0.0-SNAPSHOT-all.jar bundle of everything in one JAR; see this FAQ entry for pros and cons:</div>

<div><br></div><div>    <a href="http://developer.imagej.net/faq#n213">http://developer.imagej.net/faq#n213</a></div><div><br></div><div>Regards,</div><div>Curtis</div><div><br></div><div><br></div><div><div class="gmail_quote">

On Mon, Jul 16, 2012 at 3:13 AM, Padraig Looney <span dir="ltr"><<a href="mailto:padraig.looney@gmail.com" target="_blank">padraig.looney@gmail.com</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">

Dear list,<br><br>Apologies if this posting is not in the correct place but I seem to have hit a brick wall in moving to ImgLib2 and ImageJ2.<br><br>I have used ImageJ 1 without the the user interface for a variety of software projects. In Image J to open an Image I would use<br>



<br>Opener opener = new opener();<br>Imageplus imp = opener.openImage("someFile");<br>
 imp.show();<br><br>and from there I could perform the processing and change the display etc. <br><br>With a view to moving to imgLib2 and ImageJ2 I have been going through the Javadoc to try to display an image perform more complicated tasks. So I have found this example among others on the Imglib2 site but in the imgLibs package there is no ImageJFunctions anymore.<br>



<br><code>public</code> <code>< T </code><code>extends</code> <code>RealType< T > & NativeType< T > > Example1b() </code><div>
<code>        </code><code>throws</code> <code>ImgIOException, IncompatibleTypeException</code></div><div><code>    </code><code>{</code></div>
<div><code>        </code><code>// define the file to open</code></div><div><code>        </code><code>File file = </code><code>new</code> <code>File( </code><code>"DrosophilaWing.tif"</code> <code>);</code></div>



<div> </div><div><code>        </code><code>// open with ImgOpener using an ArrayImgFactory, here the return type will be </code></div>
<div><code>        </code><code>// defined by the opener</code></div><div><code>        </code><code>// the opener will ignore the Type of the ArrayImgFactory</code></div>
<div><code>        </code><code>ImgFactory< ? > imgFactory = </code><code>new</code> <code>ArrayImgFactory< T >();</code></div>
<div><code>        </code><code>Img< T > image = </code><code>new</code> <code>ImgOpener().openImg( file.getAbsolutePath(), imgFactory );</code></div>
<div> </div><div><code>        </code><code>// display it via ImgLib using ImageJ</code></div><div>
<code>        </code><code>ImageJFunctions.show( image );</code></div><div> </div><div><code>        </code><code>// open with ImgOpener as Float using a CellImgFactory, it will be opened as float  </code></div>
<div><code>        </code><code>// independent of the type of the image</code></div><div><code>        </code><code>// to enforce to open it as FloatType, an instance of FloatType has to be passed along</code></div>
<div><code>        </code><code>Img< FloatType > imageFloat = </code><code>new</code> <code>ImgOpener().openImg( file.getAbsolutePath(), </code></div>
<div><code>            </code><code>new</code> <code>CellImgFactory< FloatType >( </code><code>10</code> <code>), </code><code>new</code> <code>FloatType() );</code></div>
<div> </div><div><code>        </code><code>// display it via ImgLib using ImageJ</code></div><div>
<code>        </code><code>ImageJFunctions.show( imageFloat );</code></div><div><code>    </code><code>}</code></div>
<br>Ideally I would like to use Swing and get a Canvas containing the image and to be able to put this on a JFrame. I have gone through the ImageJ2 javadoc and I have found a range of classes that seem relevant such as Defaultdataset, SwingSdiImageDisplayViewer, SwingDisplayPanel but I keep running into errors with Services that don't exist because I am probably not using ImageJ2 as intended. <br>



<br>Many thanks <br><span class="HOEnZb"><font color="#888888"><br>Padraig Looney<br>Medical Physicist  <br>Royal Surrey County Hospital<br> <br><br><br><br>
</font></span><br>_______________________________________________<br>
ImageJ-devel mailing list<br>
<a href="mailto:ImageJ-devel@imagej.net">ImageJ-devel@imagej.net</a><br>
<a href="http://imagej.net/mailman/listinfo/imagej-devel" target="_blank">http://imagej.net/mailman/listinfo/imagej-devel</a><br>
<br></blockquote></div><br></div>