Skip to main content

Posts

Showing posts with the label OOP

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)     {      ...

Histogram computation on a video

Histograms are collected counts of data organized into a set of predefined bins   refracted class for histogram: given an input image, output the histogram image class atsHistogram { public:     cv::Mat DrawHistogram(Mat src)     {         /// Separate the image in 3 places ( R, G and B )          vector<Mat> rgb_planes;          split( src, rgb_planes );          /// Establish the number of bins          int histSize = 255;          /// Set the ranges ( for R,G,B) )          float range[] = { 0, 255 } ;          const float* histRange = { range };          bool uniform = true; bool accumulate = false;   ...

OPENCV2 C++ basics (OOP) edge detection using CANNY

if you have an OK background on C++ you can follow easily: ive seperated the camera capturing and the edge detection to separate classes. the main entry point remains the same. you can use the code to add a new class to process images using the atscameraCapture class. #include <iostream> #include <iomanip> #include <sstream> #include <string> #include <vector> #include <opencv2/core/core.hpp> #include <opencv2/highgui/highgui.hpp> //for atsEdges #include <opencv2/imgproc/imgproc.hpp> class atscameraCapture { public:     cv::Mat ats_getImage()     {         //check if Camera is still open         if (!cap.isOpened())         {             std::cout< "Cant Capture";             exit(0);     ...