Пример #1
0
int main()
{
    int m,n,z;
    t a;

    randomize();
    do {
        czyt(&n,&z);
        generacja(n,z,a);
        obl(n,a,&m);
        druk(n,z,a,m);
        printf("koniec? 0/1\n");
    } while (getch()!='1');
    return 0;
} //main
    /**
     * @brief Compute the sum of values and the sum of squared values of a patch with dimensions
     * 2*xWindow+1 by 2*yWindow+1 and centered in point p, using the integral image and integral
     * image of squared pixel values.
     * @param[in] p The center of the patch we want to calculate the sum and sum of squared values.
     * @param[in] s The integral image
     * @param[in] ss The integral image of squared values.
     * @param[out] sum The sum of pixels inside the patch.
     * @param[out] ssum The sum of squared values inside the patch.
     * @param [in] xWindow The distance from the central pixel of the patch to the border in x
     * direction.
     * @param [in] yWindow The distance from the central pixel of the patch to the border in y
     * direction.
     * @note Default value for xWindow, yWindow is 1. in this case the patch is 3x3.
     * @note integral images are very useful to sum values of patches in constant time independent
     * of their size. For more information refer to the cv::Integral function OpenCV page.
     */
    void patchSumSum2(const cv::Point2i p, const cv::Mat &sum, const cv::Mat &ssum,
                        float &s, float &ss, const int xWindow=1, const int yWindow=1)
    {
      cv::Point2i otl(p.x-xWindow, p.y-yWindow);
      //outer top right
      cv::Point2i otr(p.x+xWindow+1, p.y-yWindow);
      //outer bottom left
      cv::Point2i obl(p.x-xWindow, p.y+yWindow+1);
      //outer bottom right
      cv::Point2i obr(p.x+xWindow+1, p.y+yWindow+1);

      // sum and squared sum for right window
      s = (float)(sum.at<int>(otl) - sum.at<int>(otr)
          - sum.at<int>(obl) + sum.at<int>(obr));

      ss = (float)(ssum.at<double>(otl) - ssum.at<double>(otr)
           - ssum.at<double>(obl) + ssum.at<double>(obr));
    }