sábado, 7 de marzo de 2009

Control de Movimiento

import ij.IJ;
import ij.ImagePlus;
import ij.WindowManager;
import ij.process.*;
import ij.gui.GenericDialog;
fgIm = null;
static double alpha = 0.5;
public int setup(String arg, ImagePlus img)
{
return DOES_8G;
}
public void run(ImageProcessor bgIp)
{
if(runDialog())
{
ImageProcessor fgIp=fgIm.getProcessor().convertToByte(false);
fgIp = fgIp.duplicate();
bgIp.copyBits(fgIp, 0, 0, Blitter.DIFFERENCE);
int w=bgIp.getWidth();
int n=bgIp.getHeight();
for(int i =0; i < w; i++)
{
for(int j= 0; j < n; j++)
{
int p =bgIp.getPixel(i,j);
if (p < 150){p=0;
}
else if(p >= 150){p=255;
}
bgIp.putPixel(i,j,p);
}
}
}
}
boolean runDialog()
{
int[] windowList = WindowManager.getIDList();
if (windowList == null)
{
IJ.noImage();return false;
}
String[] windowTitles = new String[windowList.length];
for(int i = 0; i < windowList.length; i++)
{
ImagePlus im = WindowManager.getImage (windowList[i]);
if (im == null)windowTitles[i] = "untitled";
elsewindowTitles[i] = im.getShortTitle();
}
GenericDialog gd = new GenericDialog("Alpha Blending");
gd.addChoice("Foreground image: ", windowTitles, windowTitles[0]);
gd. addNumericField("Alpha value [0. . 1]: " , alpha, 2);
gd.showDialog();
if (gd.wasCanceled())
return false;
else
{
int fgIdx = gd.getNextChoiceIndex();
fgIm = WindowManager.getImage(windowList[fgIdx]);
alpha = gd.getNextNumber ();
return true;
}
}
}

Detector de Movimiento

import ij.IJ;
import ij.ImagePlus;
import ij.WindowManager;import ij.process.*;
import ij.gui.GenericDialog;
import java.awt.*;
import ij.plugin.filter.*;
public class Alpha_Blending implements PlugInFilter
{
magePlus fgIm = null;
static double alpha = 0.5;
public int setup(String arg, ImagePlus img)
{
return DOES_8G;
}
public void run(ImageProcessor bgIp)
{
if(runDialog())
{
ImageProcessor fgIp=fgIm.getProcessor().convertToByte(false);
fgIp = fgIp.duplicate();
bgIp.copyBits(fgIp, 0, 0, Blitter.DIFFERENCE);
int w=bgIp.getWidth();
int n=bgIp.getHeight();
for(int i =0; i < w;i++)
{
for(int j= 0; j < n;j++)
{
int p =bgIp.getPixel(i,j);
if (p <150){p=0;}else>=150){p=255;
}
bgIp.putPixel(i,j,p);
}
}
}
}
boolean runDialog()
{
int[] windowList = WindowManager.getIDList();
if (windowList == null)
{
IJ.noImage();
return false;
}
String[] windowTitles = new String[windowList.length];
for(int i = 0; i < windowList.length; i++)
{
ImagePlus im = WindowManager.getImage (windowList[i]);
if (im == null)windowTitles[i] = "untitled";
elsewindowTitles[i] = im.getShortTitle();
}
GenericDialog gd = new GenericDialog("Alpha Blending");
gd.addChoice("Foreground image: ", windowTitles, windowTitles[0]);
gd. addNumericField("Alpha value [0. . 1]: " , alpha, 2);
gd.showDialog();
if (gd.wasCanceled())
return false;
else
{
int fgIdx = gd.getNextChoiceIndex();
fgIm = WindowManager.getImage(windowList[fgIdx]);
alpha = gd.getNextNumber ();return true;
}
}
}

Detector de movimiento

