当前位置:网站首页>PTA 1066 image filtering (15 points)
PTA 1066 image filtering (15 points)
2022-06-24 05:10:00 【freesan44】
subject
Image filtering is to dye the unimportant pixels in the image into the background color , Make important parts stand out . Now give a black-and-white image , You are required to replace all pixel colors with a specified color when the gray value is within a specified range .
Input format :
Input gives the resolution of an image on the first line , That is, two positive integers M and N(0<M,N≤500), The other is the end point of the gray value interval to be filtered A and B(0≤A<B≤255)、 And the specified replacement gray value . And then M That's ok , Each line gives N The gray value of a pixel , Separated by spaces . All gray values are in 0, 255 Within the interval .
Output format :
Output the filtered image as required . The output M That's ok , Each row N Pixel gray value , Percentage of each gray value 3 position ( For example, black should be displayed as 000), Separated by a space . There must be no extra space at the beginning and end of the line .
sample input : 3 5 100 150 0 3 189 254 101 119 150 233 151 99 100 88 123 149 0 255 No blank lines at the end sample output : 003 189 254 000 000 000 233 151 099 000 088 000 000 000 255 No blank lines at the end
Their thinking
M,N,A,B,H = map(int,input().split())
# M,N,A,B,H = map(int, "3 5 100 150 0".split(" "))
zongResList = []
for i in range(M):
for j in input().split():
if A <= int(j) <= B:
zongResList.append("%03d" % H)
else:
zongResList.append("%03d" % j)
# The following methods failed in the final case
# # The input is converted to int Of List
# inputList = list(map(int, input().split()))
# # inputList = list(map(int, "3 189 254 101 119".split()))
# resList = []
# for j in inputList:
# res = None
# if A <= int(j) <= B:
# # Make up 0 escape
# # res = "{:0>3d}".format(int(H))
# res = "%03d" % H
# else:
# # Make up 0 escape
# # res = "{:0>3d}".format(int(j))
# res = "%03d" % j
# # resList.append(res)
# zongResList.append(res)
# # zongResList.append(resList)
# # print(" ".join(resList))
for i in range(0, len(zongResList),N):
print(' '.join(zongResList[i:i+N]))边栏推荐
- Leetcode question brushing (question 3) - the longest substring without repeated characters
- Problem: SQL create stored procedure
- Disaster recovery series (IV) - disaster recovery construction of business application layer
- 『渗透基础』Cobalt Strike基础使用入门_Cobalt Strike联动msfconsole
- How does ECS publish websites? What software tools are needed?
- Use of golang testing framework goshub
- What is the new generation cloud computing architecture cipu of Alibaba cloud?
- Black horse programmer machine learning handout: preliminary use of linear regression API
- Tencent conference rest API x-tc-registered parameter policy update notification
- LeetCode 1290. Binary linked list to integer
猜你喜欢

Intensive learning and application of "glory of the king" to complete the application of 7 real worlds other than human players

014_ TimePicker time selector

011_ Cascader cascade selector

What are the disadvantages of the free IP address replacement tool?

CTF learning notes 17:iwesec file upload vulnerability-02 file name filtering bypass
![[leetcode daily question] push domino](/img/81/1c31e97d9a245816514bcf47c92107.jpg)
[leetcode daily question] push domino

『渗透基础』Cobalt Strike基础使用入门_Cobalt Strike联动msfconsole

Leetcode (question 2) - adding two numbers

Analysis on the subjective enthusiasm of post-90s makers' Education

Training methods after the reform of children's programming course
随机推荐
How does the mobile phone remotely connect to the ECS? What should be paid attention to during the operation
Problem: SQL create stored procedure
Training methods after the reform of children's programming course
What are the functions and advantages of the Internet of things cloud platform?
GDB debugging container and command saving
Jimureport building block report - expression introduction
Skillfully compiling openwrt routing firmware with pay as you go ECS
Tencent cloud installs Kedao cloud - build an exclusive private cloud disk
Inventory of common tools used by dry goods | data journalists
Cos+cdn realizes the distribution of game client version files in a faster, better and cheaper manner
Activity recommendation | cloud native community meetup phase VII Shenzhen station begins to sign up!
What is the new generation cloud computing architecture cipu of Alibaba cloud?
[leetcode daily question] push domino
Understanding OAuth 2.0
Spirit breath development log (12)
Customer disaster recovery case - a MySQL database migration scheme
The principle of defer keyword in go
Ext4 file system jam caused by MEM CGroup OOM
Functional advantages of industrial wireless router
Panoramic recording, WYSIWYG new recording scheme, and exclusive preferential resource package as low as 1 yuan!