Pixel by pixel

Hi to every one..
m new at j2me and at this forum too... and have started working on face
recognition in j2me..
but for now i want to do a pixel by pixel matching of two images..
can i do it with immutable images? or necessary to do it with mutable ones?
and one more question plz..
if i've displayed the image like this
     image = Image.createImage("/randy_orton.png");
          imageItem = new ImageItem(null, image,
                    ImageItem.LAYOUT_NEWLINE_BEFORE
                    | ImageItem.LAYOUT_LEFT
                    | ImageItem.LAYOUT_NEWLINE_AFTER,null);
          form.append(imageItem);
how can i now get the pixels of it or bytes of this image..
plz gime ur suggestions ..
thanks
a small piece of code with a bit of discription would be of greater help..
thanks in advance,,

i went thorugh that API ahve searched some more things as well.. I have listened about the getRGB() and getPixels methods for it.. If you found a getPixels method, you're looking at the wrong API. I told you to
Read the API for javax.microedition.lcdui.Image
Not any of the classes in java.awt.image.
but dont know how to use those...Do you know what an array is? How to access and assign values of array elements? If not, then go back to basics and go through some tutorials. Start here:
{color:#0000ff}http://java.sun.com/docs/books/tutorial/{color}
db

Similar Messages

  • Can you make a background a random multicolor, pixel by pixel?

    In any basic window, would you be able to color the background, like, a random multicolor? Let me explain...
    Say I have a window that was generated with Java. Typically, this window would have a white background. Instead of that, I'd like the background to be a continuously changing random bunch of colors, pixel by pixel. So, it would be just a giant mess of crazy colors.
    Is there a way to do this? I searched online, but didn't find anything.
    This isn't really important to me, just something I thought would be fun to do.
    ~Dac

    import java.awt.event.*;
    import java.awt.image.*;
    import java.util.*;
    import javax.swing.*;
    import javax.swing.Timer;
    public class TVExample implements Runnable, ActionListener {
        private Timer t = new Timer(10, this);
        private JLabel label;
        private BufferedImage image;
        private Random r = new Random();
        public void run() {
            image = new BufferedImage(100, 100, BufferedImage.TYPE_INT_RGB);
            label = new JLabel(new ImageIcon(image));
            JFrame f = new JFrame();
            f.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
            f.getContentPane().add(label);
            f.pack();
            f.setResizable(false);
            f.setLocationRelativeTo(null);
            f.setVisible(true);
            t.start();
        public void actionPerformed(ActionEvent evt) {
            int x = r.nextInt(image.getWidth());
            int y = r.nextInt(image.getHeight());
            int rgb = r.nextInt(0x1000000);
            image.setRGB(x, y, rgb);
            label.repaint();
        public static void main(String[] args) {
            SwingUtilities.invokeLater(new TVExample());
    }

  • Pixel by Pixel Scan

    Hi all.
    I'm messing around trying to make a simple 2D game. Currently, I have a few sprites on the screen and collision detection working between them. My sprites have transparent backgrounds and the collisions occur when the sprites bounding boxes contact each other but unfortunately this means that things like missiles explode when they hit the bounding box of a ship rather than the ship itself.
    I want to perform a pixel by pixel scan of two sprites once a collision between them has been detected and allow their transparency to overlap until they hit 'solid' color. Basically I want my missile to explode when it hits my ship, not when their two transparent boxes hit each other.
    Anyone have any ideas how I would do this? I've used C++ APIs which have these functions built in but I have no clue as to how to do it in Java. Please help!
    Thanks.

    Heres some code from what I use.
      BufferedImage bi   = new BufferedImage(800, 500, BufferedImage.TYPE_INT_ARGB);
      public static byte[] getAreaCollisions(BufferedImage bi, int minX, int maxX, int minY, int maxY) {
        byte[] collisions = new byte[(maxY - minY + 1) * (maxX - minX)];
        int numCollisions = 0;
        for (int i = maxX; i > minX; i--) {
          for (int j = maxY; j > minY; j--) {
            if (Util.getAlpha(bi.getRGB(i, j)) > 0) {
              collisions[numCollisions++] = 1;
            } else {
              collisions[numCollisions++] = 0;
        if (collisions.length == 0) {
          System.out.println(minX + " " + maxX + " " + minY + " " + maxY);
        return collisions;
      public static int getAlpha(int pixel) {
        return (pixel >> 24) & 0xff;
      }May not be the best code, but it works :)
    CoW

  • Pixel-by-pixel graphics

    I'm working on a bioinformatics project that will use java. My data will be represented pixel-by-pixel, where the color of that pixel will represent of three variables in the dataset. The x and y dimensions are used for two other variables.
    I've been looking through the Java 2D API and tutorials, and there doesn't seem to be a tutorial on pixel-by-pixel specification. Everything seems to be discussing shapes and lines instead.
    In the end, I want a JFrame to pop up, draw the data to the screen, save the graph as a lossless, 8-color picture file, and terminate. Eventually, I hope to have thousands of these files, and I want to animate a change in the data over thousands of generations.
    But first things first... how do I deal with pixel-by-pixel graphics generation?

    g.setRGB(int x, int y, int rgb) where g is the graphics context of a BufferedImage, for example
    buf = new BufferedImage(width, height, BufferedImage.TYPE_INT_RGB);
    Graphics g = buf.getGraphics();
    g.setRGB(x, y, rgb);
    //or//
    g.setRGB(x, y, new Color(r, g, b).getRGB());
    have fun!

  • Is pixel by pixel painting possible in standard MIDP?

    With pixel by pixel painting I mean painting each pixel on the screen instead of using methods like draweline and drawarc. I know that this is possible when using platform specific Java libraries, like Nokias. But is it also possible to do this in standard MIDP, so it works on all Java-enabled mobiles?

    I assume you mean that there is no such method.No, I mean you should look in the api docs to see if there is such a method (but no, there is none)
    I want to make a fullscreen animation. If I did that
    by calling drawline for each pixel, wouldn't that be
    e terribly slow?Well, just try it. Also, you probably don't need to update all of the screen with every frame

  • How to adjust the green (starting) and the red (end) rectangles pixel by pixel (top, bottom, left and right) by changing the number of pixels in ken burns.

    How to adjust the green (starting) and the red (end) rectangles pixel by pixel (top, bottom, left and right) by changing the number of pixels in ken burns. Help please.

    If you look closely at the top of the canvas pane, as you move either of the boxes (green or red) there is an indication of pixel positions... "top, bottom, left, right," and "scale."
    Admittedly, it doesn't seem as if you can "enter" the dimensions with your keyboard, however, as you move the boxes, you have a real time indication of the boxs' locations.
    (I couldn't take a screen shot, as you have to actively move the box with a mouse or other input device... thus, I could not also take a screen shot with same device.)
    I hope this helps.

  • Input to output (pixel by pixel) problems

    I'm at the start of creating a simple plugin. My aim is to put everything from input to output but pixel by pixel. I'm using a CCU example for that, but this causes problems.
    Here's my code:
        PF_EffectWorld *inputP = &params[0]->u.ld;
        PF_Pixel8 *inputPix = (PF_Pixel8 *)inputP->data;
        PF_Pixel8 *outPix = (PF_Pixel8 *)output->data;
        for (int i=0; i<output->height; i++)
            for (int j=0; j<output->width; j++)   
                *outPix++ = *inputPix++;
    My original footage looks like this:
    And after using my code it looks like this:
    After adding the bold line everything works (why do I have to use that line?):
    for (int i=0; i<output->height; i++)
            for (int j=0; j<output->width; j++)   
                *outPix++ = *inputPix++;
            for(int k=0;k<4;k++) inputPix++;
    But when I'm trying to use the plugin again on the same footage it looks like this:
    Am I missing something? What causes that? When I use the callback funcion everything works fine, but I have to do that using the above way 'cause I have to have access to every pixel of the footage.
    Thanks in advance, David

    It is called gutter or row padding, each row may contain more pixel than the actual width. You can check for this with the rowBytes value of inputP.
    The CCU example already compensates for this, so look there for more information:
    in_gutterL        =     (inputP->rowbytes / sizeof(PF_Pixel8)) - inputP->width,
    out_gutterL        =    (outputP->rowbytes / sizeof(PF_Pixel8)) - outputP->width;
    // At the end of each row, account for the gutter
    // (this number can vary by platform and for other reasons)
    if (yL >= 0 && yL < inputP->height){
        bop_inP    += in_gutterL;
    bop_outP += out_gutterL;

  • Help setting the movement to pixel by pixel

    Good day fellow designers. I'm having a "not so good" situation. I hope you can help me guys. It's all about moving an selected object pixel by pixel.
    I have this object selected on photoshop. And I want to move it pixel by pixel. So what I did is I selected it then press the arrow keys. In photoshop,
    usually, this will make the object move pixel by pixel. But in my illustrator however, it's kinda different. It moves at least 3 pixel by 3 pixel. It's not
    accurate. I already tried playing with illustrator's preferences but still no good. I know it's just around there somewhere.
    Maybe someone can help me with this? Thanks and have a good day ahead! Cheers!

    Hmm, I already got that tweaked... But it still skips a few pixels when I move it. A solution that I currently have right now is move it via mouse. It gets
    the job done but the movement via arrow keys helps a lot specially when my workspace is starting to get laggy.
    EDIT :
    I already got it figure out. And yup, it's the keyboard increment. I got used to 1px that I've forgotten that I can also input much lower than 1px. I tried
    0.25px and it worked! : )
    Thanks mate. Cheers! : )

  • Dispay an image pixel by pixel

    Hy! i want to read an image, bmp or jpg and then display it on the screen pixel by pixel....can you help?
    thanks!
    Message was edited by:
    zzirna

    http://forum.java.sun.com/thread.jsp?forum=31&thread=313033
    could prove to be of some interest

  • Cursor ove, pixel by pixel

    I'm a novice at this, so bear with me. In older Macintosh systems there was a program called "Easy Access." At that time, this program allowed for a keyboard function that allowed you to move the cursor pixel by pixel (a benefit for unsteady arthritic hands). The command was: Shift-Command-Clear (from the numeric keypad). Then the zedro key activated this function, and the period key cancelled it. The up and down arrows on the numeric keypad then moved the cursor up or down, and the left and right arrows moved the cursor left or right. does this function still exist, and if so, how do I use it? I may have gotten the older commands mixed up, but would appreciate any help with this.

    I have checked the Universal Access options, but I don't see anyting that specifically relates to what I want to do. I would like to use the up, down, left, and right arrows on the keyboard to move my cursor one pixel at a time in any of those directions. Perhaps I have missed something, but I don't see that capability. any suggestions?

  • Pixel by pixel image manipulation- java

    Hey guys, i need to write a bit of code that looks at 3 images, assesses which pixels in ALL 3 are grey, and then redraws a new image consisting of the old ones, but grey only showing where all 3 have grey.
    The inputs are mays with grey overlays, so therefore the output pixels should be the same UNLESS the pixel was grey in all 3.
    I know its to do with arrays but im not a very good programmer and i need to get this done. Ive written the rest of my program, is anyone able to write this simple code? My problem is that i dont really know how to create an image using an array, plus also i know the pixel colours are stored awkwardly too. Ive only been programming in java for 4 weeks!

    The BufferedImage class is really good at creating images from an array. I don't know what a may is, but if you had an array of integer values in the format {a, r, g, b, a ,r, g, b}, it would be as easy as this:
              BufferedImage b = new BufferedImage(5, 5, BufferedImage.TYPE_4BYTE_ABGR);
              b.getRaster().setPixels(0, 0, 2, 1, new int[] {128, 64, 32, 16, 128, 75, 50, 25});Hope this helps.

  • Scaling two objects to match exactly pixel to pixel.

    I have two art objects on two layers. I want to match to the pixel the two objects that otherwise could be exactly the same but one layered object was imported slightly smaller. The scale tool has good scale handling, I just want to measure the tool spots to the pixel to gain an exact scale size factor and match sizes.

    If they could be the same  size what caused the scale difference. Were the images taken with or different cameras, or different focal length or angle are you sure only the scale is off.  That the perspectives and sizes of the objects are the same. Photoshop has a measure tool just remember perspective, angle, axis all effect the measurements size.

  • Need help!-----How to get pixel from pixel location??

    Hi, I have the location of a pixel (x, y), how to get the pixel value which will be used in DirectColorModel cm.getRGB(int pixel)?
    thanks a lot!!!

    Hi, my image is created by Toolkit.createImage(byte[]). I think I should use PixelGrabber to grab all pixels value to int[], use location(x,y) to get pixel index(y*width+x), then use ColorModel.getRGB(int pixelIndex) to get the rgb value at that location, right? is there any other way to do it?
    thank you.

  • Square Pixels-Rectangle Pixels: Still Confused...

    Ok I've read the manuals. Read the books.
    The whole square pixel thing still escapes me.
    Here's my situation:
    Im working on a project in FC and Im bringing in Quicktime movies exported from Keynote (which since it came from my Mac, it is square pixel), regular DV NTSC footage from my camcorder (which is Rectangular), and Photoshop files (which are square pixel, but could be prepared in the Photoshop preset size designed for inclusion in FC).
    My final out put will be a stand alone Quicktime file which willl be played back on a Mac through a digital projector and it will be put into a DVD using DVD SP or iDVD.
    Given all that, it is hard for me to keep track of what my settings should be for Square Pixel or Rectangular.
    Is it just me or is this hard to understand?

    Thomas,
    I'll take a crack at this since I did something similar about a year back. My first suggestion is to rather play back from the dvd through the projector (in other words don't play the file from the desktop, rather insert the DVD and play that from the laptop.). The projector should compensate for the SQ vs Round (Rectangle) issue as everything is going to be round. (Check the projector settings.)
    You might as well re-format the aspect ration of the PSD files to NTSC DV, as you are going to edit in NTSC (and output a NTSC DVD eventually.) As for the Keynote QT files, I'd first check to see if there is an export setting in Keynote to NTSC DV. Secondly I'd try importing them and see if FCP will render them correctly. And as a last measure you should resize the files using the motion tab. In the FCP manual they describe the exact process of re-sizing. (Sorry I'm not at the edit suite at the moment, so its not on hand.)
    I hope this helps a little.

  • Moyenne pixel par pixel couleur RGB

    Bonjour, je fais un programme labview pour un ''projet'' personnel. Je travaille actuellement sûr une balance à reconnaissance couleur composée d'une camèra, d'une base de données et d'un CompactRIO. 
    Travaillant sûr labview, j'ai acquis une image quelconque et je l'ai traité en couleur RGB mais il me faudrait une moyenne de couleur de tous les pixels en RGB.
    Des solutions à me proposer ? Cordialement Anthony, mercid'avance.

    Avec la fonction "IMAQ ColorImageToArray", c'est un peu brutal mais ça marche :
    When my feet touch the ground each morning the devil thinks "bloody hell... He's up again!"

Maybe you are looking for

  • What is the policy for dead pixel or stuck pixel in apple store?

    Hi, i'm the new mac user here. I never use the MAC. I just bought it 2 day ago at apple store. I'm so happy when i carry it back to my home. When I turn on my macbook, I think to get 1 DOT bad pixel on my screen......Oh..Is it my fault??? I just boug

  • Script to redirect a Application to secondary server if primary server is not available in a .ini file

    Hi Team, I want to write a script in the .ini file of an excel add-in on the users windows system , where if the primary server is not available it should automatically redirect to the secondary server.  Can someone help me in this?

  • I bought the iPhone 6 yesterday and am having connectivity issues

    I bought the iPhone 6 yesterday and over the course of the last 26 hours, I've had issues with my phone connecting to data coverage. I can make phone calls and send texts but my most used apps (Gmail, Facebook, Twitter, even the App Store) won't load

  • TF10175: The team project does not exists

     use visualstudio online for repository. I removed [ProjectName] project from collecection of project After that I got error only on one computer TF10175: The [ProjectName] team project doesnot exist. Any idea to solve this issue ?

  • Mapping multiple tags

    Hi, I am dealing with a mapping challenge. I have my incoming message <address> <name1> A</name1>             (occurrence is 0:1) <street1>ABC Street</street1> <name2>P</name2> <street2>PQR Street</street2> <name100>X</name100> <street100>XYZ Street<