Mon May 06, 2013 11:14 pm
package EnhancementOpr;
import java.lang.reflect.Array;
import java.awt.*;
import java.awt.event.*;
import java.awt.image.*;
import java.awt.geom.GeneralPath;
import com.sun.image.codec.jpeg.*;
import java.io.*;
import javax.imageio.*;
import java.awt.image.BufferedImage;
/**
*
* @author sami
*/
public class Binirization {
public static int THRESHABOVE = 255;
public static int THRESHBELOW = 0;
private BufferedImage bufi;
private Raster data;
private DataBuffer datab;
private int width, height;
private int threshold;
private int datav [];
private int datanew[];
private BufferedImage bufnew;
/** Creates a new instance of Binirization */
public Binirization(BufferedImage newimg) {
bufi=newimg;
}
public static int getColor(int b, int g, int r) {
return (int)Math.pow(2,16)*r + 256*g + b;
}
public void setThreshold(int threshold){
this.threshold=threshold;
}
public int getWidth(){
return data.getWidth();
}
public int getHight(){
return data.getHeight();
}
public void DoBinirization(){
width=bufi.getWidth();
height=bufi.getHeight();
BufferedImage bi = new BufferedImage(width, height,bufi.getType());
for(int i=0;i<width;i++) {
for(int j=0;j<height;j++) {
int rgb =bufi.getRGB(i,j);
int r = (rgb >> 16) & 0xff;
int g = (rgb >> <img src="./images/smilies/icon_cool.gif" alt="8)" title="Cool"> & 0xff;
int b = (rgb >> 0) & 0xff;
// Calculate the brightness
if(r>threshold||g>threshold||b>threshold)
{
r=255;
g=255;
b=255;
}
else
{
r=0;
g=0;
b=0;
}
// Return the result
rgb= (rgb & 0xff000000) | (r << 16) | (g << <img src="./images/smilies/icon_cool.gif" alt="8)" title="Cool"> | (b << 0);
bi.setRGB(i, j,rgb);
}
bufnew=bi;
}
}
public BufferedImage getImg(){
return bufnew;
}
}
Codemiles.com is a participant in the Amazon Services LLC Associates Program, an affiliate advertising program designed to provide a means for sites to earn advertising fees by advertising and linking to Amazon.com
Powered by phpBB © phpBB Group.