Implement Method #1 Using the algorithm given. Method #1: include zero and no wrap-around. Method #2: without zero and no wrap-around. Method #3: include zero and wrap-around. Method #4: without zero...

Implement the run length encoding-decoding method 1 in Java.


Implement Method #1 Using the algorithm given. Method #1: include zero and no wrap-around. Method #2: without zero and no wrap-around. Method #3: include zero and wrap-around. Method #4: without zero and wrap-around. Language: Java I. Input (args [0]): a txt file representing an image (gray-scale or binary), where the first text line has 4 integers, representing the "header" of the input image numRows, numCols, minVal, maxVal, follows by rows and cols of pixel values (integers). Example-1 for gray-scale image, 5 8 0 9 // The image has 5 rows, 8 columns, min value is 0 and max value is 9 0 0 8 8 8 8 9 9 9 0 7 7 8 8 9 0 0 0 9 9 9 9 9 9 9 9 1 1 8 8 2 2 3 3 1 1 5 5 5 0 II. a) Encoded file (NOT from args): to be created during the run-time, to store EncodeMethod1. The format for the result of an encoded image is given below. 5 8 0 9 1 0 0 0 2 0 2 8 4 0 6 9 2 : b) Decoded file (NOT from args): is created during the run-time to store EncodeMethod1_Decoded. // Note: If the program works, the Decode file should be the same as the input file. III. Data structure: You may add other variables as needed - runLength class - numRows (int) - numCols (int) - minVal (int) - maxVal (int) - numRuns (int) - whichMethod (int) // for this project it is 1. - nameEncodeFile (string) - nameDecodeFile (string) - encodeMethod1 (…) // Given below. - decodeMethod1 (…) // Use the algorithm steps given IV. main (…) step 0: inFile <- open="" args[0],="" the="" input="" image="" files="" numrows,="" numcols,="" minval,="" maxval=""><- read="" from="" infile="" whichmethod=""><- 1="" step="" 1:="" nameencodefile=""><- args[0]="" +="" “_encodemethod”="" +="" “whichmethod”="" encodefile=""><- open="" (nameencodefile)="" step="" 2:="" encodefile=""><- output="" numrows,="" numcols,="" minval,="" maxval="" encodefile=""><- output="" whichmethod="" step="" 3:="" encodemethod1="" (infile,="" encodefile)="" algorithm="" steps="" is="" given="" below.="" step="" 4:="" closed="" encodefile="" step="" 5:="" re-open="" encodefile="" step="" 6:="" namedecodefile=""><- nameencodefile="" +="" “_decoded”="" step="" 7:="" decodefile=""><- open="" (namedecodefile)="" step="" 8:="" decodemethod1="" (encodefile,="" decodefile)="" step="" 9:="" close="" all="" files="" v.="" encodemethod1="" (infile,="" encodefile)="" step="" 0:="" row=""><- 0="" step="" 1:="" col=""><- 0="" length=""><- 0="" currval=""><- read="" the="" next="" pixel="" (integer)="" from="" infile="" *one="" integer="" at="" a="" time*="" step="" 2:="" encodefile=""><- output="" row="" and="" col="" and="" currval="" to="" outfile1="" length="" ++="" step="" 3:="" col++="" step="" 4:="" nextval=""><- read="" the="" next="" pixel="" (integer)="" from="" infile="" step="" 5:="" if="" nextval="=" currval="" length="" ++="" else="" encodefile=""><- output="" length="" currval=""><- nextval="" length=""><- 1="" output="" row="" and="" col="" and="" currval="" step="" 6:="" repeat="" step="" 3="" to="" step="" 5="" while="" length="">< numcols="" step="" 7:="" row="" ++="" step="" 8:="" repeat="" step="" 1="" to="" step="" 7="" until="" end="" of="" file="" or="" while="" row="">< numrows="" step="" 9:="" close="" all="" files="" algorithm="" steps="" for="" using="" method="" 1:="" step="" 0:="" open="" infile="" and="" outfile="" row=""><- 0="" col=""><- 0="" length=""><- 0="" step="" 1:="" nrow,="" ncol,="" minval,="" maxval=""><- read="" from="" infile="" outfile="">< -="" nrows,="" ncols,="" minval,="" maxval="" srow=""><- row="" ;="" scol=""><- col="" step="" 2:="" curval=""><- read="" from="" infile="" length++="" ;="" col++="" step="" 3:="" outfile=""><- srow,="" scol,="" curval="" step="" 4:="" nextval=""><- read="" from="" infile="" step="" 5:="" if="" nextval="=" curval="" length++="" else="" nextval="" not="" equal="" to="" curval="" outfile=""><- length="" curval=""><- nextval="" srow=""><- row="" scol=""><- col="" outfile=""><- srow,="" scol,="" curval="" length=""><- 1="" step="" 6:="" col++="" step="" 7:="" repeat="" step="" 4-5="" until="" col="">= NCol Step 8: row++ Col <- 0="" outfile=""><- length="" length=""><- 0 step 9: repeat step 2-8 until eof (infile) 20 20 0 9 0 0 0 0 0 0 7 7 7 7 7 7 7 7 7 4 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="" 3="" 3="" 3="" 3="" 3="" 3="" 3="" 3="" 3="" 3="" 3="" 3="" 0="" 0="" 3="" 3="" 3="" 3="" 3="" 3="" 7="" 7="" 7="" 7="" 7="" 7="" 7="" 7="" 7="" 7="" 7="" 7="" 7="" 7="" 7="" 7="" 7="" 7="" 7="" 0="" 0="" 0="" 0="" 0="" 0="" 0="" 0="" 0="" 0="" 0="" 0="" 1="" 1="" 1="" 1="" 1="" 1="" 1="" 1="" 0="" 0="" 0="" 8="" 8="" 8="" 8="" 9="" 9="" 9="" 9="" 9="" 9="" 9="" 9="" 0="" 0="" 0="" 9="" 9="" 9="" 9="" 9="" 0="" 0="" 0="" 0="" 8="" 8="" 8="" 8="" 8="" 8="" 9="" 9="" 0="" 0="" 0="" 9="" 9="" 9="" 9="" 9="" 0="" 0="" 0="" 0="" 0="" 0="" 0="" 0="" 0="" 0="" 0="" 0="" 0="" 0="" 2="" 2="" 2="" 2="" 2="" 2="" 3="" 4="" 4="" 4="" 4="" 4="" 4="" 0="" 0="" 0="" 0="" 0="" 0="" 0="" 0="" 0="" 0="" 0="" 0="" 0="" 0="" 0="" 0="" 0="" 0="" 0="" 0="" 0="" 0="" 0="" 0="" 0="" 0="" 0="" 0="" 0="" 0="" 0="" 0="" 0="" 0="" 0="" 0="" 0="" 0="" 0="" 0="" 0="" 0="" 0="" 0="" 0="" 0="" 0="" 0="" 0="" 0="" 0="" 0="" 0="" 0="" 0="" 0="" 0="" 0="" 0="" 0="" 1="" 1="" 1="" 1="" 1="" 1="" 1="" 1="" 1="" 1="" 1="" 1="" 1="" 1="" 1="" 1="" 1="" 1="" 1="" 1="" 1="" 1="" 1="" 1="" 1="" 1="" 1="" 1="" 1="" 1="" 6="" 6="" 6="" 6="" 6="" 6="" 6="" 6="" 6="" 6="" 6="" 6="" 6="" 6="" 6="" 6="" 6="" 6="" 6="" 6="" 0="" 0="" 0="" 0="" 0="" 0="" 0="" 0="" 0="" 0="" 0="" 0="" 0="" 0="" 0="" 0="" 0="" 0="" 0="" 0="" 0="" 0="" 0="" 0="" 0="" 0="" 0="" 0="" 0="" 0="" 0="" 0="" 0="" 0="" 0="" 0="" 0="" 0="" 0="" 0="" 0="" 0="" 0="" 0="" 0="" 0="" 0="" 0="" 0="" 0="" 0="" 0="" 0="" 0="" 0="" 0="" 0="" 0="" 0="" 0="" 0="" 0="" 0="" 0="" 0="" 0="" 0="" 0="" 0="" 0="" 0="" 0="" 0="" 0="" 0="" 0="" 0="" 0="" 0="" 0="" 0="" 0="" 0="" 0="" 0="" 0="" 0="" 0="" 0="" 0="" 9="" 9="" 9="" 9="" 9="" 0="" 0="" 0="" 9="" 9="" 9="" 9="" 9="" 8="" 9="" 7="" 7="" 7="" 7="">
Sep 29, 2021
SOLUTION.PDF

Get Answer To This Question

Related Questions & Answers

More Questions »

Submit New Assignment

Copy and Paste Your Assignment Here