Hi, I am new to Imagej Api, I am trying to zoom in a image in display, but
the image stays the same. I have tried IJ.runPlugIn("ij.plugin.Zoom", "in"), which works, but I want to stick to IJ2. I tried two ways of doing it. one is use ZoomService, another is to use command. here is my code. final ImageJ ij = new ImageJ(); final Dataset dataset = ij.scifio().datasetIO().open("0050000006\\dcm\\0000001.dcm"); ij.launch(args); final ImageDisplay imageDisplay = (ImageDisplay) ij.display().createDisplay(dataset); Context context = new Context(DefaultZoomService.class); ZoomService zoomService = context.getService(DefaultZoomService.class); zoomService.zoomIn(imageDisplay); CommandInfo info = ij.command().getCommand("net.imagej.plugins.commands.zoom.ZoomIn"); ij.command().run(info, true); neither work. Please tell me the standard way of doing it. TY -- Sent from: http://imagej.1557.x6.nabble.com/ -- ImageJ mailing list: http://imagej.nih.gov/ij/list.html |
Hi,
Apologies for the delay in reply. There are a couple of issues with your code: > Context context = new Context(DefaultZoomService.class); Do not make a new Context. Use the one you already haveāit's inside the ImageJ object. Context context = ij.context(); > ZoomService zoomService = context.getService(DefaultZoomService.class); Do not ask for a service by concrete implementation. Just use the interface: ZoomService zoomService = context.service(ZoomService.class); But adjusting both of those things is still unlikely to fix your issue, because the legacy ImageJ user interface is built on ImageJ1, and it's only partially integrated into the ImageJ2 API. So I fear the pure-ImageJ2 approach you are trying to use is doomed to failure at the moment. You need either: A) stick with IJ.runPlugIn("ij.plugin.Zoom", "in"); or B) switch to the Swing UI of ImageJ2. I'd recommend (A) for now, since we don't currently have bandwidth to actively work on or support ImageJ2's Swing UI. Regards, Curtis P.S. Questions about ImageJ2 are best posted on forum.image.sc with the imagej tag, rather than here on the ImageJ(1) mailing list. -- Curtis Rueden Software architect, LOCI/Eliceiri lab - https://loci.wisc.edu/software ImageJ2 lead, Fiji maintainer - https://imagej.net/User:Rueden Have you tried the Image.sc Forum? https://forum.image.sc/ On Tue, Feb 4, 2020 at 6:43 PM rickyxiangzhihai <[hidden email]> wrote: > Hi, I am new to Imagej Api, I am trying to zoom in a image in display, but > the image stays the same. > I have tried IJ.runPlugIn("ij.plugin.Zoom", "in"), which works, but I want > to stick to IJ2. > I tried two ways of doing it. one is use ZoomService, another is to use > command. here is my code. > > final ImageJ ij = new ImageJ(); > final Dataset dataset = > ij.scifio().datasetIO().open("0050000006\\dcm\\0000001.dcm"); > ij.launch(args); > final ImageDisplay imageDisplay = > (ImageDisplay) > ij.display().createDisplay(dataset); > > Context context = new Context(DefaultZoomService.class); > ZoomService zoomService = > context.getService(DefaultZoomService.class); > zoomService.zoomIn(imageDisplay); > CommandInfo info = > ij.command().getCommand("net.imagej.plugins.commands.zoom.ZoomIn"); > ij.command().run(info, true); > > > neither work. Please tell me the standard way of doing it. TY > > > > -- > Sent from: http://imagej.1557.x6.nabble.com/ > > -- > ImageJ mailing list: http://imagej.nih.gov/ij/list.html > -- ImageJ mailing list: http://imagej.nih.gov/ij/list.html |
Free forum by Nabble | Edit this page |