WeChall Simply Red (Stegano, Image) 答案
分析
点击问号可以看看提示:
看Gizmore的提示,图片名字很重要,擎天柱(Optimus Prime)
又提到了filter,过滤
解决
有了这些信息:prime素数,以及题目和图片的颜色红色(Red),filter过滤
python代码
from PIL import Image
from math import sqrt
def is_prime(n):
if n==1:
return False
for i in range(2, int(sqrt(n) + 1)):
if n % i == 0:
return False
return True
img = Image.open("op.png")
width = img.size[0]
height = img.size[1]
for x in range(width):
for y in range(height):
r,g,b = img.getpixel((x,y))
if is_prime(r):
continue
else:
img.putpixel((x,y),(255,255,255))
img.show()
程序意思是:分析所有像素点,如果rgb的r值不是素数,就设置成白色。
最终效果:
成功
提交PrimalOffset
即可。
该题解决是参考了:https://powerqwer13.tistory.com/entry/Wechall-Simply-Red
使用python对图片的操作参考了:
Python图像处理库:PIL中Image,ImageDraw等基本模块介绍 - 小唯THU - 博客园
python Image 模块处理图片 - 临渊慕鱼不如退而结网 - 博客园
python image模块 - Django's blog - 博客园