Tue Mar 18, 2008 11:18 pm
Package : EnhancementOpr , includes
/Binirization.java
/Filter.java
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 >> & 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 << | (b << 0);
bi.setRGB(i, j,rgb);
}
bufnew=bi;
}
}
public BufferedImage getImg(){
return bufnew;
}
}
package EnhancementOpr;
import java.io.*;
import java.awt.image.*;
public abstract class Filter {
public abstract BufferedImage filter(BufferedImage image, BufferedImage output);
public BufferedImage filter(BufferedImage image) {
return filter(image, null);
}
public BufferedImage verifyOutput(BufferedImage output, BufferedImage input) {
return verifyOutput(output, input.getWidth(), input.getHeight(), input.getType());
}
public BufferedImage verifyOutput(BufferedImage output, BufferedImage input, int type) {
return verifyOutput(output, input.getWidth(), input.getHeight(), type);
}
public BufferedImage verifyOutput(BufferedImage output, int width, int height, int type) {
if (output != null && output.getWidth() == width &&
output.getHeight() == height && output.getType() == type) return output;
return new BufferedImage(width, height, type);
}
}
Package : imageviewer , includes
/CustomFilter.java
/EdgeDetector.java
/EnhancementPanel.java
/Image_Print.java
/ImageComponent.java
/ImageProcess.java
/Main.java
/noisePanel.java
/RGBFrame.java
/ShowFrame.java
/ViewerFrame.java
/NoiseFilters
/NoiseFilters/NoiseFilter.java
Tue Feb 10, 2009 9:13 am
Wed Feb 11, 2009 12:11 am
Fri Feb 13, 2009 8:47 pm
Sat May 19, 2012 11:01 am
Sat May 19, 2012 11:40 pm
Sun Jan 20, 2013 3:09 pm
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.