I,m trying encode, send and put some noise,and decode an Image in Python app using Reed-Solomon coder
I have converted imagage from PIL to numpy array. Now I'm trying to encode this array and then decode it. But I have problem with code word. It's too long. Does anyone know how to solve this problem. Thank You in advance
Error message: ValueError: Message length is max 223. Message was 226
import unireedsolomon as rs
from PIL import Image
import numpy as np
class REED
def __init__(self):
self.img = None
self.numpyImg = None
def loadPictureAndConvertToNumpyArray(self):
self.img = Image.open('PATH')
self.img.load()
self.numpyImg = np.array(self.img)
def reedSolomonEncode(self):
coder = rs.RSCoder(255,223)
self.numpyImg = coder.encode(self.numpyImg)
The ReedSolomon package's github page clearly indicates that you cannot encode arrays that are larger than k (223 in your case). This means that you have to split your image first before encoding it. You can split it into chunks of 223 and then work on the encoded chunks:
k = 223
imgChunks = np.array_split(self.numpyImg, range(k, self.numpyImg.shape[0], k))
encodedChunks = [coder.encode(chunk) for chunk in imgChunks]