! * \brief pixGetPerceptualDiff() * * \param[in] pixs1 8 bpp gray or 32 bpp rgb, or colormapped * \param[in] pixs2 8 bpp gray or 32 bpp rgb, or colormapped * \param[in] sampling subsampling factor; use 0 or 1 for no subsampling * \param[in] dilation size of grayscale or color Sel; odd * \param[in] mindiff minimum pixel difference to be counted; > 0 *
| 1612 | * </pre> |
| 1613 | */ |
| 1614 | l_int32 |
| 1615 | pixGetPerceptualDiff(PIX *pixs1, |
| 1616 | PIX *pixs2, |
| 1617 | l_int32 sampling, |
| 1618 | l_int32 dilation, |
| 1619 | l_int32 mindiff, |
| 1620 | l_float32 *pfract, |
| 1621 | PIX **ppixdiff1, |
| 1622 | PIX **ppixdiff2) |
| 1623 | { |
| 1624 | l_int32 d1, d2, w, h, count; |
| 1625 | PIX *pix1, *pix2, *pix3, *pix4, *pix5, *pix6, *pix7, *pix8, *pix9; |
| 1626 | PIX *pix10, *pix11; |
| 1627 | |
| 1628 | PROCNAME("pixGetPerceptualDiff"); |
| 1629 | |
| 1630 | if (ppixdiff1) *ppixdiff1 = NULL; |
| 1631 | if (ppixdiff2) *ppixdiff2 = NULL; |
| 1632 | if (!pfract) |
| 1633 | return ERROR_INT("&fract not defined", procName, 1); |
| 1634 | *pfract = 1.0; /* init to completely different */ |
| 1635 | if ((dilation & 1) == 0) |
| 1636 | return ERROR_INT("dilation must be odd", procName, 1); |
| 1637 | if (!pixs1) |
| 1638 | return ERROR_INT("pixs1 not defined", procName, 1); |
| 1639 | if (!pixs2) |
| 1640 | return ERROR_INT("pixs2 not defined", procName, 1); |
| 1641 | d1 = pixGetDepth(pixs1); |
| 1642 | d2 = pixGetDepth(pixs2); |
| 1643 | if (!pixGetColormap(pixs1) && d1 < 8) |
| 1644 | return ERROR_INT("pixs1 not cmapped or >=8 bpp", procName, 1); |
| 1645 | if (!pixGetColormap(pixs2) && d2 < 8) |
| 1646 | return ERROR_INT("pixs2 not cmapped or >=8 bpp", procName, 1); |
| 1647 | |
| 1648 | /* Integer downsample if requested */ |
| 1649 | if (sampling > 1) { |
| 1650 | pix1 = pixScaleByIntSampling(pixs1, sampling); |
| 1651 | pix2 = pixScaleByIntSampling(pixs2, sampling); |
| 1652 | } else { |
| 1653 | pix1 = pixClone(pixs1); |
| 1654 | pix2 = pixClone(pixs2); |
| 1655 | } |
| 1656 | |
| 1657 | /* Remove colormaps */ |
| 1658 | if (pixGetColormap(pix1)) { |
| 1659 | pix3 = pixRemoveColormap(pix1, REMOVE_CMAP_BASED_ON_SRC); |
| 1660 | d1 = pixGetDepth(pix3); |
| 1661 | } else { |
| 1662 | pix3 = pixClone(pix1); |
| 1663 | } |
| 1664 | if (pixGetColormap(pix2)) { |
| 1665 | pix4 = pixRemoveColormap(pix2, REMOVE_CMAP_BASED_ON_SRC); |
| 1666 | d2 = pixGetDepth(pix4); |
| 1667 | } else { |
| 1668 | pix4 = pixClone(pix2); |
| 1669 | } |
| 1670 | pixDestroy(&pix1); |
| 1671 | pixDestroy(&pix2); |
nothing calls this directly
no test coverage detected