Share on Google+Share on Google+

babu
read image
1 Answer(s)      5 years and 11 months ago
Posted in : Java Beginners

java code to read an image in the form of an array.

Ads

View Answers

May 9, 2011 at 4:22 PM


import java.io.*;
import javax.imageio.*;
import java.awt.image.*;
class ReadImageInArray 
{
    public static int[] getImagePixels(BufferedImage image)
{
    PixelGrabber grabber;
    int[] pixels = new int[image.getWidth() * image.getHeight()];
    try
    {
        grabber = new PixelGrabber(image, 0, 0, image.getWidth(), image.getHeight(), pixels, 0, image.getWidth());
        grabber.grabPixels(0);

    }
    catch (Exception e)
    {
        e.printStackTrace();
    }
    return pixels;
}
    public static void main(String[] args) throws Exception
    {
        File input = new File("C:/rose.jpg");
        BufferedImage image = ImageIO.read(input);
      int array[]=getImagePixels(image);
      for(int i=0;i<array.length;i++){
          System.out.println(array[i]);
      }
    }
}









Related Tutorials/Questions & Answers:
read image
read image  java code to read an image in the form of an array.  ... ReadImageInArray { public static int[] getImagePixels(BufferedImage image...() * image.getHeight()]; try { grabber = new PixelGrabber(image, 0, 0
read an image in java
read an image in java  qns: how we can read an image tell me about its code
Advertisements
JME image read
JME image read  how to display more then one image in jme after reading from nokia 6303 phone. reply me at [email protected]
Read content for JPEG image File in Java - Java Beginners
Read content for JPEG image File in Java  How to Read content for JPEG image File in Java? or Extract text from JPEG image File in Java
image
image  how to add the image in servlet code
Image
Image  how to insert image in xsl without using xml. the image was displayed in pdf..Please help me
Image
Image  how to insert image in xsl without using xml. the image was displayed in pdf..Please help me
Image
Image  how to insert image in xsl without using xml. the image was displayed in pdf..Please help me
image
image   Dear every body please help me how to add and retrive image and video into oracle 11g using jsp
image scrambling
image scrambling  Hi frinds : i want to read image and scrambling it then saved using java any help please
read paragraph
read paragraph  how to read paragraph from one file to another file
Read bufferedreader
Read bufferedreader  Tell me the example of Read file using bufferedreader. Thanks   Read the tutorial Reading file using BufferedReader class. Thanks
PHP Random image, PHP Randomizing image
PHP Random image PHP Random image Tutorial Ever wanted to know how to create... $imgpath = "path/to/image/dir"; $handle = opendir( "$imgpath"... comment the code. $handle = opendir( "path/to/image/dir"
xl read
xl read  hi, i have read excel sheet data using poi api and printed on console, now i have to store the same data which is printed on the console...: Insert excel file data into database Read Excel File
read a file
read a file  read a file byte by byte   import java.io.File; import java.io.FileInputStream; public class ReadFileByteArray { public static void main(String[] args) { File file = new File("D://Try.txt"); try
Read Write
Read Write  Hi; How can I read certain line of say 10 text files and write to one text file   Java Read Multiple Files and store the data into another text file The given code reads all the text files of the directory
read xml
read xml   hi all, i want to ask about how to read an xml in java ME.. here is the xml file <data> <value> <struct> <member> <name> User_Name
Use of Image I/O library
Use of Image I/O library       This section illustrates you how to use Image I/O library. The ImageIO class provides the method to read and write image. We are providing you
Image Steganography
Image Steganography  SOURCE CODE FOR IMAGE STEGANOGRAPHY
image scrolling
image scrolling  A brief description of scrolling image
image format
image format  what are the different format available in image
image format
image format  what are the different format available in image
What is dirty read?
What is dirty read?  What is dirty read
Read RFID data
Read RFID data  how to read RFID data using java
java read file
java read file  Hello i need some help... i want to read an MS Excel file in java so how to read that file
read xml elements
read xml elements  i want read xml data using sax parser in java. but is there any classes or methods to read xml elements
read xml elements
read xml elements  i want read xml data using sax parser in java. but is there any classes or methods to read xml elements
Read file in java
Read file in java  Hi, How to Read file in java? Thanks   Hi, Read complete tutorial with example at Read file in java. Thanks
To scan a image encode that image in j2me
To scan a image encode that image in j2me  Hai team i am new man of j2me i have doubt to scan a image and encode the image in j2me... Please clarify that doubt... Thanks in Advance... Kumar
Image_creation
Image_creation  how to create an image from a set of pixel values stored in array - in java
image in database
image in database  how to set image in database and retrieve it using servlet(java)in msaccess
Tutorials   
Java Spring Hibernate Struts Training What does core Java include? java What are some way to learn Java quickly? Is it required to learn Java before learning Java Script? Is it necessary to learn java script before learning PHP? Are HTML5 and Java Script boosts Java career? Is Java object oriented? Fingerprint application with Java Uninstall Oracle Virtual Box JSON to HashMap Free Java online Training I want example of Control Statement in Java ANSI Color Codes with Python Create a Program that Calculates Input What is difference between JDK,JRE and JVM? How to see ubuntu version on server? How to get Page Source in Selenium (WebDriver) using Java? The path to the driver executable must be set by the webdriver.gecko.driver system property parse data from a link in java Java Program Qns using BlueJ How to fix HAX Kernel Module Is Not Installed error? Installing Audacity Looking for code Logic to check track changes & Coments in MSWord, MSWordx, MSExcel, MSExcelx is ON/OFF Installing JDK on Mac SAX Parser exception ERROR 601 (42P00): Syntax error. Encountered Thread java.lang.NoClassDefFoundError: org/apache/commons/fileupload/FileItemFactory How to install Ubuntu 16.04 LTS? HttpServletRequest cannot be resolved to a type in eclipse - Solved Unhandled event loop exception GC overhead limit exceeded Spring Data jpa with apache phoenix Caused by: java.lang.IllegalArgumentException: Not a host:port pair: PBUF o.a.h.h.z.RecoverableZooKeeper - Possibly transient ZooKeeper, quorum= com.thinkaurelius.titan.diskstorage.hbase.HBaseStoreManager class not found com.thinkaurelius.titan.diskstorage.hbase.HBaseStoreManager not found How to download and install Java 8 on Windows? How to uninstall JDK 7? How to install gtk-doc-tools package in Ubuntu? How to install Oracle JDK 8 on Ubuntu? ejabberd_ctl.beam not found - Solved How to convert date to UTC format in Java? How to install autoconf, automake and libtool in Ubuntu 15.10? How to convert current date to mm dd yyyy format in Java? How to convert current date to dd mm yyyy format in Java? How to stop window closing in "internalFrameClosing" event. How to find list of all index in Neo4j? neo4j-server.properties file location SASLError using PLAIN: not-authorized how to convert war file into .exe file using java code

Ads

 
Advertisement null

Ads