Tech Off Thread

6 posts

Forum Read Only

This forum has been made read only by the site admins. No new threads or comments can be added.

Unit Testing for Image Processing

Back to Forum: Tech Off
  • User profile image
    watermelon

    Hi All Smiley,

    Does anyone know how to do unit testing for image processing? For instance, I have a function for blurring an image but I'm not sure on comparing the expected result with the actual result.

    Cheers,

    watermelon

  • User profile image
    JohnAskew

    Well, why not consider a text-recognition algorithm for images, where the original image has readable text and the expectation is that the blurred image will have im-parsible text.

    Oh, I just made a new word, one I've never heard, and it's synonymically comical; "imparsible!"

    HTH

  • User profile image
    bondsbw

    Compare a correctly blurred copy of the image to your output.  The test passes if they are identical, otherwise it fails.

    I don't believe John's method is good.  If a bug causes the output to be all black instead of a blurred image, the OCR test would pass while a simple byte-by-byte comparison would fail.

  • User profile image
    JohnAskew

    @bondsbw: Text parsing would not be trivial. I'm not sure how one can predict a blurring algorithm's output in advance, but that would be the best approach, I agree. Perhaps one could manually create the expected blurred image and rely on the blurring algorithm to exactly re-produce this image. If the blurring algorithm is not predictable then some other pattern recognition would be required. A unit test for all black should not be difficult if that is a problem. I am not familiar with image blurring codebases or if their output is predictable, fwiw.

  • User profile image
    MasterPi

    Test that the blurred image is not identical to the source, but that the test dimensions are the same.

    Test pixel colors of blurred image are within some strict range of source image. (no random colors were added, e.g)

    You can also do something with subtracting pixels between the images...maybe if abs( image_blur - image_source ) < max_thres the blur was acceptable.

    Computer vision results are really subjective so the tests for the most part will be sanity checks. Testing also depends on how much blurred the image should be is also a major obstacle as there won't be a clear mechanism to map a source image to its blurred counterpart. In general doing something like checking the average pixel color deviation from source to blur might help determine similarity between the images. In fact, define some acceptable percent similarity and use that to assess whether the blur was successful.

     

  • User profile image
    JohnAskew

    @MasterPie: brilliant

Conversation locked

This conversation has been locked by the site admins. No new comments can be made.