วิศวะฝั่งธน

ปรับขนาดภาพ OpenCV

IplImage* mycvResize(IplImage* src, CvSize size) //Resizeeee //////
{
int iratex,iratey;
double rate;
IplImage *resizeimg;
if (src->height > size.height || src->width > size.width)
{
iratex = (int)(src->width/(size.width/10));
iratey = (int)(src->height/(size.height/10));
rate = (iratex>iratey? iratex: iratey)/10;
resizeimg= cvCreateImage(cvSize((int)(src->width/rate),(int)(src->height/rate)), src->depth, src->nChannels);
cvResize(src,resizeimg,CV_INTER_NN);
return resizeimg;
}
else
{
// resizeimg= cvCreateImage(cvSize((int)(92),(int)(112)), src->depth, src->nChannels);
// cvResize(src,resizeimg,CV_INTER_NN);
// return resizeimg;
}
}




 

Create Date : 04 มีนาคม 2551   
Last Update : 4 มีนาคม 2551 15:40:07 น.   
Counter : 532 Pageviews.  

cvGetPixel In OpenCV

void process(void* img) {

IplImage* image = reinterpret_cast(img);

int nl= image->height;
int nc= image->width * image->nChannels;
int step= image->widthStep; // because of alignment

// because imageData is a signed char*
unsigned char *data=
reinterpret_cast(image->imageData);

for (int i=0; i {
for (int j=0; jnChannels)
{

// 3 channels per pixel

if (data[j+1] > data[j] && data[j+1] > data[j+2])
{

data[j]= 0xFF; // 255
data[j+1]= 0xFF;
data[j+2]= 0xFF;

}
}

data+= step; // next line
}
}




 

Create Date : 04 มีนาคม 2551   
Last Update : 4 มีนาคม 2551 15:21:15 น.   
Counter : 433 Pageviews.  


TahKM
Location :
ตรัง Thailand

[Profile ทั้งหมด]

ฝากข้อความหลังไมค์
Rss Feed

ผู้ติดตามบล็อก : 1 คน [?]




[Add TahKM's blog to your web]