jueves, 26 de febrero de 2009

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 Control_Moviento 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 Filtro_Umbra implements PlugInFilter
{
ImagePlus imp;public int setup(String arg, ImagePlus imp)
{
this.imp = imp;return DOES_8G;
}
public void run(ImageProcessor ip)
{
int f=ip.getWidth();
int c=ip.getHeight();
for(int i =0; i< j=" 0;" pixel ="ip.getPixel(x,y);" pixel="0;">=40)
{
pixel=255;
}
ip.putPixel(x,y,pixel);
}
}
}
}

Ecualizacion de Imagenes

import ij.*;
import ij.process.*;
import ij.gui.*;
import java.awt.*;
import ij.plugin.filter.*;
public class Filtro_Ecua implements PlugInFilter
{
ImagePlus imp;public int setup(String arg, ImagePlus imp)
{
this.imp = imp;return DOES_ALL;
}
public void run(ImageProcessor ip)
{
int []H = ip.getHistogram();
int K1=255;
for (int a=1; a< H.length; a++)
{
H[a]=H[a-1]+H[a];
}
int f=ip.getWidth();
int c=ip.getHeight();
for(int i =0; i < f; i++)
{
for(int j= 0; j < c; j++)
{
int pixel =(int)(ip.getPixel(i, j));
pixel=H[pixel]*((K1-1)/(i*j));
ip.putPixel(i,j,pixel);
}
}
}
}

Trabajo en Clase

import ij.IJ;
import ij.
ImagePlus;
import ij.WindowManager;
import ij.gui.GenericDialog;
import ij.plugin.filter.PlugInFilter;
import ij.process.*;
public class Alpha_Blending implements PlugInFilter{
static double alpha = 0.5; //
ImagePlus fgIm = null; //
public int setup (String arg, ImagePlus imp)
{
return DOES_8G;
}
public void run(ImageProcessor bgIp)
{
if(runDialog())
{
ImageProcesor fgIp= fgIm.getProcessor().convertToByte(false);
fgIm = fgIp.duplicate();
fgIm.multiply(1-alpha);
bgIp.multiply(alpha);
bgIp.copyBits(fgIp, 0, 0, Blitter.ADD);
}
}
boolean runDialog()
{
//get list of open imagesint[]windowList = WindowManager.getIDList();
if(windowList == null){IJ.noImage();return false;
}
String[] windowTitles = new String[windowList.length];
for (int i=0; i < windowList.lenght(); 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;
}
}
}

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 Control_Moviento 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";
else
windowTitles[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;
}

}

}

Umbralización

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

public class Filtro_Umbra implements PlugInFilter
{
ImagePlus imp;

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

public void run(ImageProcessor ip)
{
int f=ip.getWidth();
int c=ip.getHeight();
for(int i =0; i< f; i++)
{
for(int j= 0; j< c; j++)
{
int pixel =ip.getPixel(x,y);

if (pixel <40){ pixel="0;">=40){
pixel=255;
}
ip.putPixel(x,y,pixel);
}
}
}
}

Ecualización

import ij.*;
import ij.process.*;
import ij.gui.*;
import java.awt.*;
import ij.plugin.filter.*;
public class Filtro_Ecua implements PlugInFilter
{
ImagePlus imp;
public int setup(String arg, ImagePlus imp)
{
this.imp = imp;
return DOES_ALL;
}

public void run(ImageProcessor ip)
{
int []H = ip.getHistogram();
int K1=255;
for (int a=1; a< H.length; a++)
{
H[a]=H[a-1]+H[a];
}
int f=ip.getWidth();
int c=ip.getHeight();
for(int i =0; i < f; i++)
{
for(int j= 0; j < c; j++)
{
int pixel =(int)(ip.getPixel(i, j));
pixel=H[pixel]*((K1-1)/(i*j));
ip.putPixel(i,j,pixel);
}
}
}
}

Trabajo en Clase

import ij.IJ;
import ij.ImagePlus;
import ij.WindowManager;
import ij.gui.GenericDialog;
import ij.plugin.filter.PlugInFilter;
import ij.process.*;

public class Alpha_Blending implements PlugInFilter
{

static double alpha = 0.5; //
ImagePlus fgIm = null; //


public int setup (String arg, ImagePlus imp)
{

return DOES_8G;
}

public void run(ImageProcessor bgIp) {
if(runDialog()){
ImageProcesor fgIp
= fgIm.getProcessor().convertToByte(false);
fgIm = fgIp.duplicate();
fgIm.multiply(1-alpha);
bgIp.multiply(alpha);
bgIp.copyBits(fgIp, 0, 0, Blitter.ADD);

}
}

boolean runDialog(){
//get list of open images
int[]windowList = WindowManager.getIDList();
if(windowList == null){
IJ.noImage();
return false;
}

String[] windowTitles = new String[windowList.length];
for (int i=0; i < windowList.lenght(); i++)
ImagePlus im = WindowManager.getImage(windowList[i]);
if(im == null)
windowTitles[i]="untitled";
else
windowTitles[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;
}
}
}

