Ask Your Question

Revision history [back]

Performance comparison of horizontal & vertical flipping

cv::flip function internally calls flipHoriz or flipVert functions.When i compared the passing time of vertical flipping and horizontal flipping with the code below i get following results.

  • flipVert process time (averaged for 500 runs): 0.286388 milliseconds.
  • flipHoriz process time (averaged for 500 runs): 1.09012 milliseconds.

i thought that flipVert has different algorihtm (i did not understand deeper) and faster than flipHoriz .

what is your remarks?

#include <opencv2/highgui.hpp>
#include <opencv2/core.hpp>
#include <iostream>

int main()
{
    cv::Mat SrcImg = cv::imread("lena.jpg");
    cv::Mat DstImg;

    const int times = 500;
    double t;

    t = (double)cv::getTickCount();

    for (int i = 0; i < times; ++i)
    {
        flip(SrcImg, DstImg, 0);
    }

    t = 1000*((double)cv::getTickCount() - t)/cv::getTickFrequency();
    t /= times;

    std::cout << "flipVert  process time (averaged for "
              << times << " runs): " << t << " milliseconds."<< std::endl;

    t = (double)cv::getTickCount();

    for (int i = 0; i < times; ++i)
    {
        flip(SrcImg, DstImg, 1);
    }

    t = 1000*((double)cv::getTickCount() - t)/cv::getTickFrequency();
    t /= times;

    std::cout << "flipHoriz process time (averaged for "
              << times << " runs): " << t << " milliseconds."<< std::endl;

    return 0;
}

Performance comparison of horizontal & vertical flipping

cv::flip function internally calls flipHoriz or flipVert functions.When functions.

When i compared the passing time of vertical flipping and horizontal flipping with the code below i get following results.

  • flipVert process time (averaged for 500 runs): 0.286388 milliseconds.
  • flipHoriz process time (averaged for 500 runs): 1.09012 milliseconds.

i thought that flipVert has different algorihtm (i did not understand deeper) and faster than flipHoriz .

i wonder is it possible to apply flipVert's algorihtm to flipHoriz.

what is your remarks?

#include <opencv2/highgui.hpp>
#include <opencv2/core.hpp>
#include <iostream>

int main()
{
    cv::Mat SrcImg = cv::imread("lena.jpg");
    cv::Mat DstImg;

    const int times = 500;
    double t;

    t = (double)cv::getTickCount();

    for (int i = 0; i < times; ++i)
    {
        flip(SrcImg, DstImg, 0);
    }

    t = 1000*((double)cv::getTickCount() - t)/cv::getTickFrequency();
    t /= times;

    std::cout << "flipVert  process time (averaged for "
              << times << " runs): " << t << " milliseconds."<< std::endl;

    t = (double)cv::getTickCount();

    for (int i = 0; i < times; ++i)
    {
        flip(SrcImg, DstImg, 1);
    }

    t = 1000*((double)cv::getTickCount() - t)/cv::getTickFrequency();
    t /= times;

    std::cout << "flipHoriz process time (averaged for "
              << times << " runs): " << t << " milliseconds."<< std::endl;

    return 0;
}

Performance comparison of horizontal & vertical flipping

cv::flip function internally calls flipHoriz or flipVert functions.

When i compared the passing time of vertical flipping and horizontal flipping with the code below i get following results.

  • flipVert process time (averaged for 500 runs): 0.286388 milliseconds.
  • flipHoriz process time (averaged for 500 runs): 1.09012 milliseconds.

i thought that flipVert has different algorihtm (i did not understand deeper) and faster than flipHoriz .

i wonder is it possible to apply flipVert's algorihtm to flipHoriz.

what is your remarks?

( i edited the code adding more processes to compare )

  • src.clone process time (averaged for 500 runs): 0.793516 milliseconds.
  • src * 2 .. process time (averaged for 500 runs) : 0.39996 milliseconds.

#include <opencv2/highgui.hpp>
#include <opencv2/core.hpp>
#include <iostream>

int main()
{
    cv::Mat SrcImg = cv::imread("lena.jpg");
    cv::Mat DstImg;

    const int times = 500;
    double t;

    t = (double)cv::getTickCount();

    for (int i = 0; i < times; ++i)
    {
        flip(SrcImg, DstImg, 0);
    }

    t = 1000*((double)cv::getTickCount() - t)/cv::getTickFrequency();
    t /= times;

    std::cout << "flipVert  process time (averaged for "
              << times << " runs): " << t << " milliseconds."<< std::endl;

    t = (double)cv::getTickCount();

    for (int i = 0; i < times; ++i)
    {
        flip(SrcImg, DstImg, 1);
    }

    t = 1000*((double)cv::getTickCount() - t)/cv::getTickFrequency();
    t /= times;

    std::cout << "flipHoriz process time (averaged for "
              << times << " runs): " << t << " milliseconds."<< std::endl;

    t = (double)cv::getTickCount();

    for (int i = 0; i < times; ++i)
    {
        DstImg = SrcImg.clone();
    }

    t = 1000*((double)cv::getTickCount() - t)/cv::getTickFrequency();
    t /= times;

    std::cout << "src.clone process time (averaged for "
              << times << " runs): " << t << " milliseconds."<< std::endl;

    t = (double)cv::getTickCount();

    for (int i = 0; i < times; ++i)
    {
        DstImg = SrcImg * 2;
    }

    t = 1000*((double)cv::getTickCount() - t)/cv::getTickFrequency();
    t /= times;

    std::cout << "src * 2   process time (averaged for "
              << times << " runs): " << t << " milliseconds."<< std::endl;
    return 0;
}