Total members 10261 | Gratitudes |It is currently Wed May 23, 2012 8:42 am Login / Join Codemiles


All times are UTC [ DST ]




Post new topic Reply to topic  Quick reply  [ 3 posts ] 
Author Question
 Question subject: image processing in java
PostPosted: Thu Oct 23, 2008 1:06 am 
Offline
Proficient
User avatar

Joined: Sun Oct 19, 2008 3:47 pm
Posts: 281
Has thanked: 0 time
Have thanks: 1 time

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,


TOP
 Profile Send private message  
Reply with quote  
 Question subject: Re: image processing in java
PostPosted: Thu Oct 23, 2008 1:07 am 
Offline
Proficient
User avatar

Joined: Sun Oct 19, 2008 3:47 pm
Posts: 281
Has thanked: 0 time
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();
}
}

}


TOP
 Profile Send private message  
Reply with quote  
 Question subject: Re: image processing in java
PostPosted: Fri Apr 29, 2011 12:55 pm 
Offline
Newbie
User avatar

Joined: Fri Apr 29, 2011 12:43 pm
Posts: 1
Has thanked: 0 time
Have thanks: 0 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);
        }


TOP
 Profile Send private message  
Reply with quote  
Post new topic Reply to topic Quick reply  [ 3 posts ] 
Quick reply


  

 Similar topics
 video chat application in java
 Image Insert in Excel File Using POI
 navigating to database using java
 java mobile apps
 need help in java
 Read your gmail using Java code
 image processing
 Java Programing to communicating port parallel
 Java Chat
 Steganography in java

All times are UTC [ DST ]


Users browsing similar posts

Users browsing this forum: No registered users and 3 guests



Jump to:  
Previous Question | Next Question 




Home
General Talks
Finished Projects
Code Library
Games
Tutorials

Java
C/C++
C-sharp
php
Script
JSP/Servlets
Ajax
ASP/ASP.net
Google SEO
Database
Communications
Phpbb3 styles
Photoshop tutorials
Flash tutorials
Find a job






Powered by phpBB © 2000, 2002, 2005, 2007 phpBB Group
All copyrights reserved to codemiles.com 2007-2011
mileX v1.0 designed by codemiles team