Filtro para Movimiento Imagenes

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 Control_Moviento 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";
else
windowTitles[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;
}

}

}

Filtro para Umbralizar Imagenes

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

public class Umbra implements PlugInFilter
{
ImagePlus imp;

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

public void run(ImageProcessor ip)
{
int f=ip.getWidth();
int c=ip.getHeight();
for(int x =0; x
{
for(int y= 0; y
{
int pixel =ip.getPixel(x,y);

if (pixel <40){
pixel=0;
}else if(pixel>=40){
pixel=255;
}
ip.putPixel(x,y,pixel);
}
}
}
}

Filtro para Ecualizar Imagenes

import ij.*;
import ij.process.*;
import ij.gui.*;
import java.awt.*;
import ij.plugin.filter.*;
public class Ecualizacion implements PlugInFilter
{
ImagePlus imp;
public int setup(String arg, ImagePlus imp)
{
this.imp = imp;
return DOES_ALL;
}

public void run(ImageProcessor ip)
{
int []H = ip.getHistogram();
int K1=255;
for (int a=1; a< H.length; a++)
{
H[a]=H[a-1]+H[a];
}
int f=ip.getWidth();
int c=ip.getHeight();
for(int i =0; i
{
for(int j= 0; j
{
int pixel =(int)(ip.getPixel(i, j));
pixel=H[pixel]*((K1-1)/(i*j));
ip.putPixel(i,j,pixel);
}
}
}
}

Trabajo en Clase

import ij.IJ;
import ij.ImagePlus;
import ij.WindowManager;
import ij.gui.GenericDialog;
import ij.plugin.filter.PlugInFilter;
import ij.process.*;

public class Alpha_Blending implements PlugInFilter
{

static double alpha = 0.5;
ImagePlus fgIm = null;


public int setup (String arg, ImagePlus imp)
{

return DOES_8G;
}

public void run(ImageProcessor bgIp) {
if(runDialog()){
ImageProcesor fgIp
= fgIm.getProcessor().convertToByte(false);
fgIm = fgIp.duplicate();
fgIm.multiply(1-alpha);
bgIp.multiply(alpha);
bgIp.copyBits(fgIp, 0, 0, Blitter.ADD);

}
}

boolean runDialog(){
//get list of open images
int[]windowList = WindowManager.getIDList();
if(windowList == null){
IJ.noImage();
return false;
}

String[] windowTitles = new String[windowList.length];
for (int i=0; i ImagePlus im = WindowManager.getImage(windowList[i]);
if(im == null)
windowTitles[i]="untitled";
else
windowTitles[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;
}
}
}

miércoles, 25 de febrero de 2009

Manejo o manipulaciòn 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 Control_Moviento 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";
else
windowTitles[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;
}

}

}

FILTRO (umbralizacion)

Filtro de Umbralización
import ij.*;
import ij.process.*;
import ij.gui.*;
import java.awt.*;
import ij.plugin.filter.*;

public class Filtro_Umbra implements PlugInFilter
{
ImagePlus imp;

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

public void run(ImageProcessor ip)
{
int f=ip.getWidth();
int c=ip.getHeight();
for(int i =0; i
{
for(int j= 0; j
{
int pixel =ip.getPixel(i,j);

if (pixel <50){
pixel=0;
}else if(pixel>=50){
pixel=255;
}
ip.putPixel(i,j,pixel);
}
}
}

}

FILTRO (Ecualizacion)

Filtro de Ecualización
import ij.*;
import ij.process.*;
import ij.gui.*;
import java.awt.*;
import ij.plugin.filter.*;
public class Equalizacion implements PlugInFilter
{
ImagePlus imp;
public int setup(String arg, ImagePlus imp)
{
this.imp = imp;
return DOES_ALL;
}

public void run(ImageProcessor ip)
{
int []H = ip.getHistogram();
int K1=255;
for (int k=1; k< H.length; k++)
{
H[k]=H[k-1]+H[k];
}
int f=ip.getWidth();
int c=ip.getHeight();
for(int i =0; i < f; i++)
{
for(int j= 0; j < c; j++)
{
int pixel =(int)(ip.getPixel(i, j));
pixel=H[pixel]*((K1-1)/(i*j));
ip.putPixel(i,j,pixel);
}
}
}
}

Umbralizaciòn de imagenes

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

public class Filtro_Umbra implements PlugInFilter
{
ImagePlus imp;

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

public void run(ImageProcessor ip)
{
int f=ip.getWidth();
int c=ip.getHeight();
for(int x =0; x
{
for(int y= 0; y
{
int pixel =ip.getPixel(x,y);

if (pixel <40){
pixel=0;
}else if(pixel>=40){
pixel=255;
}
ip.putPixel(x,y,pixel);
}
}
}
}

Ecualizaciòn de Imagenes

import ij.*;
import ij.process.*;
import ij.gui.*;
import java.awt.*;
import ij.plugin.filter.*;
public class Equalizacion implements PlugInFilter
{
ImagePlus imp;
public int setup(String arg, ImagePlus imp)
{
this.imp = imp;
return DOES_ALL;
}

public void run(ImageProcessor ip)
{
int []H = ip.getHistogram();
int K1=255;
for (int a=1; a< H.length; a++)
{
H[a]=H[a-1]+H[a];
}
int f=ip.getWidth();
int c=ip.getHeight();
for(int i =0; i
{
for(int j= 0; j
{
int pixel =(int)(ip.getPixel(i, j));
pixel=H[pixel]*((K1-1)/(i*j));
ip.putPixel(i,j,pixel);
}
}
}
}

miércoles, 18 de febrero de 2009

Filter_Imagen Doble (Ejercicio Clase)

import ij.IJ;
import ij.ImagePlus;
import ij.WindowManager;
import ij.gui.GenericDialog;
import ij.plugin.filter.PlugInFilter;
import ij.process.*;

public class Alpha_Blending implements PlugInFilter
{

static double alpha = 0.5; //
ImagePlus fgIm = null; //


public int setup (String arg, ImagePlus imp)
{

return DOES_8G;
}

public void run(ImageProcessor bgIp) {
if(runDialog()){
ImageProcesor fgIp
= fgIm.getProcessor().convertToByte(false);
fgIm = fgIp.duplicate();
fgIm.multiply(1-alpha);
bgIp.multiply(alpha);
bgIp.copyBits(fgIp, 0, 0, Blitter.ADD);

}
}

boolean runDialog(){
//get list of open images
int[]windowList = WindowManager.getIDList();
if(windowList == null){
IJ.noImage();
return false;
}

String[] windowTitles = new String[windowList.length];
for (int i=0; i ImagePlus im = WindowManager.getImage(windowList[i]);
if(im == null)
windowTitles[i]="untitled";
else
windowTitles[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;
}
}
}

Alpha Blending

import ij.IJ;
import ij.ImagePlus;
import ij.WindowManager;
import ij.gui. GenericDialog;
import ij.plugin.filter.PlugInfilter;
import ij.Process.*;

public class Aplha_Blending implements PlugInFilter
{
static double alpha = 0.5;
ImagePlus fgIm= null;

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

public void run(ImageProcessor bgIp)
{
if (rumDialog())
{
ImageProcessor fgIP
= fgIm.getProcessor().convertToByte (false);
fgIp= fgIP. duplicate();
fgIp.multiply(1-alpha);
bgIp.multiply(alpha);
bgIp.copyBits(fgIp, 0, 0, Blitter. ADD);
}
}


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”;
else
windowTitles [i] = im.getShortTitle();
}

GenericDialog gd = new GenericDialog(“Alpha Blending”);
gd.addChoice(“Foreground image :”,
windowTitles, windowTitles [0]);
gd. addNumericField(“Alpa value [0..1]:”, alpha,2);
gd.showDialog ();
if (gd.wasCanceled())
return false;
else
{
Int fgIdx = gd.getNexChoiceIndex();
fgIm = WindowManager.getImage ( windowList[fgIdx]);
alpha = gd.getNextNumber ();
return true;
}
}
}

martes, 17 de febrero de 2009

tarea contraste brillo

import ij.*;
import ij.process.*;
import ij.gui.*;
import java.awt.*;
import ij.plugin.filter.*;
public class Filtro_ContrasteBrillo implements PlugInFilter
{
ImagePlus imp;
public int setup(String arg, ImagePlus imp)
{
this.imp = imp;
return DOES_ALL;
}
public void run(ImageProcessor ip)
{
int x=ip.getWidth();
int y=ip.getHeight();
for(int i =0; i
{
for(int j= 0; j
{
int n =(int)((ip.getPixel(i,j))*0.6+1.8);
if(n> 255)
{n=255;}
ip.putPixel(i,j,n);
}
}
}
}

Filtro Contraste Brillo

(Proceso para realiza el contraste y brillo de una imagen)

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