Ask Your Question

HiHello's profile - activity

2021-03-19 04:06:14 -0600 received badge  Notable Question (source)
2020-01-08 06:36:38 -0600 received badge  Popular Question (source)
2016-10-04 14:07:35 -0600 asked a question visual studio 2015 -> opencv 3.0

can I use opencv 3.0 in visual studio 2015?

2016-07-14 01:11:34 -0600 received badge  Student (source)
2016-07-13 18:44:10 -0600 asked a question average value to int
Mat src_size;
src_size = imread("unit.jpg", 1);
cv::Scalar avg;
avg = cv::mean(src_size);

Mat dst_size(Size(256, 256), CV_64F);


for (int i = 0; i < 256; i++) {
    for (int j = 0; j < 256; j++) {
        dst_size.at<int>(i, j) = avg;
    }
}
imshow("Hi", dst_size);

How can i convert Scalar to int??

2016-07-13 18:16:17 -0600 asked a question move and expand image

image description -> image description

How can i make the image like this? I am thinking about the flow like this.

First, make a new Mat type data 256*256.

Second, fill the image with the average value of small image.

Third, copy the small image in the middle of the new image.

Is that rignt? and also how can i copy the small image in the middle of the new image? T.T

2016-07-13 00:12:32 -0600 received badge  Enthusiast
2016-07-12 17:29:37 -0600 asked a question Vec2f , mulSpectrums

i got the answer about mulSpectrum like this.

Mat z1(1,2,CV_32FC2),z2(1,2,CV_32FC2),z3;

z1.at<vec2f>(0, 0) = Vec2f(1,1);//1+i

z1.at<vec2f>(0, 1) = Vec2f(2,3);//2+3i

z2.at<vec2f>(0, 0) = Vec2f(2,1);//2+i

z2.at<vec2f>(0, 1) = Vec2f(3, 3);//3+3i

mulSpectrums(z1,z2,z3,0); cout<<z3; (1+i)<em="">(2+i) and (2+i)(3+3i) waitKey();

how can i change IplImage* to the form like above? do i have to use "for loop"? i meat that

CvMat* freq;

For example, (R0, I0), (R1, I1), (R2, I2), (R3, I3)..(Rn,In)

freq->data.db[0] means R0, freq->data.db[1] means I0,

freq->data.db[2] means R1, freq->data.db[3] means I1,

freq->data.db[4] means R2, freq->data.db[5] means I2, ...

something like this. i dont know how to convert that data to Vec form.

Thanks.

2016-07-12 16:44:34 -0600 commented answer mulSpectrums

Thanks! then, how can i change IplImage* to that form?

do i have to use "for loop"?

CvMat* freq;

For example, (R0, I0), (R1, I1), (R2, I2), (R3, I3)..(Rn,In)

freq->data.db[0] means R0,freq->data.db[1] means I0,

freq->data.db[2] means R1,freq->data.db[3] means I1,

freq->data.db[4] means R2,freq->data.db[5] means I2, ...

something like this. i dont know how to convers that data to Vec form.

2016-07-12 13:59:32 -0600 asked a question mulSpectrums

what is the result of mulSpectrums? if input A = a+bi input B = c+di mulSpectrums(A, B, result, CV_DXT_MUL_CONJ, true)

then, result = (a+bi)(c-di)?? or just result = bi(-ci)??

Also what type of input is better? InputArray can be IplImage? CvMat? Mat? Also for the function mulSpectrums, input should be 2 channels? for real part and imaginary part??

if you dont mind, could you explain about the differences of those three data types?(IplImage, CvMat, Mat)

i also read this, but im not an English speaker. so it is hard tho. image description

I started just 1 week ago.

Please explain it as much as you can. Thanks a lot.

2016-07-06 19:25:15 -0600 commented answer complex conjugate

thanks for your advice! btw what is the difference between c API and c++ API? im beginer so, if you dont mind please give me some details.

2016-07-06 18:54:54 -0600 asked a question 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.

2016-07-06 11:51:20 -0600 received badge  Editor (source)
2016-07-06 11:47:46 -0600 asked a question image fft(2d)

Is there any functions for fft (for image (2D)) which is provided from opencv

I am trying, but it is hard to consider imaginary part.

also

realInput = cvCreateImage((256,256), IPL_DEPTH_64F, 1);
imaginaryInput = cvCreateImage((256, 256), IPL_DEPTH_64F, 1);
complexInput = cvCreateImage((256, 256), IPL_DEPTH_64F, 2);
cvScale(src_img, realInput, 1.0, 0.0);
cvZero(imaginaryInput);/////////////////////////////////////////////////Error  -> i dont know
cvMerge(realInput, imaginaryInput, NULL, NULL, complexInput);

whats wrong with this code tho

i need to get a result like this image description

thanks!

2016-07-05 12:42:53 -0600 commented question gradient filter

thanks for your advice:)

2016-07-05 12:40:36 -0600 commented answer gradient filter

thanks! also thanks for your advice.

2016-07-05 11:29:03 -0600 asked a question gradient filter

i am try to make gradient filter which is

intfilter[filterHeight][filterWidth]{
    -1,-1, -1,
    -1, 0,  1,
     1, 1,  1
};

and the code is like below.

image description

Mat gradient(Matdst, IplImage *img) {
Matnew_dst(256, 256, DataType<int>::type);
uchar*data;
data= (uchar*)img->imageData;

intheight, width, i, j;
height= img->height;
width= img->width;
IplImage*imgavg = cvCreateImage(cvSize(width, height), IPL_DEPTH_8U, 1);

if(img != 0){
cvSmooth(img, imgavg, CV_BLUR, 1);//3*3의 이웃 픽셀값의 평균
cvNamedWindow("AvgFilter", CV_WINDOW_AUTOSIZE);
cvShowImage("AvgFilter", imgavg);
}


for(i = 2; i < width-2; i++) {
for(j = 2; j < height-2; j++) {
new_dst.at<int>(i,j) = {(dst.at<int>(i-1, j-1))*(filter[0][0])+(dst.at<int>(i-1,j))*(filter[0][1])+ (dst.at<int>(i-1, j+1))*(filter[0][2])
+(dst.at<int>(i , j-1))*(filter[1][0]) + (dst.at<int>(i,j))*(filter[1][1]) + (dst.at<int>(i, j+1))*(filter[1][2])
+(dst.at<int>(i+1, j-1))*(filter[2][0]) + (dst.at<int>(i+1,j))*(filter[2][1]) + (dst.at<int>(i+1, j+1))*(filter[2][2])};
}//forj (height)
}//fori (width)

IplImage*imgn;
imgn= cvCreateImage(cvSize(512, 512), IPL_DEPTH_8U, 1);
imgn->imageData= (char *)new_dst.data;
cvShowImage("Hooooooo",imgn);
returnnew_dst;
}

so i got the result like this. the result of gradient filter that i made is the first pic.

image description

i havent any idea that why the result comes out like this.

Here is my question. If you have any idea about that filter, please let me know.

Also I you can please advice me that what is wrong about my code.

Also, if there is any route that i can see the filter library which is served by opencv please let me know.

Thanks !

2016-07-02 00:01:25 -0600 asked a question sine function

i want to get a window function which is

#define PI 3.141592653
window function = sin(pixel / (image width - 1) * PI)^2

However, when i tried to do it, the left side of '^' can not be double type. Is there any suggestion for this situation?

Also the function means hann window i guess. Is there any window function which can use from library like that equation??