#include "cv.h"
#include "highgui.h"
#include "cvaux.h"
//extern void SHOW_IMAGE(unsigned char *ptr_u8Image, unsigned int u32ImageWidth, unsigned int u32ImageHeight,
// int s32NoOfPlanes, unsigned char *ptr_u8ImageWindowName);
void SHOW_IMAGE(unsigned char *ptr_u8Image, unsigned int u32ImageWidth, unsigned int u32ImageHeight,
int s32NoOfPlanes, unsigned char *ptr_u8ImageWindowName)
{
IplImage *ptr_u8ImagetoShow = NULL;
CvPoint pt1,pt2;
int i,j, cnt;
/*Create the window in which image data needs to be shown*/
cvNamedWindow(ptr_u8ImageWindowName,1);
/*Allocate the memory for the image to be shown*/
if(!ptr_u8ImagetoShow )
ptr_u8ImagetoShow = cvCreateImage( cvSize(u32ImageWidth, u32ImageHeight), IPL_DEPTH_8U, s32NoOfPlanes );
/*Show Binary mask on preprocessed image*/
memset(ptr_u8ImagetoShow->imageData,0,(u32ImageWidth * u32ImageHeight));
for(i = 0;i < u32ImageHeight; i++)
{
for(j = 0; j < u32ImageWidth; j++)
if(ptr_u8Image [i * u32ImageWidth + j] != 0)
{
switch (s32NoOfPlanes)
{
case 1:
(unsigned char)ptr_u8ImagetoShow->imageData[i * ptr_u8ImagetoShow->widthStep + j] = 255;
break;
case 3:
(unsigned char)ptr_u8ImagetoShow->imageData[i * ptr_u8ImagetoShow->widthStep + (j*3)] = 255;
(unsigned char)ptr_u8ImagetoShow->imageData[i * ptr_u8ImagetoShow->widthStep + (j*3) + 1] = 255;
(unsigned char)ptr_u8ImagetoShow->imageData[i * ptr_u8ImagetoShow->widthStep + (j*3) + 2] = 255;
break;
}
}
}
cvShowImage(ptr_u8ImageWindowName,(CvArr*)ptr_u8ImagetoShow);
cvWaitKey(0);
cvDestroyWindow(ptr_u8ImageWindowName);
cvReleaseImage(&ptr_u8ImagetoShow);
}