Welcome to the Java Programming Forums


The professional, friendly Java community. 21,500 members and growing!


The Java Programming Forums are a community of Java programmers from all around the World. Our members have a wide range of skills and they all have one thing in common: A passion to learn and code Java. We invite beginner Java programmers right through to Java professionals to post here and share your knowledge. Become a part of the community, help others, expand your knowledge of Java and enjoy talking with like minded people. Registration is quick and best of all free. We look forward to meeting you.


>> REGISTER NOW TO START POSTING


Members have full access to the forums. Advertisements are removed for registered users.

Results 1 to 5 of 5

Thread: Peak signal to noise ratio code ...how to take input and get the out morever my code is not running plzz help

  1. #1
    Junior Member
    Join Date
    Mar 2014
    Posts
    2
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default Peak signal to noise ratio code ...how to take input and get the out morever my code is not running plzz help

    ************************************************** *******************
    */
    import java.io.*;

    public class Psnr {

    public static double log10(double x) {
    return Math.log(x)/Math.log(10);
    }

    public static void main (String[] args) {
    int nrows, ncols;
    int img1[][], img2[][];
    double peak, signal, noise, mse;

    if (args.length != 4) {
    System.out.println("Usage: Psnr <nrows> <ncols> <img1> <img2>");
    return;
    }
    nrows = Integer.parseInt(args[0]);
    ncols = Integer.parseInt(args[1]);
    img1 = new int[nrows][ncols];
    img2 = new int[nrows][ncols];
    ArrayIO.readByteArray(args[2], img1, nrows, ncols);
    ArrayIO.readByteArray(args[3], img2, nrows, ncols);

    signal = noise = peak = 0;
    for (int i=0; i<nrows; i++) {
    for (int j=0; j<ncols; j++) {
    signal += img1[i][j] * img1[i][j];
    noise += (img1[i][j] - img2[i][j]) * (img1[i][j] - img2[i][j]);
    if (peak < img1[i][j])
    peak = img1[i][j];
    }
    }

    mse = noise/(nrows*ncols); // Mean square error
    System.out.println("MSE: " + mse);
    System.out.println("SNR: " + 10*log10(signal/noise));
    System.out.println("PSNR(max=255): " + (10*log10(255*255/mse)));
    System.out.println("PSNR(max=" + peak + "): " + 10*log10((peak*peak)/mse));
    }
    }


  2. #2
    Member
    Join Date
    Oct 2013
    Location
    Manila, Philippines
    Posts
    285
    My Mood
    Amused
    Thanks
    6
    Thanked 64 Times in 61 Posts

    Default Re: Peak signal to noise ratio code ...how to take input and get the out morever my code is not running plzz help

    What is your question?
    is there any errors in your code? if so, please paste it here.

  3. #3
    Junior Member
    Join Date
    Mar 2014
    Posts
    2
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default Re: Peak signal to noise ratio code ...how to take input and get the out morever my code is not running plzz help

    ArrayIO.readByteArray(args[2], img1, nrows, ncols);
    ArrayIO.readByteArray(args[3], img2, nrows, ncols);
    errors r cuming in these two lines
    when i compile the above program it compile but does not run

    --- Update ---

    do i need to import files for
    ArrayIO.readByteArray(args[2], img1, nrows, ncols);
    ArrayIO.readByteArray(args[3], img2, nrows, ncols);
    please help

    --- Update ---

    I need PSNR code to run smoothly

  4. #4
    Member
    Join Date
    Oct 2013
    Location
    Manila, Philippines
    Posts
    285
    My Mood
    Amused
    Thanks
    6
    Thanked 64 Times in 61 Posts

    Default Re: Peak signal to noise ratio code ...how to take input and get the out morever my code is not running plzz help

    what does it says when you run it? can you create a print right after the main method and then compile and run again?

  5. #5
    Member
    Join Date
    Feb 2014
    Posts
    180
    Thanks
    0
    Thanked 48 Times in 45 Posts

    Default Re: Peak signal to noise ratio code ...how to take input and get the out morever my code is not running plzz help

    Psnr and ArrayIO were written by Yuan-Liang Tang. Use of code without the author's permission and attribution is plagiarism. Please post here evidence from the author that you are free to use them.

Similar Threads

  1. what is wrong with my code its not running
    By javacodeaddict in forum What's Wrong With My Code?
    Replies: 1
    Last Post: March 18th, 2014, 05:36 PM
  2. [SOLVED] n00b having problems running code
    By cha0s619 in forum What's Wrong With My Code?
    Replies: 10
    Last Post: November 10th, 2012, 04:31 PM
  3. help needed to know how the code is running
    By Dark knight in forum Java Theory & Questions
    Replies: 9
    Last Post: July 30th, 2012, 07:18 PM
  4. need to know how the code is running
    By Dark knight in forum Java Theory & Questions
    Replies: 3
    Last Post: July 19th, 2012, 10:28 AM
  5. can' stop working a part of code.plzz help
    By kyros in forum What's Wrong With My Code?
    Replies: 2
    Last Post: October 30th, 2010, 04:10 PM