4
$\begingroup$

I've been experimenting with various methods to detect defects in printed images. Features that are qualified as defects may include scratches, discoloration, etc.

I'm not very experienced in image processing and not sure if my approach would be acceptable.

There are several approaches that I've tried:

Given two images (one good, the other one is defect)

  1. Threshold and blur
  2. Run Canny edge detection
  3. Remove noises using fastNlMeansDenoising
  4. XOR the two images and use SIFT to find outstanding features that may be classified as a defect.

It works very well - in very limited cases.

Seems like this method is used/proposed in industry a bit (?) as seen in this paper. But the problem with it is that if you have two images that are misaligned to the slightest bit, then you would get a problem because all your XOR result in an XOR-ed image that is very wrong. So to me it doesn't seem like an acceptable solution, since it is impossible to perfectly align two images every time (or I could try to realign the images).

How should I approach this. Is there a method that is similar to XOR-ing that is more tolerant to subtle differences? Or perhaps, a totally different approach.

Possible alternative

Break up both images into chunks of n by n pixels. Compute and compare the histogram of each chunk of pixels broken up from image A to image B. Even if one of the images is blurred a little, the histogram should be still be similar (not sure if this is a sound assumption). If any chunk contains dark or white spots, this should flag that chunk for further inspection.

diff 1 Detects darker font color

diff 2 Detects eyebrows that aren't supposed to be there

diff 3 Detects faded/lighten area

$\endgroup$
6
  • $\begingroup$ Could you add an example pair of images? $\endgroup$ Sep 1, 2015 at 9:20
  • 1
    $\begingroup$ The usual way to align images is the process called image registration. The idea being to find the transformation that aligns the images and apply it. The other approach is to find techniques that are rotation, translation, and scale invariant for your particular problem. That might be harder. $\endgroup$
    – Peter K.
    Sep 1, 2015 at 11:57
  • $\begingroup$ What about techniques like feature matching to "stitch" the two images together. $\endgroup$
    – 40pro
    Sep 1, 2015 at 12:10
  • 1
    $\begingroup$ I think there are SIFT based methods for image registration, have a look at the vlfeat library $\endgroup$ Sep 1, 2015 at 12:33
  • 1
    $\begingroup$ vlfeat.org/applications/sift-mosaic-code.html $\endgroup$ Sep 1, 2015 at 12:34

1 Answer 1

2
$\begingroup$

All the comments in the comment section were very constructive, thank you.

In the end, I ended up using the solution: Image Alignment (ECC) in OpenCV ( C++ / Python )

For my case, most of my images are not expected to tilt more than a few degree, lighting and depths are strictly controlled. So a Euclidean Motion model (MOTION_EUCLIDEAN) should suffice for findTransformECC which computed the transformation matrix that is required to correct the misalignment.

$\endgroup$

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.