Ask Your Question

raymond's profile - activity

2017-05-31 10:17:33 -0500 received badge  Editor (source)
2017-05-31 10:16:24 -0500 asked a question Fast fourier higest three magnitudes

i am trying to build a classifier using the fast Fourier as a feature for my image so the steps must be as following: 1-get the FFT coefficients

2-get the three highest magnitudes.

3-pass the highest magnitudes to a neural network classifier or k-nearest neighbor algorithm ,

the idea is that i don't know whether to use the coefficients or magnitudes , but any how here is the code i followed

Mat padded;                            //expand input image to optimal size
int m = getOptimalDFTSize(vertical.rows);
int n = getOptimalDFTSize(vertical.cols); // on the border add zero values
copyMakeBorder(vertical , padded, 0, m - vertical.rows, 0, n - vertical.cols, BORDER_CONSTANT, Scalar::all(0));

Mat planes[] = { Mat_<float>(padded), Mat::zeros(padded.size(), CV_32F) };
Mat complexI;
merge(planes, 2, complexI);         // Add to the expanded another plane with zeros

dft(complexI, complexI);            // this way the result may fit in the source matrix
split(complexI, planes);                   // planes[0] = Re(DFT(I), planes[1] = Im(DFT(I))
magnitude(planes[0], planes[1], planes[0]);// planes[0] = magnitude
Mat magI = planes[0];

where Vertical is the required processed image

ComplexI i guess is the FFT coefficients

MagI is the Magnitude

generally when using Matlab i would do :

F=fft2(src);
magnitude= abs(F);
sorted_mag = sort(magnitude , 'descend')
threehighest = sorted_mag(1:3);

then get these threehighest , put them into a vector and apply nearest neighbor.

but hey that's matlab , so how do i implement this idea and code it in opencv c++ ??

please explain the concept behind the magnitude and how the dft is splited into planes ...

2017-05-01 18:30:23 -0500 commented answer How to remove line on music sheet

I Have done this and worked with c++ code only with the same picture ... But when i tried some picture notes like these http://www.music-scores.com/midi.php?sheetmusic=Xmas_Deck_the_Hall_easy_piano (link text) the vertical picture doesn't show any notes ... so i figured out that the issue is in this line int verticalsize = vertical.rows/30 ; changing 30 to bigger will create lower size and fix the image of notes but i quiet don't understand the concept of this line in general ... could you please explain it to me ??

2017-03-25 11:54:47 -0500 commented question morphological operations in c#

where can i find a help with c# ?

2017-03-25 11:43:50 -0500 asked a question morphological operations in c#

i am sort of new to emgu in c# but i found these lines of code in c++ and i find it hard to translate it to c#

Mat horizontalStructure = getStructuringElement(MORPH_RECT, Size(horizontalsize,1));

erode(horizontal, horizontal, horizontalStructure, Point(-1, -1));
dilate(horizontal, horizontal, horizontalStructure, Point(-1, -1));

basically i don't understand what Mat is ? and its difference other than creating Image<gray, byte=""> horizontal; for example ...

Anyhow i tried to do sort of this stuff but has always error and can't complete the last needed object call ... plus MORPH_RECT isn't located in the emgu c# or i can't find it at least...

please help converting it to c#

2017-03-25 10:33:25 -0500 commented answer How to remove line on music sheet

could you please provide more explanation on this code ? or explain how to write it in C#.

// Create structure element for extracting vertical lines through morphology operations
Mat verticalStructure = getStructuringElement(MORPH_RECT, Size( 1,verticalsize));

// Apply morphology operations
erode(vertical, vertical, verticalStructure, Point(-1, -1));
dilate(vertical, vertical, verticalStructure, Point(-1, -1));

i understand that morphology operations are dilatation and erosion but i don't understand the usage of structure...?? and what is MORPH_REC .