ContrastAdjuster plugin

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

ContrastAdjuster plugin

Blandine Chanteloup
Hello,

I would like to use the ContrastAdjuster plugin to process an image
displayed in a JFrame.
When the program starts, the image is displayed and the window
corresponding to the Contrastadjuster plugin correctly appears.
But when I''m changing for example the brightness value using the
scrollbar, the image is not changed.

Any idea ???

I'm using the following source code :

public class JFrame_TestImageJPlugin extends javax.swing.JFrame {

        private ij.IJ myImageJ;
        private ij.ImagePlus myImagePlus;
        private ij.gui.ImageCanvas myImageCanvas;

        public static void main(String[] args) {
                JFrame_TestImageJPlugin inst = new JFrame_TestImageJPlugin();
                inst.setVisible(true);
        }
       
        public JFrame_TestImageJPlugin() {
                super();
                initGUI();
        }
       
        private void initGUI() {
                try {
                        setDefaultCloseOperation(WindowConstants.DISPOSE_ON_CLOSE);
                        pack();
                        setSize(400, 300);
                       
                        myImageJ = new ij.IJ();
                        myImageJ.open("image.bmp");
                        myImagePlus = myImageJ.getImage();
                        myImageCanvas = new ij.gui.ImageCanvas(myImagePlus);
                        this.add(myImageCanvas);

                        myImageJ.run("Brightness/Contrast...");

                        myImageCanvas.repaint();

                } catch (Exception e) {
                        e.printStackTrace();
                }
        }
}
Reply | Threaded
Open this post in threaded view
|

Re: ContrastAdjuster plugin

Rémi Cathelin
Hello,
I suppose the control Adjuster does nothing because it doesn't work with
your frame.
The ContrastAdjuster is running on the current displayed image found by
the WindowManager method:
ImagePlus imp = WindowManager.getCurrentImage();

It is probably why in your code,  the B&C don't know your ImagePlus object.
If you want to use the ij B&C, you can modify it in order to apply it on
your own image...

Rémi.

----------------------------------------------
Remi CATHELIN
INRA - SIGENAE Team BP 52627 - 31326 CASTANET-TOLOSAN cedex FRANCE
Phone: 33 (0)5 61 28 55 68
Email: [hidden email]
----------------------------------------------


Blandine Chanteloup wrote:

> Hello,
>
> I would like to use the ContrastAdjuster plugin to process an image
> displayed in a JFrame.
> When the program starts, the image is displayed and the window
> corresponding to the Contrastadjuster plugin correctly appears.
> But when I''m changing for example the brightness value using the
> scrollbar, the image is not changed.
>
> Any idea ???
>
> I'm using the following source code :
>
> public class JFrame_TestImageJPlugin extends javax.swing.JFrame {
>
>     private ij.IJ myImageJ;
>     private ij.ImagePlus myImagePlus;
>     private ij.gui.ImageCanvas myImageCanvas;
>
>     public static void main(String[] args) {
>         JFrame_TestImageJPlugin inst = new JFrame_TestImageJPlugin();
>         inst.setVisible(true);
>     }
>    
>     public JFrame_TestImageJPlugin() {
>         super();
>         initGUI();
>     }
>    
>     private void initGUI() {
>         try {
>             setDefaultCloseOperation(WindowConstants.DISPOSE_ON_CLOSE);
>             pack();
>             setSize(400, 300);
>            
>             myImageJ = new ij.IJ();
>             myImageJ.open("image.bmp");
>             myImagePlus = myImageJ.getImage();
>             myImageCanvas = new ij.gui.ImageCanvas(myImagePlus);
>             this.add(myImageCanvas);
>
>             myImageJ.run("Brightness/Contrast...");
>
>             myImageCanvas.repaint();
>
>         } catch (Exception e) {
>             e.printStackTrace();
>         }
>     }
> }
>
>
Reply | Threaded
Open this post in threaded view
|

Re: ContrastAdjuster plugin

Blandine Chanteloup
In reply to this post by Blandine Chanteloup
It's true the ContrastAdjuster is running on the current displayed image
found by the WindowManager method.

And I think that the ImagePlus I define in my frame corresponds to the
value returned by WindowManager.getCurrentImage() because the histogram
plotted in the B&C window corresponds to the "image.bmp" image ...

Is it possible to add some methods like "update()" rather than modifying
the ImageJ plugin ??


>Hello,
>I suppose the control Adjuster does nothing because it doesn't work with
>your frame.
>The ContrastAdjuster is running on the current displayed image found by
>the WindowManager method:
>ImagePlus imp = WindowManager.getCurrentImage();
>
>It is probably why in your code,  the B&C don't know your ImagePlus object.
>If you want to use the ij B&C, you can modify it in order to apply it on
>your own image...
>
>Rémi.
>
>
>Blandine Chanteloup wrote:
>
>>Hello,
>>
>>I would like to use the ContrastAdjuster plugin to process an image
>>displayed in a JFrame.
>>When the program starts, the image is displayed and the window
>>corresponding to the Contrastadjuster plugin correctly appears.
>>But when I''m changing for example the brightness value using the
>>scrollbar, the image is not changed.
>>
>>Any idea ???
>>
>>I'm using the following source code :
>>
>>public class JFrame_TestImageJPlugin extends javax.swing.JFrame {
>>
>>     private ij.IJ myImageJ;
>>     private ij.ImagePlus myImagePlus;
>>     private ij.gui.ImageCanvas myImageCanvas;
>>
>>     public static void main(String[] args) {
>>         JFrame_TestImageJPlugin inst = new JFrame_TestImageJPlugin();
>>         inst.setVisible(true);
>>     }
>>
>>     public JFrame_TestImageJPlugin() {
>>         super();
>>         initGUI();
>>     }
>>
>>     private void initGUI() {
>>         try {
>>             setDefaultCloseOperation(WindowConstants.DISPOSE_ON_CLOSE);
>>             pack();
>>             setSize(400, 300);
>>
>>             myImageJ = new ij.IJ();
>>             myImageJ.open("image.bmp");
>>             myImagePlus = myImageJ.getImage();
>>             myImageCanvas = new ij.gui.ImageCanvas(myImagePlus);
>>             this.add(myImageCanvas);
>>
>>             myImageJ.run("Brightness/Contrast...");
>>
>>             myImageCanvas.repaint();
>>
>>         } catch (Exception e) {
>>             e.printStackTrace();
>>         }
>>     }
>>}
Reply | Threaded
Open this post in threaded view
|

