Compare array of picture

Hi all,
I need some help on these.
A black and white picture (bmp file) is to be opened and let say that the picture is divided into 4 quarters. If as long as there is a white spot on the top left quarter, the program has to be able to identify it as pattern A.   Likewise if there is a white spot on the top right quarter, the program will identify it as pattern B.
Please advise and thank you in advance.
Regards,
Lip Seng

Hi,
It's hard so give a solution without seeing the picture. "Black and white" and "white spots" are open for interpretation. (B&W could be gray, white spots can be different sizes, what is the level of the background noise, how consistent are the picture colors, etc.)
In the simples case (the spots have high intensity level and are of significant size, background have low intensity level, low bg noise level) I'd try this.
First, I'd divide the 2d picture data into 4 separate arrays. Then, get a histogram of each array. Get the amplitude of a representative value, and check it against a value. If it is higher, there must be a white spot.
(Even simpler.. If there is only one pixel against a totally black bg, just use a array max & min, and you instantly have the index of the spot!)
Regards,
Wiebe.
"Lip Seng" <[email protected]> wrote in message news:[email protected]..
Hi all,
&nbsp;
I need some help on these.
&nbsp;
A&nbsp;black and white picture (bmp file) is to be opened and let say that the picture is divided into 4 quarters. If as long as there is a white&nbsp;spot on the top left quarter, the&nbsp;program&nbsp;has to be able to identify it as pattern A.&nbsp;&nbsp; Likewise if there is a white&nbsp;spot&nbsp;on the top right quarter, the program will identify it as pattern B.
&nbsp;
Please advise and thank you in advance.
&nbsp;
&nbsp;
Regards,
Lip Seng

