Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

I'm struggling with that please answer correctly please, if you need the full code please let me know. thanks in advance. ] friunctian tp-convert the

I'm struggling with that please answer correctly please, if you need the full code please let me know. thanks in advance. image text in transcribed
image text in transcribed
image text in transcribed
image text in transcribed
image text in transcribed
image text in transcribed
image text in transcribed
image text in transcribed
] friunctian tp-convert the pixel values from an inage into graysealo. frobor Loop over the Litage array and convert the the pixels using this grayacale formula and store them Cith the firocessed array. ff(x=0.299+9=0.587+b=0.114) public void toarayscale () I public elass Image I ff these are the elaps attributef soedea to conplete thle lab f. feage dinensions If Maxyal is used for reading in the ppat file, for the default conatruetor, yos can inte the value as of private int widthr private int: height. private int maxvalo If inage artay and proceened array definitionis (1) conatructors /ropos create an Timage constructor that inikiatizes all the-attribate to a detault value Prtblic Image () 1 widthi =5z height =8z maxta1=6; 1 ff creates an inage ibject by-teading the input image public raage (string input file) I catch (FileNotEoundException ex) ! System.out, printin ("Input: image file mot found!= +ex)t ex.printstackJrace () I It accessors //TODO: get width accessor public int getwidth() I Feturn widdthy MTODO: set width fintator public void setwidth (int w) 1 width =w; F/ToDo: get height aceessor public int getreight() return height, 1 //roDo: set height mutator public void setHeight(int h) I height =h i 1f reads an image from the given input inage tiie //This function is given to you as a helg in underatanding hou the pixel data iu realf and initiallied public void read(string file_name) I ff open the file try 1 Scanner sc = new Scanner(new plle(file_nane)) fl read the header (arsumes ppM text images) (f read the header (assumen PDM text images) string magic; magic= sc. next(); width = sc, nextint(); height = sc.nextint (); maxVal = sc. nextint () ; System.out.println ("Header:" + magic + " " + width + = I + height + " " + maxVall; I/make sure the 1 mage arfey are nutl and then initialize them if (image _array = null) image_array = new intlaidtin*hetght*31; If (processed_array == nu11) processed_array = new int [ width*height*3]t image array [1]= sc.nextint()t 1 cateh (rileNotFoundException ex) I System.out.printin ("Input image file not found" + ex)/ ex.printstack\%race ()) 1 11 displays image uning the Brivess eolor qrid /TTODO: given the colorgeid object and if you want to display a grayseate or noral iaspe, //populate the colorgrid objects with the pixel values from the read in imare. //You can set a colorgrids pixel value by doings cq,aet(1, ), new color(s, d, byt public void setcolorarid (Colorgrid eg, Boolean processed) I if (processed) I for ( int 1=0i

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Advances In Knowledge Discovery In Databases

Authors: Animesh Adhikari, Jhimli Adhikari

1st Edition

3319132121, 9783319132129

More Books

Students also viewed these Databases questions