필자는 다시 한번 orignal 이미지가 필요하지만 반환하는 그레이 스케일 선생님은 처음에 컬러 맵을 사용하여 matlab에서 일어난다 고 말했습니다. 그래서 내가 도와주세요 내 코드는 모양이 너무 다음은 파이썬에서 비슷한 작업을 수행 할matlab colormap in python
암호화 :
import numpy as np
from PIL import Image
x = Image.open('1.jpg', 'r')
x = x.convert('L')
y = np.asarray(x.getdata(), dtype=np.int).reshape((x.size[1], x.size[0]))#changed image to matrix getdata for matrix value # dtype is int type reshape used to break 1d array into 2d array
y = np.asarray(y, dtype=np.uint8)#if values still in range 0-255!
#print(y)
z = y
w = Image.fromarray(y, mode='L')
w.save('grey_scale.bmp')
for i in range(len(z)):
for j in range(len(z[i])):
a = z[i][j]
p = int(bin(a)[2:])
p = '%08d' % p
p = p[::-1]
z[i][j] = int(p, 2)
#print(z)
C = Image.fromarray(z)
C.save('decryption.bmp')
print("DONE")
암호 해독 :
import numpy as np
from PIL import Image
x = Image.open('decryption.bmp', 'r')
y = np.asarray(x.getdata(), dtype=np.int).reshape((x.size[1], x.size[0]))#changed image to matrix getdata for matrix value
#print(y) # dtype is int type reshape used to break 1d array into 2d array
y = np.asarray(y, dtype=np.uint8)#if values still in range 0-255!
#print(y)
z = y
for i in range(len(z)):
for j in range(len(z[i])):
a = z[i][j]
p = int(bin(a)[2:])
p = '%08d' % p
p = p[::-1]
z[i][j] = int(p, 2)
#print(z)
C = Image.fromarray(z)
C.save('Final.bmp')
print("DONE")
나는 당신이 여기 무엇을 찾고 있는지 잘 모르겠습니다. x = x.convert ('L') 라인은 이미지를 그레이 스케일로 변환합니다. 색상 정보가 손실되고 처리량이 줄어들어 색상 정보가 복원되지 않습니다. 톤 매핑에 대해 묻지 않는 한? –
위의 주어진 코드를 수정하여 RGB 이미지를 입력 한 다음 출력을 rgb 이미지로 제공하지만 그레이 스케일로 처리 할 수 있습니까? – prashant