简体   繁体   中英

Image Rotation Unit Test

I have a question related to unit test of some image processing algorithms. Take image rotation as an example, in order to perform image rotation, usually we need two parameters: one is the rotation angle and the other is the re-sampling method, and the function that perform image rotation then have the following signature:

void rotate_image(const Image &image, const double rotationAngle, const int rotationMethod, Image &rotatedImage);

Then, how can we design a good unit test framework to test this function? For the time being, the only solution I can figure out is: first obtain the ground truth image (that is, the rotated image with denoted rotation angle and re-sampling method) by using other state-of-art software packages (for example, MATLAB Image Processing Toolbox); after that the rotated image using the implemented function is obtained; finally, the compare the two images. If the absolute sum of the difference image is less than a threshold, then the function passes the unit test. I was wondering whether there are other solutions available to tackle this problem. Thanks.

Some test cases come into my mind:

  1. Create an round image with some data, everything around is black. Rotate it and verify that some parameters eg average rg and b-value are unchanged.
  2. Create a series of rotations, which result in a full 360° rotation, compare to the original.
  3. Rotate a geometric figure (rectangle) and calculate the expected result.
  4. Rotate a centred circle around the centre, expect no change.
  5. Rotate by 90°. Each pixel gets a new position, there should be no tolerance issue.
  6. Rotate an image by +90° and -270°. If you get small difference, there is some unnecessary high precision loss.

Obviously you will have small precision errors in all cases, you have to define a tolerance.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM