Total members 11895 |It is currently Mon Dec 23, 2024 1:30 am Login / Join Codemiles

Java

C/C++

PHP

C#

HTML

CSS

ASP

Javascript

JQuery

AJAX

XSD

Python

Matlab

R Scripts

Weka





java code
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;
}



}


Original project:
finished-projects/image-viewer-image-processing-filters-noise-enhancements-t639.html



_________________
M. S. Rakha, Ph.D.
Queen's University
Canada


Author:
Mastermind
User avatar Posts: 2715
Have thanks: 74 time
Post new topic Reply to topic  [ 1 post ] 

  Related Posts  to : image binarization in java
 crop image in java     -  
 Clip of image in java     -  
 how to compress Bmp image in java...     -  
 Image Scale in java     -  
 flip image in java     -  
 java image effects     -  
 image processing in java     -  
 Image Noise Filter in Java     -  
 Image Custom Filter In Java     -  
 Image Colors Frequencies Histogram in Java     -  



Topic Tags

Java Image






Powered by phpBB © 2000, 2002, 2005, 2007 phpBB Group
All copyrights reserved to codemiles.com 2007-2011
mileX v1.0 designed by codemiles team
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