- Ensure that the length of your bit string is a multiple of 16. If it is not, pad it with zeros.
- Divide this bit string into segments of 16 bits each. Each segment will correspond to one 4x4 block.
- Convert each 16-bit segment into a 4x4 block. This can be done by reshaping the segment into a 4x4 matrix using “reshape” function.
Encoding the image using Huffman transform and converting to non-overlapping blocks
4 visualizaciones (últimos 30 días)
Mostrar comentarios más antiguos
Hi, I encoded an image with huffman transform and converted the image into a contiguous bit string. I want to convert this bit string into 4x4 blocks. Can anyone guide me?
0 comentarios
Respuestas (1)
Meet
el 12 de Sept. de 2024
Hi Javad,
To convert your Huffman-encoded image bit string into 4x4 blocks you could follow these steps:
Following is a sample code for the same:
% Sample bit string of encoded image after huffman transform.
bitString = '110101011001011011110000100110101010101010101010';
bitStringLength = length(bitString);
% Calculate the number of 4x4 blocks.
numBlocks = bitStringLength / 16;
% Cell array to store final result.
blocks = cell(numBlocks, 1);
% Divide the bit string into 4x4 blocks.
for i = 1:numBlocks
% Extract 16-bit data from the bit string.
bitSegment = bitString((i-1)*16 + 1:i*16);
% Convert the 16-bit data into a 4x4 block
block = reshape(bitSegment, [4, 4])';
blocks{i} = block;
end
% Display the blocks
for i = 1:numBlocks
fprintf('Block %d:\n', i);
disp(blocks{i});
end
You can refer to the resource below for more information:
1 comentario
Walter Roberson
el 12 de Sept. de 2024
bitString = '110101011001011011110000100110101010101010101010';
After all padding has been done, you can use
num2cell(reshape(bitString, 4, 4, []), [1 2])
Ver también
Categorías
Más información sobre Denoising and Compression en Help Center y File Exchange.
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!