| OLD | NEW |
| 1 // Copyright (c) 2008 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2008 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 /* Fuzzy pixel test matching. | 5 /* Fuzzy pixel test matching. |
| 6 * | 6 * |
| 7 * This is designed to compare two layout test images (RGB 800x600) and manage | 7 * This is designed to compare two layout test images (RGB 800x600) and manage |
| 8 * to ignore the noise caused by the font renderers choosing slightly different | 8 * to ignore the noise caused by the font renderers choosing slightly different |
| 9 * pixels. | 9 * pixels. |
| 10 * | 10 * |
| (...skipping 14 matching lines...) Expand all Loading... |
| 25 * |-----OR------| | 25 * |-----OR------| |
| 26 * | | 26 * | |
| 27 * V | 27 * V |
| 28 * count pixels | 28 * count pixels |
| 29 * | 29 * |
| 30 * The result is that three different pixels in a row (vertically or | 30 * The result is that three different pixels in a row (vertically or |
| 31 * horizontally) will cause the match to fail and the binary exits with code 1. | 31 * horizontally) will cause the match to fail and the binary exits with code 1. |
| 32 * Otherwise the binary exists with code 0. | 32 * Otherwise the binary exists with code 0. |
| 33 * | 33 * |
| 34 * This requires leptonica to be installed. On Ubuntu do | 34 * This requires leptonica to be installed. On Ubuntu do |
| 35 * # apt-get install libleptonica libleptonica-dev | 35 * # apt-get install libleptonica libleptonica-dev libtiff4-dev |
| 36 * | 36 * |
| 37 * Build with: | 37 * Build with: |
| 38 * % gcc -o fuzzymatch fuzzymatch.c -llept -ljpeg -ltiff -lpng -lz -lm -Wall -
O2 | 38 * % gcc -o fuzzymatch fuzzymatch.c -llept -ljpeg -ltiff -lpng -lz -lm -Wall -
O2 |
| 39 * | 39 * |
| 40 * Options: | 40 * Options: |
| 41 * --highlight: write highlight.png which is a copy of the first image | 41 * --highlight: write highlight.png which is a copy of the first image |
| 42 * argument where the differing areas (after noise removal) are ringed | 42 * argument where the differing areas (after noise removal) are ringed |
| 43 * in red | 43 * in red |
| 44 * --no-ignore-scrollbars: usually the rightmost 15px of the image are | 44 * --no-ignore-scrollbars: usually the rightmost 15px of the image are |
| 45 * ignored to account for scrollbars. Use this flag to include them in | 45 * ignored to account for scrollbars. Use this flag to include them in |
| (...skipping 94 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 140 PIX *d1 = pixDilateBrick(NULL, opened, 7, 7); | 140 PIX *d1 = pixDilateBrick(NULL, opened, 7, 7); |
| 141 PIX *d2 = pixDilateBrick(NULL, opened, 3, 3); | 141 PIX *d2 = pixDilateBrick(NULL, opened, 3, 3); |
| 142 pixInvert(d2, d2); | 142 pixInvert(d2, d2); |
| 143 pixAnd(d1, d1, d2); | 143 pixAnd(d1, d1, d2); |
| 144 pixPaintThroughMask(a, d1, 0, 0, 0xff << 24); | 144 pixPaintThroughMask(a, d1, 0, 0, 0xff << 24); |
| 145 pixWrite("highlight.png", a, IFF_PNG); | 145 pixWrite("highlight.png", a, IFF_PNG); |
| 146 } | 146 } |
| 147 | 147 |
| 148 return count > 0; | 148 return count > 0; |
| 149 } | 149 } |
| OLD | NEW |