Similar Messages

  • Comparing arrays - help!

    Hello. I've been trying to solve this problem for hours, and I would be most grateful for any help you can give me.
    Basically, I'm trying to compare two arrays of char and tell first how many are the same in the same place (I can do that) and then how many are the same but not in place. However, if there are two of one char in one array, and one of the same char in the other, I only want to count it once.
    The problem is, I can't figure out how to do this. I'm using for loops and then setting the char to 0 if it finds a match. This doesn't work. I tried using a series of if statements but I got weird run time acceptions sometimes, and when I put in more if statements to combat that, 1.) it got too confusing and 2.) still only worked half the time. So I'm back to the for loops.
    Here's what I have:
    for (int j = 0; j<guess1.length; j++){
    for(int k = 0; k<code1.length; k++){
    if(code1[k]== guess1[j]){
    code1[k]=0;
    guess1[j] = 0;
    almost = almost + 1;
    So if the code is BBYG and the guess is BWWY, it should return 1 correct and one almost. It will return the one correct, but then return 3 for the almost. It looks at the B in guess which already returned the correct and find it an almost against both B's. When it should have been set to 0 in the correct for loop.
    Sorry, I ramble a bit. Hope you can help!
    Thanks.

    You're gonna love this.
    Unless you have some annoying and patently backward lecturer who wants you to everything the hard way then get ye nose into:
    1. the Collections framework.
    http://java.sun.com/docs/books/tutorial/collections/index.html
    2. and the Collections class itself.
    http://java.sun.com/javase/6/docs/api/java/util/Collections.html
    Hint: a Map can be used to find the distinct items in a list.

  • Compare arrays

    Hello all, I am new to labview and i am trying to compare two arrays to see if they are equal. What i am trying to do is read cell values from excel and move them into an array. Then i would like to compare that array with a constant array in my labview program. Any help is greatly appreciated.

    Do attention with the "aggregates" function.
    Comparing two arrays, for example 3,2,1,0 and 3,2,1 gives "different"
    When comparing if all values in an array are zero, the dimension must also be right !
    So before comparing the values, I compare the length, causing an error if unequeal.
    In my case, compare if everything is zero, I use the "Array max&min" function. (Max<>0 and Min <>0)
    Message Edited by ST5 on 08-11-2009 05:00 AM

  • Array of picture controls and zoom factor

    Is it possible to set different zoom factors for the elements of an array of 2D picture controls?
    Ben64
    Solved!
    Go to Solution.

    No.  Zoom factor, like almost all properties of array elements, is the same for all elements.

  • How to compare array of String with column of a table

    Hi,
    i have a array of string(say array is of length 1000). I want to
    compare those string in array with one table column
            - whether that table column has a string
                            if yes
                                            do nothing.
                            if no
                                            then insert that string into table.
            - whether table has obsolete row i.e, the one present in table and
    not in array
                            then delete that row.
    How do i go about this, because i see, it is not feasible to loop
    through array and search table to find new string OR loop through each
    row from table to find some obsolete row
    How can i accomplish this task more feasibly(without running query for
    each string, for comparission)? Is there any way to find this kind of
    problem. I would have been easy if i had to compare two tables(with
    UNION and INTERSECT), but it is not the case.
    thanks,
    kath.

    I'm not sure, whether I understand your problem correctly. Only two comments:
    - if both arrays are sorted, all can be done running exactly once simultaneously through both arrays.
    - if the column is marked as UNIQUE, all column strings will be different. I.e. you cannot insert the same string a second time.
    Regards  Thomas

  • Comparing array elements for equality

    Hi
    I have written a simple program that works as a lottery number predictor. It works fine except for the fact that sometimes 2 numbers will be the same. Does anyone know of a method that compares an array element to the others to test for equality?

    ok I've had a go at implementing a solution. I worked it out on paper so I haven't tested it yet in the program. Let me know if you can see any errors that I can't.
       boolean numNotSame = true;
       int[] lottery = new int[5];
       int currentNumber;
       start:  //label to return to if 2 numbers are the same
       while(numNotSame){
          for( int j = 0; j < lottery.length; j++){
              currentNumber = 1 + randomNumbers.nextInt(34);   //get random number
              for( int i = 0; i < lottery.length; i++){
                 if( currentNumber == lottery)
    continue start; //if numbers are the same begin again
    } //end inner for
    lottery[ j ] = currentNumber; //set array element if number not used yet
    } //end outer for loop
    numNotSame = false; //set false so while loop will end
    } //end while block

  • Comparing array members

    i cant solve the 2nd part of this prob (found in this forum):
    // Generate lottery numbers (from 1-49)
    // Print number of occurrences of each number
    public class Lotaria {
         public static void main(String[] args) {
              int x = 1;
              int p = 1;
              int s = 1;
              int n = 1;
              int[] loto = new int[49];    // n?s do loto
              // Generating lottery numbers (from 1-49)
              for ( n = 0; n < 49; n++ ) {
                   loto[n] = (int)(Math.random() * 49 + 1);
                   System.out.println(loto[n]);
              for ( p = 0; p < loto.length; p++ ) {
                   for ( s = 0; s < loto.length; s++ ) {
                        if ( loto[p] == loto[s] ) {
                             x++;
                             System.out.println(loto[p]
                                              + " ocorre " + x + " vezes");// prints nonsenses
    }looks like (inside the if) i'm comparing every array element to all the others and then counting each repetition...
    can someone sort me out of this, or at least give me an hint? (pls dont ask for interfaces)

    I did it!
    // Generate lottery numbers (from 1-49)
    // Print number of occurrences of each number
    public class Lotaria {
         public static void main(String[] args) {
              int x = 0;
              int p = 1;
              int s = 1;
              int n = 1;
              int[] loto = new int[49];
              // Generating lottery numbers (from 1-49)
              for ( n = 0; n < 49; n++ ) {
                   loto[n] = (int)(Math.random() * 49 + 1);
                   System.out.println(loto[n]);
              for ( p = 0; p < loto.length; p++ ) {
                   for ( s = 0; s < loto.length; s++ ) {
                        if ( loto[p] == loto[s] ) {
                        x++;
              System.out.println(loto[p] + " ocorre " + x + " vezes");
              x = 0;
    }i think the 3rd loop (my original idea) can be more elegant but right now i cant cope with it
    the secret was in resetting "x"!...
    thanks to both for helping me

  • Array to picture

    Hi all
    How can I convert 8 bit array to B&W picture?
    Regards
    Iskander
    Attachments:
    8_array to picture.vi ‏284 KB

    Thanks all
    I want to receive B&W image from array.
    Ireceived color image.
    Regards
    Iskander
    Attachments:
    Image to picture.vi ‏144 KB

  • Comparable array

    Hi,
    point of intrest as was looking in a book and one of the excercises was to make a generic storage array
    if I have the following
    private Comparable[]  list; and want to add and sort generic objects to this is there anyway I can use either Collections.sort or Arrays.sort, without implementing comparable (I know how to do it this way fine ie having two objects over riding compareTo)
    Am I missing a trick?
    Thanks in advance
    .

    You can use Collections.sort and Arrays.sort with a
    Comparator. Then you don't have to implement
    Comparable.Good point. But it'd be tough to write a Comparator for a "generic" object. If you wanted to compare hash codes or string values it'd be okay, I guess...

  • Compare Array

    I need to compare 2 array tokens to see if they are the same or not.
                if //insert missing code here
                    // Destination identical to origin.
                    error = true;
                    System.err.println("Destination identical to origin. - " + line);
                }The two array tokens are tokens[2] and tokens[3]
    Do you need to use something like "compareTo" or something?? I tried using "if (tokens[2] == tokens[3])" but it still won't work.
    HALP!!!

    It is explained at the method description at the java.lang.String API: http://java.sun.com/javase/6/docs/api/java/lang/String.html

  • Compare Array in Conbination

    How to compare two arrays and find same combinations?

    The correct function to use in column E to solve this problem is dependent on the data that will be in columns F-H. I assumed those columns would contain numbers between 0 and 999999
    Formula in E2 =IF(ISERROR(MATCH(A$2,F2:H2,0)+MATCH(B$2,F2:H2,0)+MATCH(C$2,F2:H2,0)),0,999999)
    Formula in D2 =COUNTIF(E,999999)
    Fill color for A2 through D2 was hand selected, not conditional.
    Conditional format for F2-H2 is "if less than E2 then green fill". Similar conditional format for the remaining rows. If you set this up before putting in the numbers, you can fill the format to the other rows. If you do it later, you can Copy Style/Paste Style to the other rows then change E2 to E3, E4, etc. as you go.

  • 2D array to picture

    Hye
    On labview application, I would like make 2Darray [X,Y] to BMP or JPG file, Does someone could help me?
    Thanks

    May be the attached vi is the right solution ?
    1/ convert array to pict string using the Flatten Pixmap.vi
    2/ display as pict (Draw Flattened PixMap.vi) & save as JPEG (write JPEG file.vi)
    Chilly Charly    (aka CC)
             E-List Master - Kudos glutton - Press the yellow button on the left...        
    Attachments:
    Array to JPEG.vi ‏29 KB

  • How can i make a visible array of pictures?

    Hello.
    Well, my current problem is that i want to make some kind of array with an image in each case.
    I have tried something like that:
    import java.awt.*;
    import java.awt.Image;
    import java.awt.Graphics;
    public class Terrain extends java.applet.Applet
         GridLayout terrain = new GridLayout(15,26);
         Image sol;
         Container c01_01;
         Container c02_01;
         public void init()
              sol = getImage(getCodeBase(),"terrain.gif");
              c01_01 = new Container();
              c02_01 = new Container();
              setLayout(terrain);
              add(c01_01);
              add(c02_01);
         public void paint(Graphics toto)
              toto.drawImage(sol,0,0,c01_01);
              toto.drawImage(sol,0,0,c02_01);
    but the "paint" method draws all the containers at the same position.
    Can someone help me to display a image in each case of the gridlayout, please?
    Thanks by advance!
    Ciao!

    OK, so I lied. Here is the code:
    FieldOfImages contains a matrix of images.
    import java.awt.Graphics;
    import java.awt.Image;
    import java.awt.Toolkit;
    import javax.swing.JComponent;
    public class FieldOfImages extends JComponent
      protected int width,height; // dimensions of the field     
      protected byte[][] field; // the field itself
      protected Image[] tiles; // the tiles for use on the field
      protected int howManyImages; // how many tiles there are
      public FieldOfImages(int w,int h,String[] images)
        super();
        // create the image array
        howManyImages = images.length;
        tiles = new Image[howManyImages];
        // gets the images
        for(int i=0;i<howManyImages;i++)
          tiles[i] = Toolkit.getDefaultToolkit().getImage(images);      
    // create the field matrix
    width = w;
    height = h;
    field = new byte[width][height];
    // fill with random values
    for(int row=0;row<height;row++)
    for(int col=0;col<width;col++)
         field[col][row] = (byte)(Math.random()*howManyImages);
    public void paintComponent(Graphics g)
    super.paintComponent(g);     
         for(int row=0;row<height;row++)
         for(int col=0;col<width;col++)
         byte whichImage = field[col][row];
         int x = col*32; // here I am assuming that the images are
         int y = row*32; // ALL 32x32.     
         g.drawImage(tiles[whichImage],x,y,null);     
    FieldOfImagesApp demonstrates the usage of FieldOfImages.
    import javax.swing.JFrame;
    public class FieldOfImagesApp
      * The application entry point.
      * @param args the command line arguments.
      public static void main(String[] args)
        // Create a JFrame for displaying the field.
        JFrame frame = new JFrame();
        frame.setTitle("Field of Images");
        // Add to the JFrame's ContentPane an instance of FieldOfImages, which
        // will contain the images.
        String[] images = {"D:/rafael/icons/tile1.jpg", "D:/rafael/icons/tile2.jpg",
                        "D:/rafael/icons/tile3.jpg", "D:/rafael/icons/tile4.jpg", };
        frame.getContentPane().add(new FieldOfImages(20,10,images));
        // Set the closing operation so the application is finished.
        frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
        frame.setSize(300,300); // adjust the frame size.
        frame.show(); // show the frame.
      }Problems are:
    - Image loading is not tracked - should use a MediaTracker for this.
    - Preferred, minimum and maximum size of the JComponent could be easily set with the images' dimensions and tile matrix dimensions.
    - Code is not commented enough :-)
    hope it helps
    Rafael

  • Comparing Array

    Hello,
    can you plz help me.
    i am checking two array.
    var temItemNo_array:Array = Array(12,13,17,19,20);
    var Item_array:Array = Array(12, 13, 14, 15, 16, 17);
    when checked [B]temItemNo[/B] &&  [B]Item_array[/B] in this arrays 12,13 are same no.
    but when 12 & 13 got continuous common no. that time want stop on 13 no and add on 13+1=14
    Thanks
    JaxNa

    if there are 2 common elements that are adjacent integers then i want next integer
    if 12 & 13 are 2 common element that are adjacent then i want next integer is 14.
    one more example
    if 17& 18 then i want  next integer is 19.
    Thanks a lot kglad

  • Convert arrays of picture into JPEG string

    Hiya, 
    I have constructed a procedure to carry out some intensity analysis for my experiment.  I have chosen to use snap instead of grab, as I only need to acquire and analyse images in every 2-30 secs (low level acquisition).  I have created a time cycle for each snap shot.  However, I could not save my images, as every 30sec the process will stop and the error will occur.  At the moment, I have connected the picutre to an AVI create.vi, everytime I run the vi, an error occurs. 
    I would like to save all my images into the same directory without using grab and without LABVIEW asking me the file name every time I want to save an image.  I would be the most appreciated if someone could help me with the problem please??
    Attachments:
    Nearlyfinishcam15.vi ‏263 KB

    hello,
    Maybe this is not what you want. But if you wanna a way  of saving your snaps to a directory you can do a simple thing as simple as I show you in the pic attached. You just have to but that inside a case that's true in the period that you want. And then you connect something to the "pic number" control in order to give different names for every snap.
    I don't have time to analyze you .vi. But I think that it's very complicated. And worst than that it's that maybe not very well programmed and you might have some problems. You have several parts of the code that you don't garanty Dataflow. Pay attention to that.
    This it's only a few ideas.
    Best regards,
    Software developer
    www.mcm-electronics.com
    PS: Don't forget to rate a good anwser ; )
    Currently using Labview 2011
    PORTUGAL
    Attachments:
    save pics.jpg ‏28 KB

Maybe you are looking for