Switch to full style
Java2 codes,problems ,discussions and solutions are here
Post a reply

image processing in java

Thu Oct 23, 2008 1:06 am

we r final yr students.currently we r doing our project in image
processing(TAMIL HANDWRITTEN RECOGNITION).the first step is
Digitization of an image.for that image should be converted into 2D
array.help us with an effective java coding for this process,



Re: image processing in java

Thu Oct 23, 2008 1:07 am

I was a student from less than a year, by chance my whole graduation
project was in Java, and using the Java 2D API most of the time.
I got u this code from my project, hope it helps, for any question, or
for the Java files, email me at: mohajami1984 (at) yahoo


Good luck,

Code:
public static void image(){
try {
File f=new File("e:\\asd\\21.bmp");

//read the image into Buffer
BufferedImage imgb=ImageIO.read(f);

//get the image width + height
int imageW=imgb.getWidth();
int imageH=imgb.getHeight();

//define ONE dimsneion arry to read the image into
int imgArr[]=new int[imageW*imageH];

//read all the the pixels info into the array
imgb.getRGB(0,0,imageW,imageH,imgArr,0,imageW);

//NOTE: each element in the array will present: (all in Hex
values)
//1- Transperancy of the color
//2- Red color
//3- Green color
//4- Blue color
//
//example if the color in the image was Lime (between green
and yellow)
//its RGB is (186,255,0)
//the result will look like: FFBAFF00 , where:
//FF mean full opaque
//BA is 186
//FF is 255
//00 is 0

//this loop will show each pixel correspondent Hex value
String out="";
for (int i = 0; i < imgArr.length; i++) {
if (i % imageW ==0) out+="\n";
out+=Integer.toHexString(imgArr[i]).toUpperCase() + "
";
}

javax.swing.JOptionPane.showMessageDialog(null,out);

//the follwoing code fills the array in 2D array
//convert to 2D array
int img2D[][]=new int[imageW][imageH];

for (int x = 0; x < imageW; x++) {
for (int y = 0; y < imageH; y++) {
img2D[x][y]=imgArr[y*imageW+x];
}
}

//printing the new array (should be same as the previous
time)
out="";
for (int y = 0; y < imageH; y++) {
for (int x = 0; x < imageW; x++) {
out+=Integer.toHexString(img2D[x][y]) + " ";
}
out+="\n";
}

javax.swing.JOptionPane.showMessageDialog(null,out);

} catch (IOException ex) {
ex.printStackTrace();
}
}

}


Re: image processing in java

Fri Apr 29, 2011 12:55 pm

Hi i am interested in Image Processing and Previously developed applications with C #
I think also have an error in code i tried this code it's true.

Code:
String filename = File.separator+"tmp";
        JFileChooser fileChooser = new JFileChooser(new File(filename));

        fileChooser.showOpenDialog(mainPanel);

        File file = fileChooser.getSelectedFile();
        try {
            BufferedImage imBuf = ImageIO.read(file);
            int imgW = imBuf.getWidth();
            int imgH = imBuf.getHeight();
            int imgAr[] = new int[imgW*imgH];

            //Bufferede img nin 0-0 dan w - h ye kadar olan kısmın rgb degerlerini alıp
            // imgAr dizisine döndürür;
            imBuf.getRGB(0, 0, imgW, imgH, imgAr, 0, imgW);
            //NOTE:
            //Dizideki elemanların herbir Hex degerleri karsılıgı
            //1- Transparanlık //2- Red  //3- Green //4- Blue

            String out="Naber ibrahim ?";
            out +=" \n"+Integer.toString(imgAr[381]);
            JOptionPane.showMessageDialog(null, out);
            //imgAr[] de tek boyutlu hali bulunuyor dizinin;

            //ConvertTo 2D dimension
            int img2D[][] = new int [imgH][imgW];
            //      row/col           447  382
        //My image Height & Width
            for(int i=0; i<imgH; i++)
                for(int j=0; j<imgW; j++){
                img2D[i][j] = imgAr[j+imgW*i];
                }
                out += " \n"+Integer.toString(img2D[0][381]);
                JOptionPane.showMessageDialog(null, out);
        } catch (IOException ex) {
            Logger.getLogger(ImageProcessingView.class.getName()).log(Level.SEVERE, null, ex);
        }


Re: image processing in java

Mon Jan 21, 2013 9:42 pm




Try this:http://www.codemiles.com/finished-projects/image-viewer-image-processing-filters-noise-enhancements-t639.html


Post a reply
  Related Posts  to : image processing in java
 Image-Viewer-Image Processing-Filters-Noise-enhancements     -  
 image processing     -  
 image processing filters project     -  
 Parsing a Processing Instruction     -  
 thread state when it terminates its processing     -  
 image binarization in java     -  
 crop image in java     -  
 Clip of image in java     -  
 how to compress Bmp image in java...     -  
 Image Scale in java     -  

Topic Tags

Java Image