Clear Filters
Clear Filters

Need help with trellis structure

10 views (last 30 days)
Neeraj Chimwal
Neeraj Chimwal on 28 Apr 2021
Answered: Sudarsanan A K on 12 Oct 2023
I am trying to encode my image with convolution encoding method but I am having difficulty in understanding how to create trellis structure with my image.
I want to use convenc(msg,trellis) to encode the image.
Please help me out with this

Answers (1)

Sudarsanan A K
Sudarsanan A K on 12 Oct 2023
Hi Neeraj,
It is my understanding that you are trying to encode an image with convolutional encoding, and you are facing difficulty in understanding the creation of the trellis structure with your image.
A trellis diagram represents the state transitions of a convolutional encoder. Each node in the trellis represents a unique combination of the encoder's internal states, and the edges connecting the nodes represent the possible state transitions.
The following example shows a step-by-step approach to create a trellis structure and encode an image using convolutional encoding in MATLAB.
  • Step 1: Import your image into MATLAB using the "imread()" function. Make sure the image is in grayscale format for simplicity.
>> img = imread('your_image.jpg');
  • Step 2: Convert the pixel values of the image into a binary sequence. You can use the "de2bi()" function to convert each pixel value into its binary representation.
>> binary_seq = de2bi(img(:), 8, 'left-msb');
  • Step 3: Create a trellis structure using the "poly2trellis()" function. This function takes two arguments: the constraint length and the generator polynomials. The constraint length represents the number of previous input bits that affect the current output bit, and the generator polynomials define the encoder's logic.
constraint_length = 3; % Example value, adjust as needed
generator_polynomials = [7 5]; % Example values, adjust as needed
>> trellis = poly2trellis(constraint_length, generator_polynomials);
  • Step 4: Encode the binary sequence using the "convenc()" function. This function takes two arguments: the binary sequence and the trellis structure.
>> encoded_seq = convenc(binary_seq, trellis);
After executing these steps, you should have the encoded sequence stored in the "encoded_seq" variable. Keep in mind that the choice of the constraint length and generator polynomials depends on your specific requirements and the desired trade-off between error correction capability and encoding complexity. Adjust these values according to your needs.
Additionally, you can refer to the MathWorks documentation on converting convolutional code polynomials to trellis in the link:
Further, to know more about the "convec()" function, refer to the MathWorks documentation in the link:
Hope this helps resolve your query.

Community Treasure Hunt

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

Start Hunting!