LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Splitting an Array to 4 Quadrants

Hello,
 
I'd like to split a 2D array into 4 Quadrants. The Array's size is 640 by 480 (made from a png graphic) and i would like to search for specific colors in each Quadrant.
So i'd need 4 output Arrays with the coordinates 0-320/0-240, 0-320/241-480, 321-640/0-240 and 321-640/241-480.
 
Has anybody made this before? I have only found functions to split the Array linewise, on the whole width only.
 
Thanks very much for any hints.
andy
0 Kudos
Message 1 of 13
(4,944 Views)
Hello,

That very simple. Use the "array subset,vi". if you see the context help, you can do what you want.
Software developer
www.mcm-electronics.com





PORTUGAL
Message 2 of 13
(4,933 Views)

Thank you! I will have a try this weekend. I thaught the vi you mentioned can only perform horizontal splits. I need to improve my english or get a german context help 🙂

 

0 Kudos
Message 3 of 13
(4,930 Views)
ok. If you need more help (only after you try LOL), I can do you an example. But it's simple... You can do it.

Please Rate the answer.
Software developer
www.mcm-electronics.com





PORTUGAL
0 Kudos
Message 4 of 13
(4,923 Views)
Jorge,
 
Is the array subset.vi good to go X and Y directions in an Array?
I believe it can only return data row by row.
I have tried an array subset with 2 input pairs, set to length 320 from index 0 and 240 from index 0 as i thaught it would be X and Y. But the output doesnt return the data that's in my left top corner.
Either I do something wrong or I didn't describe my problem precisely enough. Imagine you cut a  photo into four same sized pieces, that's what i want to do.
 
thanks a lot.
 
0 Kudos
Message 5 of 13
(4,897 Views)

It seems to work now 🙂

I had 2 faults: Somehow the module only returned zeros when i used %#g as formatting for the "read from spreadsheet file". I used this because i use the same formatting when saving the SSfile. Without a format constant, the module returns my numbers correctly.

The other (fault) was that the subset array module wants Y coordinates on top and X on bottom. I didn't read this anywhere and I thaught it would begin with X.

Thanks very much again.

Message Edited by randerson on 07-12-2007 12:28 PM

0 Kudos
Message 6 of 13
(4,895 Views)

Well, I am not sure why you need to create all these array subset just to search for colors.

Why can't you search in the original array "in place", keeping track of the indices appropriate for the current quadrant of intererst?

(Just curious: How do you search? It might be easiest to flatten to a 1D array and use search 1D array.)

0 Kudos
Message 7 of 13
(4,888 Views)


@randerson wrote:
I'd like to split a 2D array into 4 Quadrants. The Array's size is 640 by 480 (made from a png graphic) and i would like to search for specific colors in each Quadrant.
So i'd need 4 output Arrays with the coordinates 0-320/0-240, 0-320/241-480, 321-640/0-240 and 321-640/241-480.

Also try to get the math straighened out. 🙂

The first element is element [0;0]!. If the array size is 640x480, the highest indices are 639 and 479, respectively. To split it in four quadrants of equal size, you want indices:

  1. 0-319/0-239
  2. 0-319/240-479
  3. 320-639/0-239
  4. 320-639/240-479

Right? 😉

About the search: What do you actually want? (e.g. how many times a color occurs in each quadrant? a list of all indices?)

0 Kudos
Message 8 of 13
(4,876 Views)

Altenbach,

Thank you for your reply. I simply don't know how to search in XY rectangles in the complete array. I didn't even know that it can be done. But the actual solution works fine and is fast, I think i'll keep it that way.

I search 0-320 and 321-639 🙂 I just quickly wrote it in the forum that way. Same for the added picture, thats just "quick trying".

Screenshot added. I just need to determine if any number >0 is present in each quadrant (The Image is the output of a visual inspection, delivering "ok" areas as 0, "dark defect" as 1 and "bright defect" as 2. I just want to make a quick preview showing which corner(s) of the picture contain faults.

The used icons are array subset, array max/min, comparison "bigger that 0" and put out on 4 LEDs.

Great forum, thank you all!

Message Edited by randerson on 07-12-2007 01:41 PM

0 Kudos
Message 9 of 13
(4,878 Views)
sorry, 0-319 and 320-639 is right of course. where was my mind. application is fully corrected now Smiley Surprised
0 Kudos
Message 10 of 13
(4,865 Views)