Multiple Circular ROI

kiran kumar-2-3
Hello group,
 
  I am writing a plugin that needs to generate multiple circular ROI of different coordinates and radius automatically and display all ROI's on the image. I am successfully able to create multiple ROI over an image but unable to display all Circular ROI's over an images.  I have attached my code with this mail. Could anyone help me to find a way out.
 
Thanks,
 
Regards,
Kiran
 
Here is my code
 
public class smart_ implements PlugInFilter {
 ImagePlus imp;     //20
 OvalRoi r1;
 RoiManager x1;
 
 
 public int setup(String arg, ImagePlus imp) {
  //this.imp = imp;
  if (arg.equals("about"))  //30
   {showAbout(); return DONE;}
  return DOES_8G+DOES_STACKS+SUPPORTS_MASKING;
 }
 
 public void run(ImageProcessor ip) {
  IJ.showMessage(" Scanning Microscope Analysis and Resolution Testing ");
   
  GenericDialog gd = new GenericDialog("Select one Method ");
  gd.addCheckbox("Manual Resolution Test ",true);
  gd.addCheckbox("Automeasure Resolution ",false);
  gd.addCheckbox("Resolution from Two Images ",false);
  gd.addCheckbox("S/N Ratio ",false);
  gd.showDialog();
  if(gd.wasCanceled()) {
   IJ.error("PlugIn canceled!");
   return;}
 
  boolean a,b,c,d;
  a = gd.getNextBoolean();
  b = gd.getNextBoolean();
  c = gd.getNextBoolean();
  d = gd.getNextBoolean();
 
  if(a== true & b == true | c == true & d == true | a== true & c == true | a== true & d == true | b== true & c == true | b== true & d == true ) {
  IJ.error("Select only one method ");
  return;}
  else if(a == true)
  Manual_Resolution(ip);
  else if(b == true)
  Automeasure_Resolution(ip);
  else if(c == true)
  TwoImage_Resolution(ip);
  else if(d == true)
  SNR_Calculation(ip);  
       //40
 }
 
 
   public void Manual_Resolution(ImageProcessor ip) {
 
  int PixCount = ip.getWidth();
  double widthum = IJ.getNumber("Enter Image width in um",1.0); /* get input from the user */
  IJ.showMessage("widthum="+widthum);
  double Pixperum = PixCount/widthum;
  double Pixsize = 1000/Pixperum;
  IJ.showMessage("pixsize="+Pixsize);    /* pixel size in nm/pixel */ //50
  Rectangle roi = ip.getRoi();
 
  int centerx = roi.x+roi.width/2;    /* setting center of ROI  */
  int centery = roi.y+roi.height/2;
  IJ.showMessage("xcor"+roi.x);
  IJ.showMessage("ycor"+roi.y);
 
  IJ.doCommand("FFT");
  IJ.wait(100);
    double rfactor = (1000*roi.width)/Pixperum;
  double rUser[] = { 0.1, 0.2, 0.3, 0.5, 0.7, 1, 1.5, 2, 2.5, 3, 4, 5, 7, 10, 20, 30, 50, 70, 100, 150 };  
  IJ.showMessage("FFT is calculated");
 
  /*  Draw the calibration rings */
 
  ImagePlus imp = WindowManager.getCurrentImage();  //70
  ip = imp.getProcessor();
   
  IJ.showMessage("Adjust threshold");
  IJ.run("Threshold...");
  IJ.wait(9000);       //80
  IJ.showMessage("Threshold is done");
   
  for( int m = 1; m<=20; m++) {
  int n = 20 - m;
  int radius = (int) Math.round((500*roi.width)/(Pixperum*rUser[n]));
  if((radius<roi.width/2) & (radius>roi.width/10)) {
   int x1 = (int) roi.width/2-radius;
  int y1 = (int) roi.height/2-radius;
  imp.setRoi( new OvalRoi(x1,y1,2*radius,2*radius,imp));  //90
 
     
  /* Annotate the rings */
 
  double theta = 1.57*(1-Math.random());
  int radX = (int) Math.round(radius * Math.cos(theta)-1);
  int radY = (int) Math.round(radius * Math.sin(theta)-1);  //100
  IJ.showMessage("rUser[]"+rUser[n]);
   
  }
      }
   }


__________________________________________________
Do You Yahoo!?
Tired of spam?  Yahoo! Mail has the best spam protection around
http://mail.yahoo.com