import ij.IJ;
import ij.ImagePlus;
import ij.WindowManager;
import ij.process.*;
import ij.gui.GenericDialog;
import java.awt.*;import ij.plugin.filter.*;
public class Alpha_Blending implements PlugInFilter
{
ImagePlus fgIm = null;
static double alpha = 0.5;
public int setup(String arg, ImagePlus img)
{
return DOES_8G;
}
public void run(ImageProcessor bgIp)
{
if(runDialog()){ImageProcessor fgIp=fgIm.getProcessor().convertToByte(false);
fgIp = fgIp.duplicate();
bgIp.copyBits(fgIp, 0, 0, Blitter.DIFFERENCE);
int w=bgIp.getWidth();
int n=bgIp.getHeight();
for(int i =0; i < w;i++){for(int j= 0; j < n;j
int p =bgIp.getPixel(i,j);if (p <150)
{
p=0;
}
else if(p>=150)
{
p=255;
}
bgIp.putPixel(i,j,p);
}
}
}
}
boolean runDialog()
{
int[] windowList = WindowManager.getIDList();
if (windowList == null)
{
IJ.noImage();
return false;
}
String[] windowTitles = new String[windowList.length];
for(int i = 0; i < windowList.length; i++)
{
ImagePlus im = WindowManager.getImage (windowList[i]);
if (im == null)windowTitles[i] = "untitled";
elsewindowTitles[i] = im.getShortTitle();
}
GenericDialog gd = new GenericDialog("Alpha Blending");
gd.addChoice("Foreground image: ", windowTitles, windowTitles[0]);
gd. addNumericField("Alpha value [0. . 1]: " , alpha, 2);
gd.showDialog();
if (gd.wasCanceled())
return false;
else
{
int fgIdx = gd.getNextChoiceIndex();
fgIm = WindowManager.getImage(windowList[fgIdx]);
alpha = gd.getNextNumber ();
return true;
}
}
}

UMBRALIZACION

import ij.*;
import ij.process.*;
import ij.gui.*;
import java.awt.*;
import ij.plugin.filter.*;
public class Filter_Umbralizacion implements PlugInFilter
{
ImagePlus imp;public int setup(String arg, ImagePlus imp)
{
this.imp = imp;
return DOES_8G;
}
public void run(ImageProcessor ip)
{
int w=ip.getWidth();
int n=ip.getHeight();
for(int i =0; i < w;
i++){for(int j= 0;
j < n;
j++){int p =ip.getPixel(i,j);
//p = (int)(p*2+50);
if (p < 50){p=0;
}else if(p > =50)
{
p=255;
}
ip.putPixel(i,j,p)
;
}
}
}
}

CONTRASTE

import ij.*;
import ij.process.*;
import ij.gui.*;
import java.awt.*;
import ij.plugin.filter.*;
public class Filter_Contraste implements PlugInFilter
{
ImagePlus imp;
public int setup(String arg, ImagePlus imp)
{
this.imp = imp;
return DOES_8G;
}
public void run(ImageProcessor ip)
{
int w=ip.getWidth();
int n=ip.getHeight();
for(int i =0; i < w;i++)
{
for(int j= 0;
j {int p =ip.getPixel(i,j);
p = (int)(p*2+50);
if (p > 255){p=255;
}
ip.putPixel(i,j,p);
}
}
}
}

katiuska Proaño

Ecualización
import ij.*;
import ij.process.*;
import ij.gui.*;
import java.awt.*;
import ij.plugin.filter.*;
public class Filtro_Ecualizacion implements PlugInFilter
{
ImagePlus imp;
public int setup(String arg, ImagePlus imp){this.imp = imp;
return DOES_ALL;
}
public void run(ImageProcessor ip){int [] vec= ip.getHistogram();
int I=255;
for (int k=1; k< vec.length; k++){vec[k]=vec[k-1]+vec[k];
}
int w=ip.getWidth();
int h=ip.getHeight();
for(int i =0; i < w; i++)
{
for(int j= 0; j < h; j++)
{
int img =(int)(ip.getPixel(i, j));
img=vec[img]*((I-1)/(i*j));
ip.putPixel(i,j,i,img);
}
}
}
}

Filtro de Contraste

import ij.*;
import ij.process.*;
import ij.gui.*;
import java.awt.*;
import ij.plugin.filter.*;

public class Filter_Contraste implements PlugInFilter
{
ImagePlus imp;

public int setup(String arg, ImagePlus imp)
{
this.imp = imp;
return DOES_8G;
}

public void run(ImageProcessor ip)
{
int w=ip.getWidth();
int n=ip.getHeight();
for(int i =0; i < w;i++)
{
for(int j= 0; j
{
int p =ip.getPixel(i,j);
p = (int)(p*2+50);
if (p > 255){
p=255;
}
ip.putPixel(i,j,p);
}
}
}

}