Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6712789
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 26, 20262026-05-26T08:18:03+00:00 2026-05-26T08:18:03+00:00

I really need help with the java program…i am getting errors when i am

  • 0

I really need help with the java program…i am getting errors when i am running the programs.
My goal for this lab is to combine two images into a single 3 dimension image. These images will be viewed using red/blue glasses to give the 3D effect. The final image will attempt to be a grayscale of the object in the original original images. I have to verify that the two images have the same width and height before attempting to create the 3D image. If the images do not match, print out an error message and exit the program.

error: width cannot be resolved

    height cannot be resolved

i wrote the program as below…

public class 3dImage {

    public static void main(String[] args) {

        // Access and open the picture
        String filename = FileChooser.pickAFile ();
        Picture p1 = new Picture (filename);

        //second picture
        String filename2 = FileChooser.pickAFile ();
        Picture p2 = new Picture (filename);

        //get the width and height from p1 and p2
        Picture p3;
        p3 = new Picture (width, height);

        // call the method to modify the Pictture
        modifyPicture (p1, p2, p3);

        // explore (display) the picture    
        p3.explore();
    }  // end of main


    public static void modifyPicture (Picture p1, Picture p2, Picture p3) {

        // get the width and height of the picture
        int width = p1.getWidth();
        int height = p1.getHeight();

        //shows width and height
        System.out.println ("Width: " + width + ", Height: " + height);

        // loop over the pixels
        for (int xPos = 0 ; xPos < width ; ++xPos) {
            for (int yPos = 0 ; yPos < height ; ++yPos) {         
                //  access the pixel to be modifed
                Pixel pix1 = p1.getPixel (xPos, yPos);
                Pixel pix2 = p2.getPixel (xPos, yPos);
                Pixel pix3 = p3.getPixel (xPos, yPos);  

                // modify the pixel 

                int redAmount = pix1.getRed (255);
                int greenAmount = pix1.getGreen (0);
                int blueAmount = pix1.getBlue (0);                
                int grayAmount1 = (int)(redAmount * 0.299 + greenAmount * 0.587 + blueAmount * 0.114);   

                redAmount = pix2.getRed(0);
                greenAmount = pix2.getGreen(255);
                blueAmount = pix2.getBlue(255);
                int grayAmount2 = (int)(redAmount * 0.299 + greenAmount * 0.587 + blueAmount * 0.114);

                pix3.setRed (grayAmount1);
                pix3.setGreen (grayAmount2);
                pix3.setBlue (grayAmount2);
                // …
            }
        }
    }
}

I am stuck here and i need help..

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-26T08:18:04+00:00Added an answer on May 26, 2026 at 8:18 am
    p3 = new Picture (width, height);
    

    Neither width nor height has been declared. You need to declare them and set to appropriate values. As you did in modifyPicture function.

    Make sure p1, p2 and p3 have the same size, otherwise modifyPicture won’t work correctly.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I really need help on this one. I am having a simple login form
Sorry to bother again, but I really need help transforming this Python2 code into
I really need your help for this. I am relatively new to programming and
I really need some help with this as I have been trying to fix
This is a followup question to one I previously asked: start-program-if-not-already-running-in-java I didn't get
I'm new to Java and really need your help. I am presently using a
I really need help with interfaces in general... Any resources that you guys would
Well, I know absolutely nothing about the subject, so I really need help. I
I really need your help in my issue very quickly and it's too close
I really need some help in Regular Expressions, i'm working on a function like

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.