To calculate the network Peak Signal-to-Noise Ratio (PSNR) in OMNeT++ has numerous steps that usually used to measure the quality of received images or video frames that have been transmitted over a network. The PSNR is the common parameters to evaluate the quality of reconstruction of lossy compression like in video or image transmission associated to the original signal. Get complete project help from omnet-manual.com we have all the necessary tool to complete your work. The given below are the procedures on how to calculate the PSNR in OMNeT++:
Steps to Calculate PSNR in OMNeT++
PSNR=10⋅log10(MAX2MSE)\text{PSNR} = 10 \cdot \log_{10}\left(\frac{\text{MAX}^2}{\text{MSE}}\right)PSNR=10⋅log10(MSEMAX2)
Where:
The MSE is calculated as:
MSE=1MN∑i=0M−1∑j=0N−1[I(i,j)−K(i,j)]2\text{MSE} = \frac{1}{MN} \sum_{i=0}^{M-1} \sum_{j=0}^{N-1} \left[I(i,j) – K(i,j)\right]^2MSE=MN1i=0∑M−1j=0∑N−1[I(i,j)−K(i,j)]2
Where:
// Example pseudocode for handling an image
int width = 640; // Example image width
int height = 480; // Example image height
int maxPixelValue = 255; // Max pixel value for 8-bit images
// Arrays to store original and received image data
std::vector<std::vector<int>> originalImage(height, std::vector<int>(width));
std::vector<std::vector<int>> receivedImage(height, std::vector<int>(width));
double mse = 0.0;
for (int i = 0; i < height; i++) {
for (int j = 0; j < width; j++) {
mse += pow(originalImage[i][j] – receivedImage[i][j], 2);
}
}
mse = mse / (width * height);
double psnr = 10 * log10((maxPixelValue * maxPixelValue) / mse);
recordScalar(“Network PSNR (dB)”, psnr);
EV << “Network PSNR: ” << psnr << ” dB” << endl;
class VideoReceiverApp : public cSimpleModule {
private:
int width, height;
int maxPixelValue;
std::vector<std::vector<int>> originalImage;
std::vector<std::vector<int>> receivedImage;
protected:
virtual void initialize() override {
width = 640; // Example dimensions
height = 480;
maxPixelValue = 255;
originalImage.resize(height, std::vector<int>(width, 0)); // Initialize with some original image data
receivedImage.resize(height, std::vector<int>(width, 0)); // Initialize with received image data
}
virtual void handleMessage(cMessage *msg) override {
// Assume msg contains received image data; populate receivedImage with it.
// Calculate MSE
double mse = 0.0;
for (int i = 0; i < height; i++) {
for (int j = 0; j < width; j++) {
mse += pow(originalImage[i][j] – receivedImage[i][j], 2);
}
}
mse = mse / (width * height);
// Calculate PSNR
double psnr = 10 * log10((maxPixelValue * maxPixelValue) / mse);
// Record and display PSNR
recordScalar(“Network PSNR (dB)”, psnr);
EV << “Network PSNR: ” << psnr << ” dB” << endl;
delete msg;
}
};
In this simulation, we know how to estimate the PSNR in the images and video frames over the network using the OMNeT++ tool. We will outline the steps involved in performing the PSNR in different simulation settings.