Last active
June 29, 2019 09:44
-
-
Save dgzlopes/e37afb72ad9ad9d4c0f45f9301841ccb 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
int main(int argc, char **argv) { | |
if (argc != 2) { | |
printf("Error: Usage %s image_file_name\n", argv[0]); | |
return EXIT_FAILURE; | |
} | |
//CV_LOAD_IMAGE_COLOR = 1 forces the resultant IplImage to be colour. | |
//CV_LOAD_IMAGE_GRAYSCALE = 0 forces a greyscale IplImage. | |
//CV_LOAD_IMAGE_UNCHANGED = -1 | |
IplImage* ImgOrigen = cvLoadImage(argv[1], CV_LOAD_IMAGE_COLOR); | |
IplImage* ImgDestino = cvCreateImage(cvSize(ImgOrigen->width, ImgOrigen->height), IPL_DEPTH_8U, 3); | |
// Always check if the program can find the image file | |
if (!ImgOrigen) { | |
printf("Error: file %s not found\n", argv[1]); | |
return EXIT_FAILURE; | |
} | |
int fila, cc; | |
for(fila = 0; fila < ImgOrigen->height; fila++) { | |
__m128i*pImgOrigen = (__m128i*) (ImgOrigen->imageData + fila*ImgOrigen->widthStep); | |
__m128i*pImgDestino = (__m128i*) (ImgDestino->imageData + fila*ImgDestino->widthStep); | |
__m128i registro; | |
for(cc = 0; cc < ImgOrigen->widthStep; cc=cc+16) { | |
//Opcion 1 | |
registro =*pImgOrigen++;*pImgDestino++ = registro; | |
//Opcion 2 | |
//registro = _mm_load_si128(pImgOrigen++); | |
//_mm_store_si128(pImgDestino++,registro); | |
//Opcion 3, para datos no alineados en memoria | |
//registro = _mm_loadu_si128(pImgOrigen++); | |
//_mm_storeu_si128(pImgDestino++,registro); | |
} | |
} | |
cvNamedWindow("Imagen Original", CV_WINDOW_AUTOSIZE); | |
cvShowImage("Imagen Original", ImgOrigen); | |
// crea y muestras las ventanas con las im genes | |
cvNamedWindow("Imagen Destino", CV_WINDOW_AUTOSIZE); | |
cvShowImage("Imagen Destino", ImgDestino); | |
cvWaitKey(0); | |
// memory release for images before exiting the application | |
cvReleaseImage(&ImgDestino); | |
cvReleaseImage(&ImgOrigen); | |
// Self-explanatory | |
cvDestroyWindow(argv[1]); | |
cvDestroyWindow("Imagen Recolor"); | |
return EXIT_SUCCESS; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment