Login  Register

Re: zooming on a region

Posted by David Hovis on Dec 06, 2007; 7:07pm
URL: http://imagej.273.s1.nabble.com/zooming-on-a-region-tp3697839p3697845.html

You are missing a } somewhere.   You need to copy and paste starting  
from:

import ij.*;

All the way down to the last curly brace }.


--David

On Dec 6, 2007, at 12:44 PM, Younes Leysi Derilou wrote:

> Hello David,
>
> Thanks so much for your help. I followed your instruction, but got  
> an error
> as following. could you please help me more.
>
> Thanks so much and Best Regards,
> Younes
>
> Note: sun.tools.javac.Main has been deprecated.
> C:\MBF_ImageJ\plugins\zoomer_.java:68: '}' expected.
>         sw.setVisible(true);
>                             ^
> 1 error, 1 warning
>
>
>
>
> On Dec 6, 2007 10:51 AM, David Hovis <[hidden email]> wrote:
>
>> That wasn't a macro, it was a plugin.
>>
>> You need to save it in a file called zoomer_.java, and put it in your
>> plugins folder.  You can then use the Plugins->Compile and Run...
>>
>> --David
>> ----------------------------------------
>> David Hovis
>> Senior Research Associate
>> Department of Materials Science
>> Case Western Reserve University
>> [hidden email]
>>
>> On Dec 6, 2007, at 10:44 AM, Younes Leysi Derilou wrote:
>>
>>> Hello Dear Audrey,
>>>
>>> Thanks so much for your nice attention to my email and sending the
>>> macro. I
>>> saved the text as a macro in the IJ macros folder, opened an image
>>> and then
>>> run the macro. it shows an error that ''undefined variable in line 1
>>> <import> ij.*". this comes up either I chose a region or not before
>>> running
>>> macro. sorry i am not good in macro writing. If I put "//" in the
>>> first
>>> line, the same error comes up for the next lines. I would appreciate
>>> it, if
>>> you could let me have a macro that I can run it easily.
>>>
>>> Thanks so much and best regards,
>>> Younes
>>>
>>> On Dec 5, 2007 1:56 PM, audrey karperien <[hidden email]>  
>>> wrote:
>>>
>>>> Hi.  Wayne recently helped me with the below plugin, which I used
>>>> to make
>>>> some animations for a presentation.  It zooms in until the selected
>>>> area is
>>>> the full screen size then you save the stack of images as an
>>>> animation in
>>>> ImageJ.  I have been saving the stack as avi or animated gif files,
>>>> but in
>>>> the code here I slipped in a line that will also save it as an avi
>>>> into the
>>>> ij path, which you can uncomment // IJ.saveAs("AVI... ",
>>>> "myfileZoom.avi")
>>>> and change to save where you want.  For animated gifs, I use the
>>>> gif stack
>>>> writer plugin.  This code zooms from the onscreen image down to the
>>>> selection size, using a gradient set differently each time, which
>>>> is what I
>>>> needed, but Wayne wrote some code that zooms starting with the
>>>> selection and
>>>> the way he did it is smoother and faster, I just haven't fully
>>>> implemented
>>>> it in this yet; you can find it in the list a few weeks back or
>>>> email me and
>>>> I will find it for you. Hope this helps.
>>>>
>>>> import ij.*;
>>>> import ij.gui.Roi;
>>>> import ij.gui.StackWindow;
>>>> import ij.plugin.*;
>>>> import ij.process.ImageProcessor;
>>>>
>>>> public class zoomer_ implements PlugIn {
>>>>
>>>> public int height = 100;
>>>> public int width = 100;
>>>> public int roiheight = 100;
>>>> public int roiwidth = 100;
>>>>
>>>> String NAME;
>>>> public void run(String arg)
>>>>    {
>>>>        ImagePlus img=IJ.getImage();
>>>>        height=img.getHeight();
>>>>        width=img.getWidth();
>>>>        Roi roi = img.getRoi();
>>>>        if (roi==null)
>>>>        {
>>>>            IJ.showMessage("Please select an roi then try again");
>>>>            return;
>>>>        }
>>>>
>>>>        String NAME=img.getTitle();
>>>>        double scale=80;
>>>>        scale=IJ.getNumber("Rate of Scaling (%)?", (double)scale);
>>>>        roiwidth=(int)roi.getBounds().getWidth();
>>>>        roiheight=(int)roi.getBounds().getHeight();
>>>>        int w =(int)( width*(scale/100f));
>>>>        int h = (int)( height*(scale/100f));
>>>>
>>>>        int cx = (int)roi.getBounds().getCenterX();
>>>>        int cy = (int)roi.getBounds().getCenterY();
>>>>       //scale it each time by the same amount
>>>>        //the user determines the amount by
>>>>        //inputting a number for the rate of scaling
>>>>        //e.g., if the rate of scaling is 50,
>>>>        //then the roi is always 50% of the current size
>>>>
>>>>        ImageStack s= new ImageStack(width, height);
>>>>       ImageProcessor ip = img.getProcessor();
>>>>       ip.snapshot();
>>>>       for (int i = w, j = h;
>>>>            (i > roiwidth)&&(j>roiheight);
>>>>            i=(int)( i*(scale/100f)), j=(int)( j*(scale/100f)))
>>>>            {
>>>>                IJ.makeRectangle
>>>>                        (cx-i/2,cy-j/2, i, j);
>>>>                IJ.run("Size...",
>>>>                        "width="+width+
>>>>                        " height="+height+
>>>>                        " constrain interpolate");
>>>>                String name=NAME+i;
>>>>                if(WindowManager.getCurrentImage
>>>> ().getHeight()!=height||
>>>>                        WindowManager.getCurrentImage
>>>> ().getWidth()!=width)
>>>>                IJ.run("Canvas Size...", "width="+width+
>>>>                       " height="+height+" position=Center");
>>>>                s.addSlice(name, img.getProcessor().duplicate());
>>>>                           // WindowManager.getCurrentImage
>>>> ().getProcessor());
>>>>                IJ.run("Revert");
>>>>            }
>>>>        IJ.run("Revert");
>>>>        img.setRoi(roi);
>>>>        StackWindow sw=new StackWindow(new ImagePlus(NAME+"Zoom",
>>>> s));
>>>>        sw.setVisible(true);
>>>> // IJ.saveAs("AVI... ", "myfileZoom.avi");
>>>>
>>>>    }
>>>>
>>>>
>>>> }
>>>>
>>>>
>>>>
>>>> ----- Original Message ----
>>>> From: Younes Leysi Derilou <[hidden email]>
>>>> To: [hidden email]
>>>> Sent: Wednesday, December 5, 2007 7:11:28 AM
>>>> Subject: zooming on a region
>>>>
>>>> Hello ImageJ Users,
>>>>
>>>> I am wondering if there is a pluging to do zooming in/out in an  
>>>> image
>>>> or
>>>> image stack and save this action as a movie.
>>>> any help is highly appreciated in advance.
>>>>
>>>> Sincerely,
>>>> Younes
>>>>
>>