LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

2D array (image) orientation (suggestion for simpler method)

I try to, output as many different orientation as I could think of in this VI. Each of the output may be a desired output depending on my requirements.

One possible way for me is to create a case structure for each orientation.

 

The problem is that I will have to rotate and transpose the image a number of times to get some of the desired outputs.

Is there a simpler way of doing this? Rotating and tranposing the image a number of times might be computationally intensive of bigger arrays especially image arrays.

 

 

0 Kudos
Message 1 of 19
(9,573 Views)
You will definitely want to put each case in a case structure, otherwise you will have many copies of your array made unncessarily, with large arrays this could be a serious hit on memory.
Message 2 of 19
(9,565 Views)

For rotating 90 degrees counter-clockwise, since it is an inverse operation from rotating 90 degrees clockwise, why not flip the array in the loop then transpose (reverse order of operations).  It should be a lot less time consuming then doing 3 90 degree clockwise rotations.

 

Another possibility would be to figure out where each element remaps to from the old array to the new array.  Create a pair of nested for loops to calculate the matching arraying indices for each type of operation and iterate through the elements and swaps the corresponding pairs.  The trick will be making sure that your stop conditions are just right so that you touch each element of the array only once (otherwise you'll wind up swapping everything back or really scrambling things up.)

Message 3 of 19
(9,562 Views)

yes i definitely want to put them in a case structure. this picture is merely for the sake of illustration.

 

I tried reversing the order of the operation before but it does not have any impact on the output.

 

mapping seem plausible but again there might just be something simpler.

 

Do you people think this is a common problem in Labview? or maybe image processing?

0 Kudos
Message 4 of 19
(9,542 Views)

Are you sure that reversing the transpose with the flip 1D array loop didn't rotate it the other way?

 

I don't have your VI,  but I created a small scale array with distinctive values  (LV8.5_, then ran the operations each way.  One looks like it is rotated clockwise, the other counter clockwise.

 

I figured mapping would be 1 way to manipulate the array just once, but whether it would be any quicker than what you are doing, I don't know.  You could use the In Place structures added to LV 8.5 to save from making extra memory copies of the array.  One thing I realized later on is that for a rotation, you aren't just swapping pair of pixels, but swapping among 4 of them up.  This would complicate the calculation of the pixel groups to swap that much more complicated.

 

I think this kind of problem (rotating, flipping of data arrays) would be a common problem in image processing.  Not so much in general LabVIEW.

Message 5 of 19
(9,539 Views)

Have a look at this old thread.

 

For example, my code for a 180 degree rotation (image below) might be more efficient:

rotate 180 degrees

 

Are you arrays square or rectangular. For square arrays, more optimizations are probably possible.

 

 

Message 6 of 19
(9,530 Views)

my bad. your suggestion for the anticlockwise is correct. i think i saw the wrong output. i will also take into consideration the 180 rotation. thanks

0 Kudos
Message 7 of 19
(9,522 Views)

Here are some ideas that might be more efficient, but you should test for yourself. No guarantees. 😉

 

How big are your arrays? I am sure improvements are possible.

 

Message Edited by altenbach on 09-09-2008 08:24 AM
Download All
Message 8 of 19
(9,491 Views)

neat. will definitely test them out myself. my images are pixel arrays of about 640 by 480. i figure these might be useful for processing other large arrays too.

0 Kudos
Message 9 of 19
(9,472 Views)

Yes, the algorithms are casually optimized for large dataset and operations are carried out in-place as much as possible.

 

I have not done any formal bechmarking, but if you want to do things differently, make sure to see if you get any speed or memory penalty. There are many ways to do all this. You are encouraged to optimize the code even more. 😉

0 Kudos
Message 10 of 19
(9,269 Views)