Array to image

I'm making a filter for an image. I used a pixel grabber then played with the array of color it gives. How can I turn back this array into an image without drawing pixel by pixel?

MemoryImageSource
PixelGrabber/MemoryImageSource are part of the old AWT's imaging toolkit. In the Java2D you can reach
down into a BufferedImage and pull out its databank. This lets you change the pixel data in place -- no need
to reconstruct another image. Here's a demo.

Similar Messages

  • How can I convert an array to image(8bit)

    I can convert an array(acquire from usb camera)to a picture,but not images(8 bit grayscale),how can I do it.many thanks!
    Attachments:
    array to image.vi ‏249 KB

    Sorry, this is the kind of thing that happens when you have been out for too long.
    Message Edité par chilly charly le 10-22-2006 11:09 AM
    Chilly Charly    (aka CC)
             E-List Master - Kudos glutton - Press the yellow button on the left...        
    Attachments:
    array%20to%20image[1].png ‏3 KB

  • Please help - I can not create large arrays of images (no more than 108 elements)

    Hello,
    I am working in an application where i acquire 300 high resolution images (3Mp) and then i process each of those frames.
    When i try to put alll those frames in one array of images, the system does not let me more than 108 elements. There is no such message like out of memory or memory error. It is just that when i visualize the array of images, there are good frames the first 108 elements, and then white frames the rest of the elements.
    Ideallically i would prefer to process frames as i am acquiring them, but i am concerned about the remaining processing time for the rest of the tasks.
    Then, as an alternative, I have tried to store frames in two shorter arrays, and i ended up observing that when the first array (say 50 elements) is full and the second array starts (another 50 elements for example), labview needs a certain time in the the middle (like three seconds between closing first array and starting acquiring on the second array). If i dont wait that time between arrays, both arrays contain the same information. I know, this is weird, and i know about the fact of passing information by reference on imaq images. 
    The most interesting thing is that when i reduce considerably the resolution of the image (say that now, instead 3Mp they are 2Mp), the maximum number of elements on the arrays are exactly the same: 108, so this makes me wonder if it is a memory constrain. And the code is fairly simple, there is no way that i am cutting the acquisition at the number 108.
    So my question is, How can i put 300 frames in one just one array? or How can eliminate the time i have to wait between arrays?
    I have heard about memory allocation and so, but i am not sure how to proceed. I have windows 7.
    Thanks in advance,
    Roberto

    It's hard to visualize.  Please post the code - or at least a shell representing your code - so we can see what is happening.  Are you sure you are getting 108 contiguous pictures, or are some aquisitions being skipped?  Is the first picture in the array the first aqcuisition?  Is the last picture the last acquisition?
    I really don't think it is about memory allocation.  I think it could be about your method of acquiring and processing said acquisitions.
    Bill
    (Mid-Level minion.)
    My support system ensures that I don't look totally incompetent.
    Proud to say that I've progressed beyond knowing just enough to be dangerous. I now know enough to know that I have no clue about anything at all.

  • How do you make an array of image icons and then call them?

    How do you make an array of image icons and then call them, i have searched all over the internet for making an array of icons, but i have
    found nothing. Below is my attempt at making an array of icons, but i cant seem to make it work. Basically, i want the image to match the value of the roll of the dice (rollVal)
    Any help would be greatly appreciated, some code or link to tuturial, ect.
    /** DiceRoller.java
    * Roll, print, Gui
    import javax.swing.*;
    public class DiceRoller extends JFrame
         private ImageIcon[] image  ;
         public String[] images = { "empty", "dice1.jpg",
                   "dice2.jpg", "dice3.jpg", "dice4.jpg",
                   "dice5.jpg", "dice6.jpg" };
         public Dice die;
         private int rollVal;
         public int rollNum;
         private JLabel j1;
         public DiceRoller(){
              j1= new JLabel("");
           die =new Dice();
           int rollVal;
           rollVal = die.roll();     
           image = new  ImageIcon[images.length];
         for(int i = 0; i < images.length; i++){
          image[i] = new ImageIcon(images);
         if (image!=null){
              j1.setIcon(image[rollVal]);
         System.out.println("Roll = "+die.roll());

    Demo:
    import java.awt.*;
    import java.net.*;
    import javax.swing.*;
    public class IconExample {
        public static void main(String[] args) {
            EventQueue.invokeLater(new Runnable(){
                public void run() {
                    launch();
        static void launch() {
            try {
                Icon[] icons = new Icon[6];
                for(int i=0; i<icons.length; ++i) {
                    String url = "http://www.eureka-puzzle.be/cast/images/dice" + (i + 1) + ".jpg";
                    icons[i] = new ImageIcon(new URL(url));
                display(icons);
            } catch (MalformedURLException e) {
                throw new RuntimeException(e);
        static void display(Icon[] icons) {
            JPanel cp = new JPanel();
            for(Icon icon : icons) {
                cp.add(new JLabel(icon));
            JFrame f = new JFrame();
            f.setContentPane(cp);
            f.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
            f.pack();
            f.setLocationRelativeTo(null);
            f.setVisible(true);
    }

  • Array to Image Inconsiten​cy

    Hello, 
       I am using labview 10.0 to take images over time and then recording pixel values.  The camera I am using produces a U8 array and I have 2 methods for getting the data:
    1.  I use the labview array tools to select a subset of the U8 array and save it as a txt file.
    2.  I use the arraytoimage VI to convert the output to tiffs which I can then use another program to take line profiles of.
    In theory these two methods should give the same answer, but they don't.  I have attached a VI with the two methods and a picture of the VI comparison.  I have also attached a graph of the signal comparing the two methods.
    In theory the two curves should look the same as they are the exact same pixel, the only difference is that one is straight from the array, and the other was converted to Tiff and then reconverted to an array with Origin 8.  This makes me believe that something is messing up with the array to image conversion, or the saving to a Tiff.  I tried jpg, but that is even worse as jpg has compression.
    If anyone knows how to fix this it would be greatly appreciated.
    Attachments:
    MethodComp.vi ‏12 KB
    MethodComp.JPG ‏34 KB
    MethodCompSignal.jpg ‏1945 KB

    Are you sure that the two different calls to your get image VI are retrieving exactly the same data?
    Try using a single call and branch the data to the two different methods.

  • Null pointer exception- with array of images

    Hi , i am having some problems with my program. I am trying to create an array of images( which i dont really know how to do) and i keep getting this error
    Exception in thread "main" java.lang.NullPointerException
    at DiceRoller.<init>(DiceRoller.java:35)
    at RollDice.main(RollDice.java:19)
    Here is my code, any help would be appreciated, i have switched things around and i still can't figure out what is wrong
    * @(#)RollDice.java
    * RollDice application
    * @author
    * @version 1.00 2009/3/23
    import java.util.Scanner;
    import javax.swing.*;
    import java.awt.*;
    import java.awt.event.*;
    public class RollDice {
        public static void main(String[] args) {
             DiceRoller diceroller  = new DiceRoller();
             //Default Close operations
             diceroller.setDefaultCloseOperation( JFrame.EXIT_ON_CLOSE );
             //Size
            diceroller.setSize( 121, 121 ); // set frame size
            //Dont want anyone to mess with it
            diceroller.setResizable(false); // Cant resize
            diceroller.setVisible( true ); // display frame
    * Dice.java
    //Main dice Class
    import java.util.Random;
    import java.io.*;
    public class Dice
         public      Random r = new Random();
         private int sides;
         private int rolls;
         public int x;
         public Dice()
         Roll method
         public int roll()
              x=0;
              x = (r.nextInt(6)+1);
              return x;
    /** DiceRoller.java
    * Roll, print, Gui
    import javax.swing.*;
    public class DiceRoller extends JFrame
         private ImageIcon[] image = null ;
         public String[] images = { "empty", "dice1.jpg",
                   "dice2.jpg", "dice3.jpg", "dice4.jpg",
                   "dice5.jpg", "dice6.jpg" };
         public Dice die;
         private int rollVal;
         public int rollNum;
         private JLabel j1;
         public DiceRoller(){
           die =new Dice();
           int rollVal = 0;
           rollVal = die.roll();     
           //Images     
           image = new ImageIcon[images.length];
          for(int i = 0; i < images.length; i++){
          image[i] = new ImageIcon(images);
    }//end for
    // setImage(rollVal);
         if (image!=null){
              j1.setIcon(image[rollVal]);
         System.out.println("Roll = "+die.roll());

    max_wallace wrote:
    Do you think you could please elaborate on your answer, and what does borked mean?One of my favourite words that; [b0rked|http://www.urbandictionary.com/define.php?term=b0rked] / borked

  • How to add byte[] array based Image to the SQL Server without using parameter

    how to add byte[] array based Image to the SQL Server without using parameter.I have a column in table with the type image in sql and i want to add image array to the sql image column like below:
    I want to add image (RESIM) to the procedur like shown above but sql accepts byte[] RESIMI like System.Drowing. I whant that  sql accepts byte [] array like sql  image type
    not using cmd.ParametersAdd() method
    here is Isle() method content

    SQL Server binary constants use a hexadecimal format:
    https://msdn.microsoft.com/en-us/library/ms179899.aspx
    You'll have to build that string from a byte array yourself:
    byte[] bytes = ...
    StringBuilder builder = new StringBuilder("0x", 2 + bytes.Length * 2);
    foreach (var b in bytes)
    builder.Append(b.ToString("X2"));
    string binhex = builder.ToString();
    That said, what you're trying to do - not using parameters - is the wrong thing to do. Not only it is insecure due to the risk of SQL injection but in the case of binary data is also inefficient since these hex strings are larger than the original byte[]
    data.

  • Index an array of images only the last image shows

    Hi everyone,
    I try to index an array of images and all but the last element give me the error: "not an image."
    Here is a picture of the vi. The first for loop loads the images and stores them in an auto indexed tunnel. Every diagnostic I ran on this loop showed everything is fine. The second for loop should display the sequence of image stored in the auto indexed tunnel, but it does not. Instead I have the error message that elements 0 to n-1 are not images, and only the last image is displayed.
    What am I doing wrong?
    Thanks for your help.
    and the vi: 
    Solved!
    Go to Solution.
    Attachments:
    PulsedImageDisp1.vi ‏31 KB

    Speed of what? The second loop can't run until the first loop is done, and all the operations are linear. I'm guessing you're referring to the perceived speed of displaying the images one after the other so you don't have to wait for the next image to be read which is why you pre-load all the images. Otherwise, the overall speed should be the same whether you use one loop or two. Actually, to be technically accurate, the two loop version will likely be a little slower overall since LabVIEW has to allocate more memory to store all the images, while in the one loop version it is only ever dealing with one image. If the images are large then you might actually run into a memory issue with the two-loop version (arrays need contiguous memory). Just something to keep in mind and to be careful about.

  • RGB array to Image

    I have a MIDlet that process a image to RGB array, hear is the code:
         int[] imgRgbData = new int[width * height];
         img.getRGB( imgRgbData, 0, width, 0, 0, width, height );
         ByteArrayOutputStream baos = new ByteArrayOutputStream();
         DataOutputStream dos = new DataOutputStream( baos );
         for( int i = 0; i < imgRgbData.length; i++ )
                   dos.writeInt( imgRgbData[i] );
         byte[] imageData = baos.toByteArray();
    after that I send the RGB array to a servlet from the MIDlet, hear is the code:
         con =(HttpConnection)Connector.open("http://" + server + "/" + project + "/addReport");
         con.setRequestMethod(HttpConnection.POST);
         //con.setRequestProperty("User-agent", "Profile/MIDP-2.0 Configuration/CLDC-1.1");
         con.setRequestProperty("Content-Language", "es-ES");
         //con.setRequestProperty("Content-Type", "application/x-www-form-urlencoded");
         con.setRequestProperty("Accept", "application/octet-stream");
         ByteArrayOutputStream baos = new ByteArrayOutputStream();
         DataOutputStream dos = new DataOutputStream( baos );
         dos.writeUTF(tipoReporte);
         dos.writeUTF(usuario);
         dos.writeUTF(comentario);
         dos.writeUTF(direccion);
         dos.writeInt(bin_image.length);
         dos.write(bin_image, 0, bin_image.length);
         byte[] datos = baos.toByteArray();
         con.setRequestProperty("Content-Length", "" + datos.length);
         os = con.openOutputStream();
         os.write(datos);
         os.close();
         dos.flush();
         dos.close();
    Mi problem comes I want to save to SQL Server 2005 database this array like image type using a strored procedure. Exist
    a web aplication in .NET that show this image lika jpeg. I don�t know how to pass the array to the stored procedure.
    I try with setBytes(byte[]) but the web aplication does not dsiplay the image. Then I tried to pass a existing image from my local drive using this:
         File file = new File("c:\\image.jpg");
         FileInputStream fis = new FileInputStream(file);
    and then use:
         cstmt.setBinaryStream(5, fis, (int)file.length());
    That works fine, and the .NET web aplication shows properly the image(jpeg) but I don't know how to proces the rgb array and the pass it to the stored procedure.

    To post code, use the code tags -- [code]Your Code[/code]will display asYour CodeOr use the code button above the editing area and paste your code between the tags it generates.
    db

  • Array of Images

    Can anyone plz help me
    i have to use an array of images here is the source code
    here img[1].source is not working

    img has only one element in your code. img[1] doesn't exist.
    BTW you don't use img[1] in your code, so I am not sure to
    understand your question....

  • Fail to index out images from an array of images!

    Hi all,
    I encountered this problem lately. I am indexing a number of images in an array using a for loop. Next the array of images (16 bit) is used somewhere else in the program; it is indexed and the images are to be processed and displayed. The problem is; when trying to index the images from the arrays using the index array the result is the same image regardless of the index!
    Can anyone explain that for me?
    Thanks in advance
    Solved!
    Go to Solution.

    When you used the IMAQ create VI you specified each image to use the same name of "image".  Each image has to have a unique name.  I edited your VI to give a unique name for each image and I was able to view three different images in three different viewing panes.
    Attachments:
    Image Array Reworked.vi ‏19 KB

  • Pass an array of images???

    I am very new to java and my instructor gave us an assignment of doing a matching game using JButtons and an applet. I have 2 separate .java files (MemoryApplet.java and MemoryGame.java). MemoryApplet intializes the applet and passes an array of images to a method using the following code...
    icon = new MemoryGame();
    for(int i = 0;i<6;i++)
    imgArr[i] = getImage(getCodeBase(),"img" i".jpg");
    icon.setTheIcons(imgArr);
    In the MemoryGame file my setTheIcons method looks like this...
    public void setTheIcons(Image icon1[])
    The problem I am having is that I cannot convert the Image to an ImageIcon to put the image on the JButton. When I passed each image by itself not using an array, it worked fine, but I want to randomize the image locations so I thought passing the array would be the way to go. Any help would be greatly appreciated.
    Thanks, Chad

    If you want to use those images in JButton, so use the ImageIcon arrays like this:
    MemoryApplet
    // declare ImageIcon array
    ImageIcon[] imgArr = new ImageIcon[6];
    for(int i = 0;i<6;i++)
      // create new ImageIcon
      // path: path of images
      imgArr[i] = new ImageIcon(path + "img" + i + ".jpg");
    // initialize MemoryGame instance and call method
    icon = new MemoryGame();
    icon.setTheIcons(imgArr);Hope this help
    Liwh

  • Sending an array of images via web service

    Hi!
    Is it possible to send an array of images using DataHandler[]?
    Thank you!
    Good Day!
    grazieee

    Hi Michael,
    Can I have an example of the JAX-RPC handler method?
    Thank you!!
    Good Day!
    grazieee..
    ================================================================
    "Michael Wooten" <[email protected]> wrote:
    >
    You can return a DataHandler[], but you can't currently pass one to a
    WLS (or WLW)
    web service opertion :-)
    For now, you should consider using a JAX-RPC Handler to achieve the same
    effect.
    Regards,
    Mike Wooten
    "grazieee" <[email protected]> wrote:
    Hi!
    Is it possible to send an array of images using DataHandler[]?
    Thank you!
    Good Day!
    grazieee

  • Load array of images

    Looking for a little direction. I'm trying to load array of
    images into flash and eventually make the image draggable.
    Can anyone point me to a tutorial that can help?
    Thanks

    Looking for a little direction. I'm trying to load array of
    images into flash and eventually make the image draggable.
    Can anyone point me to a tutorial that can help?
    Thanks

  • Want to convert an array to image in gray scale

    i have an image that i have read into the vi. using the draw unflattened pixmap , i have an array of numbers .after some mathematical computations on the array i should be able to convert the array back to the image. how can i convert from array to image.and then from image to gray scale?

    I am not sure what you are doing. Can you post a simple example program?

  • How to change the image into byte and byte array into image

    now i am developing one project. i want change the image into byte array and then byte array into image.

    FileInputStream is = new FileInputStream(file);
    byte[] result = IOUtils.toByteArray(is);
    with apache common IO lib

Maybe you are looking for