09-08-2008 08:23 PM
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.
09-08-2008 08:50 PM
09-08-2008 09:01 PM
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.)
09-08-2008 10:57 PM
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?
09-08-2008 11:18 PM
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.
09-08-2008 11:51 PM
Have a look at this old thread.
For example, my code for a 180 degree rotation (image below) might be more efficient:
Are you arrays square or rectangular. For square arrays, more optimizations are probably possible.
09-09-2008 12:27 AM
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
09-09-2008 10:23 AM - edited 09-09-2008 10:24 AM
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.
09-09-2008 09:49 PM
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.
01-09-2009 05:38 PM
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. 😉