Total members 11894 |It is currently Sat Nov 23, 2024 10:46 am Login / Join Codemiles

Java

C/C++

PHP

C#

HTML

CSS

ASP

Javascript

JQuery

AJAX

XSD

Python

Matlab

R Scripts

Weka





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,




Author:
Proficient
User avatar Posts: 280
Have thanks: 1 time

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();
}
}

}



Author:
Proficient
User avatar Posts: 280
Have thanks: 1 time

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);
        }



Author:
Newbie
User avatar Posts: 1
Have thanks: 0 time




Try this:http://www.codemiles.com/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  [ 4 posts ] 

  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 Scale in java     -  
 flip image in java     -  
 java image effects     -  
 image binarization in java     -  
 crop image in java     -  



Topic Tags

Java Image
cron





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