lunes, 26 de enero de 2009

Histograma - Java

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

public class Histograma implements PlugInFilter
{
ImagePlus imp;

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

public void run(ImageProcessor ip)
{

int [ ] H = new int [256];
int w= ip.getWidth();
int h= ip.getHeight();
for (int v=0 ; v {
for ( int u=0; u {
int i= ip.getPixel(u,v);
H[i]=H[i]+1;

}
}
ImageProcessor histIp= new ByteProcessor (500,500);
histIp.setValue(255);
histIp.fill();
for( int count=0; count<256; count++)
{
int i=H[count]/75;
for(int j=0;j {
histIp.putPixel(count, j, 0);
}
}
ImagePlus histIm=new ImagePlus ("Histograma", histIp);
histIm.show();
histIm.updateAndDraw();

}

}

No hay comentarios: