
Advertisement

Content Count
87 
Joined

Last visited

Neural Network with varying amount of input data?
sjhalayka replied to JimboC's topic in Artificial Intelligence
Just use the maximum number of inputs for the input neuron count, and when there are less than the maximum number of inputs, you just pad the input with the necessary number of 0s. 
"Stuck b/w joint probablity and conditional probability"
sjhalayka replied to sjhalayka's topic in Math and Physics
Thanks again alvaro! I posted a link to your explanation on answers.opencv.org. 
"Stuck b/w joint probablity and conditional probability"
sjhalayka replied to sjhalayka's topic in Math and Physics
Someone defined them using cards: https://www.quora.com/Whatisthedifferencebetweenconditionalprobabilityandjointprobability I am looking for extra examples. 
"Stuck b/w joint probablity and conditional probability"
sjhalayka posted a topic in Math and Physics
What is the difference between joint and conditional probability? Originally asked here: http://answers.opencv.org/question/183825/stuckbwjointprobablityandconditionalprobablity/ 
Not so much, although neural networks are covered in AI for Game Developers.

Has anyone tried out the deep neural network (DNN) module of OpenCV? What are some examples of what you did with the DNN module?

How to calculate the energy and entropy of an image
sjhalayka replied to sjhalayka's topic in Math and Physics
I think we're on the same page, yes. Not sure how my code got mangled so bad LOL. I found this one link that shows the relationship between intensity and amplitude squared: http://muchomas.lassp.cornell.edu/p214/Notes/Interference/node6.html I use the entropy to get the number of bits needed to classify n equiprobable messages  ceil(ln(n)/ln(2)), like with a neural network. 
How to calculate the energy and entropy of an image
sjhalayka replied to sjhalayka's topic in Math and Physics
The code to calculate the entropy of a greyscale image: #include <opencv2/opencv.hpp> using namespace cv; #pragma comment(lib, "opencv_world331.lib") #include <iostream> #include <vector> #include <map> using namespace std; int main(void) { Mat frame = imread("puppets.png", CV_LOAD_IMAGE_GRAYSCALE); if (frame.empty()) { cout << "Error loading image file" << endl; return 1; } map<unsigned char, size_t> pixel_map; for (int j = 0; j < frame.rows; j++) for (int i = 0; i < frame.cols; i++) pixel_map[frame.at<unsigned char>(j, i)]++; //cout << frame.rows*frame.cols << " " << pixel_map.size() << endl; double entropy = 0; for (map<unsigned char, size_t>::const_iterator ci = pixel_map.begin(); ci != pixel_map.end(); ci++) { double probability = ci>second / static_cast<double>(frame.rows*frame.cols); entropy += probability * log(probability); } entropy = entropy; cout << entropy << endl; return 0; } 
How to calculate the energy and entropy of an image
sjhalayka replied to sjhalayka's topic in Math and Physics
Yes, I found on google that intensity is proportional to amplitude squared. It's helpful to know that the intensity (energy per unit area per unit time) is power per unit area. 
How to calculate the energy and entropy of an image
sjhalayka replied to sjhalayka's topic in Math and Physics
@Aressera  You make an interesting point, and it's intuitive. The three intensities (photon count per second * photon energy (red)... etc.) are added up to get the total intensity (energy per unit area per unit time). Right? @alvaro  Is the amplitude squared the pixel intensity? 
How to calculate the energy and entropy of an image
sjhalayka replied to sjhalayka's topic in Math and Physics
Thank you for your clarification. How does one calculate the amplitudes of a pixel? I am applying the entropy function to the pixel distribution. To keep count of all the distinct pixel values, I am using a std::map<pixel, size_t>, where pixel is the pixel colour, be it 3 channel BGR or 1 channel greyscale, and size_t is the count. 
How to calculate the energy and entropy of an image
sjhalayka replied to sjhalayka's topic in Math and Physics
Thanks for your comments. Is energy proportional to frequency, like for light? It's not clear to me how you obtained the value S = log(probability). I am familiar with the S_binary = sum(p_i ln(p_i)) / ln(2) equation, which simplifies down to S_binary = ln(n)/ln(2) where n is the number of equiprobable states. The sum of probabilities must equal 1, right? 
I've got code to use OpenCV's implementation of an artificial neural network to perform both the XOR operation, and image classification. XOR: https://github.com/sjhalayka/opencv_xor Image classification: https://github.com/sjhalayka/opencv_image_classification

How to calculate the energy and entropy of an image
sjhalayka replied to sjhalayka's topic in Math and Physics
Thanks for the guidance alvaro. I'm trying to get the energy and entropy measurements for an image. They fascinate me. So far, I've found on google that the perpixel energy can be considered to be related to the x and y gradients, like: E = \sqrt{g_x^2 + g_y^2}. It reminds me of the potential energy due to gravity. I assume that just adding the energy of all pixels together gives you the perimage energy. As for entropy, it is perimage, and I will use a std::map to count the number of pixels there are for each distinct colour, like you would when obtaining a histogram. I have several codes to calculate the entropy of a string: https://github.com/sjhalayka/entropycalculation I'm just looking for a second opinion on the interpretations of energy and entropy. In fact, I am asking for a person who asked this question on http://answers.opencv.org/question/180503/energycomputationofdctofimage/ who is looking to measure the energy of an image using the DCT. 
How does one go about calculating the energy and entropy of an image?

Advertisement