Example Code

Simple 2D array transformations

Code and Documents

Attachment

Download All

This example was first published in the LabVIEW forum, but I decided to give it a more permanent home here is the Develope Zone Community.

Given a 2D array, there are 8 symmetry related transformations possible:

  • identity
  • vertical flip
  • horizontal flip
  • rotate 180 degrees
  • transpose
  • rotate 90 degrees
  • rotate 270 degrees
  • diagonal flip

(There are probably more scientific words for some of those, but the picture below should show what they mean)

ArrayTranformationsFP.png

Version 1 tries to avoid unecessary extra data copies in memory by doing things in place as much as possible. This is important for performance on large arrays. There is no guarantee that everything is fully optimized, so if you are worried about performance and think you have a better idea, please do some benchmarks and let me know if you found an improvement.

Version 2 uses simpler code at the cost of a few more buffer allocations for the 2D array (let's not count allocations for 1D arrays, they are much smaller). Should be sufficient for typical 2D arrays. To process very large inputs, detailed benchmarking would need to be done to determine the best solution.

Newer LabVIEW versions also support the parallel FOR loop. Some of the transformations are suitable for parallelization, potentially boosting speed. Again benchmarks would need to be done to weight the impact of the parallelization overhead.

Example code from the Example Code Exchange in the NI Community is licensed with the MIT license.

Comments
phmk
Member
Member
on

It would be nice if the Application Software Requirements would state would Labview version the example is written in. That would save me the time to download it and start LV before getting the message that my LV can't open the example.

Paul Kullmann

Pittsburgh

Deirdre
NI Employee (retired)
on

Thanks for the feedback, Paul.  I'll be sure to pass it on to the Web Team.

Deirdre Walsh -- NI Community Manager & Social Media Geek
altenbach
Knight of NI Knight of NI
Knight of NI
on

Curiously, the LabVIEW version is required information when submitting an example, so things are already in place. (or did this just get added?)

Paul, if you have an older LabVIEW version and just want to see the code, click on the quoted LabVIEW forum link on the first line of the description.

Contributors