Skip to main content

Posts

If you found these codes useful buy me a beer

If you found these codes useful buy me a beer

Results Update Feb 4

getting SURF points of any image

this post uses OPENCV 2.2 and a simple change of the extract feature will allow use on version 2.3 class atsSURF { public:     cv::Mat extractPoints(cv::Mat img)     {         int minHessian = 500;         cv::SurfFeatureDetector detector(minHessian);         std::vector<cv::KeyPoint> keypoints;         detector.detect(img,keypoints,img); //opencv 2.2         //detector.detect(img,keypoints); //opencv 2.3         cv::SurfDescriptorExtractor extractor;         cv::Mat descriptor;         extractor.compute(img,keypoints,descriptor);         thisDescriptor = descriptor;         thisKeypoints = keypoints;         cv::Mat outim =...

Entropy and Gini index experiments

Conclusion: 1. Entropy and Gini index are unique when color and shape are different 2. Entropy and Gini Index are unique (Small Difference) Color remains the same but different shape 3. Entropy and Gini Index are unique (smaller difference) Color and shape are the same Area and size Shape and Color are the same, however entropy is unique, Gini Index is even more unique

Blob Detection, Connected Component (Pure Opencv)

Connected-component labeling (alternatively connected-component analysis, blob extraction, region labeling, blob discovery, or region extraction) is an algorithmic application of graph theory, where subsets of connected components are uniquely labeled based on a given heuristic. Connected-component labeling is not to be confused with segmentation. i got the initial code from this URL: http://nghiaho.com/?p=1102 However the code did not compile with my setup of OpenCV 2.2, im guessing it was an older version. so a refactored and corrected the errors to come up with this Class class atsBlobFinder     {     public:         atsBlobFinder()         {         }         ///Original Code by http://nghiaho.com/?p=1102         ///Changed and added commments. Removed Errors     ...

Computing Gini Index of an image (measure of Impurity)

Using my previous posts Class file and this reference: http://people.revoledu.com/kardi/tutorial/DecisionTree/how-to-measure-impurity.htm float computeGiniIndex(Mat r, Mat g, Mat b)     {         float giniIndex = 0.0;         float frequency = getFrequencyOfBin(r);         for( int i = 1; i < histSize; i++ )         {             float Hc = abs(getHistogramBinValue(r,i));             giniIndex += Hc*Hc;         }         frequency = getFrequencyOfBin(g);         for( int i = 1; i < histSize; i++ )         {             float Hc = abs(getHistogramBinValue(g,i));  ...

Computing Entropy of an image (CORRECTED)

entropy is a measure of the uncertainty associated with a random variable. basically i want to get a single value representing the entropy of an image. 1. Assign 255 bins for the range of values between 0-255 2. separate the image into its 3 channels 3. compute histogram for each channel 4. normalize all 3 channels unifirmely 5. for each channel get the bin value (Hc) and use its absolute value (negative log is infinity) 6. compute Hc*log10(Hc) 7. add to entropy and continue with 5 until a single value converges 5. get the frequency of each channel - add all the values of the bin 6. for each bin get a probability - if bin 1 = 20 bin 2 = 30 then frequency is 50 and probability is 20/50 and 30/50 then compute using shannon formula  REFERENCE: http://people.revoledu.com/kardi/tutorial/DecisionTree/how-to-measure-impurity.htm class atsHistogram { public:     cv::Mat DrawHistogram(Mat src)     {      ...

Opencv 2.3.1 Installation

alright it took me a while before posting this. for OPENCV 2.3.1 and Visual studio 2010 Professional on a windows 7 64 bit environment Download The "super pack" and unzip to "C:\OPENCV" it seems you can only get the source of opencv and need to compile it with CMAKE. very straight forward. download CMAKE and use the command prompt to enter CMAKE CMAKELIST.txt at the opencv directory Open  "ALL_BUILD" by double clicking - opens up visual studio Compile it and wait. (took a minute) go to properties and select the release version and compile again (took another minute) your all set with the opencv installation "c:\opencv\build" create an empty visual studio "win32 console application" Click on Configuration Properties->VC++ Directories, and edit the Include Directories. Add: C:\opencv\build\common\tbb30_20110427oss\include (UPDATE) C:\opencv\build\include Click on Configuration Properties->VC++ Directories, and ...

Blobs with opencv (internal function)

There are many open source opencv BLOB libraries that you can use. i have tried several of these, however because of the 64 bit machine that im using recompiling these are very troublesome. If you have heard of these libraries: "cvBlobsLib": http://opencv.willowgarage.com/wiki/cvBlobsLib   "cvBlob": http://code.google.com/p/cvblob/   "Bloblib" by Dave Grossman (also referred to as "Blob Analysis Package"): Go to http://tech.groups.yahoo.com/group/OpenCV/files/  You will know that opencv also has a built in function that can help you find blobs using cv::findContour and see some statistics using the cv::moments. eventually make these functions similar to regionprops Matlab function The BLOB FINDER CLASS: class atsBlobFinder { public:     atsBlobFinder(cv::Mat src)     {         numBlobs = 0;         cv::Mat img; //must create a temporary Matrix to hold...

finding the center of gravity in opencv

Alot of feature detectors such as the Haar classifier will return rectangular shapes presented as a detected feature. one of the things to do in order to track these, is to find the center of the rectangle.   int main( int argc, char** argv ) { atscameraCapture movie; char code = (char)-1; for(;;)         {             //get camera             cv::Mat imgs = movie.ats_getImage(); #define drawCross( center, color, d, img )                                 \             line( img, Point( center.x - d, center.y - d ),                \       ...