I have some issues about Reed-Solomon Encoder

8 views (last 30 days)
Hi, someone who will help me!!
I've loaded a image.
And, it has a RGB scale, so I've changed that color scale to gray scale.
(Because , when a RGB scale image is converted to the binary type data, the result was 3-dim matrix.)
(Accurately, it looks like a third order tensor)
And then, I'm given the data of binary type of this image.
From this data, I've applied to Reed-Solomon Code.
So, I made a Galois Field, so that the result was successful.
However, the rsenc code line that is the last line doesn't work.
MATLAB spit the below error out
Error using rsenc (line 69)
MSG must be either a K-element row vector or a matrix with K columns.
Error in Reed_Solomon_Practice(line 22)
code = rsenc(msg, n, k);
How can I resolve this issue??
Help me please!!! :(
The below one is my code.
RGB = imread('img.jpg');
%Convert the image into a binary image.
I = rgb2gray(RGB);
BW = imbinarize(I);
%Display the original image next to the binary version.
%L = logical(mod(BW,2));
%BW(L)
m = 8;
n = 2^m-1; % m=8 -> 255
k = 239;
msg = gf(BW, m);
code = rsenc(msg, n, k); %%%%%% HERE ERROR: WHY? %%%%%%
figure
imshowpair(I,BW,'montage')

Answers (1)

Pratyush Roy
Pratyush Roy on 28 Dec 2020
Hi,
The rsenc function works under a following assumptions:
  1. The value of k in rsenc(msg,n,k) is equal to the number of columns in the Galois field array msg.If msg is 1-dimensional, k must be equal to the number of elements in msg
  2. If k is chosen to be equal to the number of columns of the Galois field array, n is strictly greater than k.
MATLAB will throw an error if at least one of these conditions is violated.
As a workaround, you can consider changing the value of n and k such that the above conditions are met.
Hope this helps!

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!