首页
网站开发
桌面应用
管理软件
微信开发
App开发
嵌入式软件
工具软件
数据采集与分析
其他
首页
>
> 详细
代写COP3502、Python程序设计代做
项目预算:
开发周期:
发布时间:
要求地区:
P2: RLE with Images Python
Overview
In this project students will develop routines to encode and decode data for images using run-length encoding
(RLE). Students will implement encoding and decoding of raw data, conversion between data and strings, and
display of information by creating procedures that can be called from within their programs and externally. This
project will give students practice with loops, strings, Python lists, methods, and type-casting.
Run-Length Encoding
RLE is a form of lossless compression used in many industry applications, including imaging. It is intended to
take advantage of datasets where elements (such as bytes or characters) are repeated several times in a row in
certain types of data (such as pixel art in games). Black pixels often appear in long “runs” in some animation
frames; instead of representing each black pixel individually, the color is recorded once, following by the number
of instances.
For example, consider the first row of pixels from the pixel image of a gator
(shown in Figure 1). The color black is “0”, and green is “2”:
Flat (unencoded) data: 0 0 2 2 2 0 0 0 0 0 0 2 2 0_
Run-length encoded data: 2 0 3 2 6 0 2 2 1 0_.
Figure 1 – Gator Pixel Image
The encoding for the entire image in RLE (in hexadecimal) – width, height, and pixels - is:
1E|162032602220121F10721AF21092301210326032308250
\W/ \H/ \------------------------------------------PIXELS-----------------------------------------------/
Image Formatting
The images are stored in uncompressed / unencoded format natively. In addition, there are a few other rules to
make the project more tractable:
1. Images are stored as a list of numbers, with the first two numbers holding image width and height.
2. Pixels will be represented by a number between 0 and 15 (representing 16 unique colors).
3. No run may be longer than 15 pixels; if any pixel runs longer, it should be broken into a new run.
For example, the chubby smiley image (Figure 2) would contain the data shown in Figure 3.
Figure 2 Figure 3 – Data for “Chubby Smiley”
NOTE: Students do not need to work with the image file format itself – they only need to work with lists and
encode or decode them. Information about image formatting is to provide context. Requirements
Student programs must present a menu when run in standalone mode and must also implement several methods,
defined below, during this assignment.
Standalone Mode (Menu)
When run as the program driver via the main() method, the program should:
1) Display welcome message
2) Display color test (ConsoleGfx.test_rainbow)
3) Display the menu
4) Prompt for input
Note: for colors to properly display, it is highly recommended that student
install the “CS1” theme on the project page.
There are five ways to load data into the program that should be provided and four ways the program must be
able to display data to the user.
Loading a File
Accepts a filename from the user and invokes ConsoleGfx.load_file(filename):
Select a Menu Option: 1
Enter name of file to load: testfiles/uga.gfx
Loading the Test Image
Loads ConsoleGfx.test_image:
Select a Menu Option: 2_
Test image data loaded._
Reading RLE String
Reads RLE data from the user in hexadecimal notation with delimiters (smiley example):
Select a Menu Option: 3
Enter an RLE string to be decoded: 28:10:6B:10:10B:10:2B:10:12B:10:2B:10:5B:20:11B:10:6B:10
Reading RLE Hex String
Reads RLE data from the user in hexadecimal notation without delimiters (smiley example):
Select a Menu Option: 4
Enter the hex string holding RLE data: 28106B10AB102B10CB102B105B20BB106B10
Reading Flat Data Hex String
Reads raw (flat) data from the user in hexadecimal notation (smiley example):
Select a Menu Option: 5
Enter the hex string holding flat data:
880bbbbbb0bbbbbbbbbb0bb0bbbbbbbbbbbb0bb0bbbbb00bbbbbbbbbbb0bbbbbb0
Displaying the Image
Displays the current image by invoking the ConsoleGfx.display_image(image_data) method.
Displaying the RLE String
Converts the current data into a human-readable RLE representation (with delimiters):
Select a Menu Option: 7 RLE representation: 28:10:6b:10:10b:10:2b:10:12b:10:2b:10:5b:20:11b:10:6b:10
Note that each entry is 2-3 characters; the length is always in decimal, and the value in
hexadecimal! Displaying the RLE Hex Data
Converts the current data into RLE hexadecimal representation (without delimiters):
Select a Menu Option: 8
RLE hex values: 28106b10ab102b10cb102b105b20bb106b10
Displaying the Flat Hex Data
Displays the current raw (flat) data in hexadecimal representation (without delimiters):
Select a Menu Option: 9
Flat hex values: 880bbbbbb0bbbbbbbbbb0bb0bbbbbbbbbbbb0bb0bbbbb00bbbbbbbbbbb0bbbbbb0
Class Methods
Student classes are required to provide all of the following methods with defined behaviors. We recommend
completing them in the following order:
1. to_hex_string(data)
Translates data (RLE or raw) a hexadecimal string (without delimiters). This method can also aid debugging.
Ex: to_hex_string([3, 15, 6, 4]) yields string "3f64".
2. count_runs(flat_data)
Returns number of runs of data in an image data set; double this result for length of encoded (RLE) list.
Ex: count_runs([15, 15, 15, 4, 4, 4, 4, 4, 4]) yields integer 2.
3. encode_rle(flat_data)
Returns encoding (in RLE) of the raw data passed in; used to generate RLE representation of a data.
Ex: encode_rle([15, 15, 15, 4, 4, 4, 4, 4, 4]) yields list [3, 15, 6, 4].
4. get_decoded_length(rle_data)
Returns decompressed size RLE data; used to generate flat data from RLE encoding. (Counterpart to #2)
Ex: get_decoded_length([3, 15, 6, 4]) yields integer 9.
5. decode_rle(rle_data)
Returns the decoded data set from RLE encoded data. This decompresses RLE data for use. (Inverse of #3)
Ex: decode_rle([3, 15, 6, 4]) yields list [15, 15, 15, 4, 4, 4, 4, 4, 4].
6. string_to_data(data_string)
Translates a string in hexadecimal format into byte data (can be raw or RLE). (Inverse of #1)
Ex: string_to_data ("3f64") yields list [3, 15, 6, 4].
7. to_rle_string(rle_data)
Translates RLE data into a human-readable representation. For each run, in order, it should display the run
length in decimal (1-2 digits); the run value in hexadecimal (1 digit); and a delimiter, ‘:’, between runs. (See
examples in standalone section.)
Ex: to_rle_string([15, 15, 6, 4]) yields string "15f:64".
8. string_to_rle(rle_string)
Translates a string in human-readable RLE format (with delimiters) into RLE byte data. (Inverse of #7)
Ex: string_to_rle("15f:64") yields list [15, 15, 6, 4]. Submissions
NOTE: Your output must match the example output *exactly*. If it does not, you will not receive full credit for
your submission!
File:
Method:
rle_program.py
Submit on ZyLabs
Do not submit any other files!
Part A (5 points)
For part A of this assignment, students will set up the standalone menu alongside the 4 requirements listed on
page 2 of this document. In addition to this, students should also set up menu options 1 (loading an image), 2
(loading specifically the test image), and 6 (displaying whatever image was loaded) in order to help grasp the
bigger picture of the project.
This involves correctly setting up the console_gfx.py file and utilizing its methods. You will use
ConsoleGfx.display_image(...) to display images. Notice how it takes in a decoded list. This is the
format in which you will locally (in your program) store any image data that you are working with. When
the document mentions that something is “loaded” it means that something is stored as a list of flat
(decoded) data.
Part B (60 points)
For part B of this assignment, students will complete the first 6 methods on page 3 of this document. They
must match specifications and pass test cases on chapter 12.2 in Zybooks, which will be your means of
submission for this part of the assignment. Your grade will be the score received on Zybooks. To guarantee
functionality moving forward to part C, it is expected that you will receive full marks for this section.
Part C (35 points)
For part C of this assignment, students will now complete the final 2 methods on page 3 of this document as well
as the remainder of the project involving the menu options and understanding how all the individual methods are
intertwined with each other. You will submit your whole program including the 8 methods listed above and the
main method in chapter 12.3 in Zybooks. We will only test your remaining 2 methods and the main method in
part C.
软件开发、广告设计客服
QQ:99515681
邮箱:99515681@qq.com
工作时间:8:00-23:00
微信:codinghelp
热点项目
更多
代写csc1001、代做python设计程...
2024-12-24
代写practice test preparatio...
2024-12-24
代写bre2031 – environmental...
2024-12-24
代写ece5550: applied kalman ...
2024-12-24
代做conmgnt 7049 – measurem...
2024-12-24
代写ece3700j introduction to...
2024-12-24
代做adad9311 designing the e...
2024-12-24
代做comp5618 - applied cyber...
2024-12-24
代做ece5550: applied kalman ...
2024-12-24
代做cp1402 assignment - netw...
2024-12-24
代写comm751/comm752 big data...
2024-12-24
代写business 114 accounting ...
2024-12-24
代做comp 273 project templat...
2024-12-24
热点标签
mktg2509
csci 2600
38170
lng302
csse3010
phas3226
77938
arch1162
engn4536/engn6536
acx5903
comp151101
phl245
cse12
comp9312
stat3016/6016
phas0038
comp2140
6qqmb312
xjco3011
rest0005
ematm0051
5qqmn219
lubs5062m
eee8155
cege0100
eap033
artd1109
mat246
etc3430
ecmm462
mis102
inft6800
ddes9903
comp6521
comp9517
comp3331/9331
comp4337
comp6008
comp9414
bu.231.790.81
man00150m
csb352h
math1041
eengm4100
isys1002
08
6057cem
mktg3504
mthm036
mtrx1701
mth3241
eeee3086
cmp-7038b
cmp-7000a
ints4010
econ2151
infs5710
fins5516
fin3309
fins5510
gsoe9340
math2007
math2036
soee5010
mark3088
infs3605
elec9714
comp2271
ma214
comp2211
infs3604
600426
sit254
acct3091
bbt405
msin0116
com107/com113
mark5826
sit120
comp9021
eco2101
eeen40700
cs253
ece3114
ecmm447
chns3000
math377
itd102
comp9444
comp(2041|9044)
econ0060
econ7230
mgt001371
ecs-323
cs6250
mgdi60012
mdia2012
comm221001
comm5000
ma1008
engl642
econ241
com333
math367
mis201
nbs-7041x
meek16104
econ2003
comm1190
mbas902
comp-1027
dpst1091
comp7315
eppd1033
m06
ee3025
msci231
bb113/bbs1063
fc709
comp3425
comp9417
econ42915
cb9101
math1102e
chme0017
fc307
mkt60104
5522usst
litr1-uc6201.200
ee1102
cosc2803
math39512
omp9727
int2067/int5051
bsb151
mgt253
fc021
babs2202
mis2002s
phya21
18-213
cege0012
mdia1002
math38032
mech5125
07
cisc102
mgx3110
cs240
11175
fin3020s
eco3420
ictten622
comp9727
cpt111
de114102d
mgm320h5s
bafi1019
math21112
efim20036
mn-3503
fins5568
110.807
bcpm000028
info6030
bma0092
bcpm0054
math20212
ce335
cs365
cenv6141
ftec5580
math2010
ec3450
comm1170
ecmt1010
csci-ua.0480-003
econ12-200
ib3960
ectb60h3f
cs247—assignment
tk3163
ics3u
ib3j80
comp20008
comp9334
eppd1063
acct2343
cct109
isys1055/3412
math350-real
math2014
eec180
stat141b
econ2101
msinm014/msing014/msing014b
fit2004
comp643
bu1002
cm2030
联系我们
- QQ: 9951568
© 2021
www.rj363.com
软件定制开发网!