Created
January 29, 2015 06:58
-
-
Save clarkzjw/ba2406a93b99d0e036b6 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include <stdio.h> | |
#include <time.h> | |
#include <cv.h> | |
#include <highgui.h> | |
int main() | |
{ | |
IplImage *img = cvCreateImage(cvSize(5000, 5000), IPL_DEPTH_8U, 1); | |
cvZero(img); | |
clock_t begin, end; | |
int time1, time2; | |
begin = clock(); | |
for (int i = 0; i < 5000; i++) | |
{ | |
for (int j = 0; j < 5000; j++) | |
{ | |
*(uchar *)(img->imageData + (i)* img->widthStep + (j)* img->nChannels) = 100; | |
} | |
} | |
end = clock(); | |
time1 = end - begin; | |
CvScalar in; | |
in.val[0] = 100; | |
begin = clock(); | |
for (int i = 0; i < 5000; i++) | |
{ | |
for (int j = 0; j < 5000; j++) | |
{ | |
cvSet2D(img, i, j, in); | |
} | |
} | |
end = clock(); | |
time2 = end - begin; | |
printf("Time 1: %d clocks\n", time1); | |
printf("Time 2: %d clocks \n", time2); | |
cvReleaseImage(&img); | |
return 0; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment