Ask Your Question

Revision history [back]

click to hide/show revision 1
initial version

complex conjugate

how do i get the complex conjugate??

is the result of cvDFT complex???

IplImage * src_img = cvLoadImage("for_fft.jpg", 0);
IplImage * dst_inverse = cvCreateImage(cvGetSize(src_img), IPL_DEPTH_8U, src_img->nChannels);
IplImage * dst_freq = cvCreateImage(cvGetSize(src_img), IPL_DEPTH_8U, src_img->nChannels);
IplImage * dst_swap = cvCreateImage(cvGetSize(src_img), IPL_DEPTH_8U, src_img->nChannels);

//spatial: input, freq: frequency domain
CvMat *spatial = cvCreateMat(src_img->height, src_img->widthStep, CV_64FC2);
CvMat *freq = cvCreateMat(src_img->height, src_img->widthStep, CV_64FC2);

//DFT
for (i = 0; i < src_img->imageSize; i++) {
    spatial->data.db[i * 2] = (double)(unsigned char)src_img->imageData[i];
    spatial->data.db[i * 2 + 1];    //for complex 
}

cvDFT(spatial, freq, CV_DXT_FORWARD);//DFT

//print it out in log scale
double tmp = 0;
double max_f = INT_MIN;
double min_f = INT_MAX;

for (i = 0; i < src_img->imageSize; i++) {
    tmp = log10(1 + sqrt(SQUARE(freq->data.db[i * 2]) + SQUARE(freq->data.db[i * 2 + 1])));
    if (tmp < min_f)min_f = tmp;
    if (tmp > max_f) max_f = tmp;
}

for (i = 0; i < src_img->imageSize; i++) {
    dst_freq->imageData[i] = (unsigned char)(256 / (max_f - min_f)*log10(1 + sqrt(SQUARE(freq->data.db[i * 2]) + SQUARE(freq->data.db[i * 2 + 1]))))+5;
}

FreqShift(dst_freq, dst_swap);

cvDFT(freq, spatial, CV_DXT_INVERSE_SCALE);

for (i = 0; i < src_img->imageSize; i++) {
    dst_inverse->imageData[i] = (char)spatial->data.db[i * 2];
}

this is what i did 2D image dft

i want to get the complex conjugate what should i do ? I just start opencv 5 days ago. please let me know.