i am working on Image Compression Using Run Length Encoding

am getting error in scanning in zigzag the error is as follows
Undefined function or variable 'toZigzag'.
Error in rlc_haar (line 21)
ImageArray=toZigzag(QuantizedImage);
plese help me
%%Matlab code for Image Compression Using Run Length Encoding
clc;
clear;
close all;
%%Set Quantization Parameter
quantizedvalue=10;
%%Read Input Image
InputImage=imread('cameraman.tif');
[row col p]=size(InputImage);
%%Wavelet Decomposition
[LL LH HL HH]=dwt2(InputImage,'haar');
WaveletDecomposeImage=[LL,LH;HL,HH];
imshow(WaveletDecomposeImage,[]);
%uniform quantization
QuantizedImage= WaveletDecomposeImage/quantizedvalue;
QuantizedImage= round(QuantizedImage);
% Convert the Two dimensional Image to a one dimensional Array using ZigZag Scanning
ImageArray=toZigzag(QuantizedImage);
%%Run Length Encoding
j=1;
a=length(ImageArray);
count=0;
for n=1:a
b=ImageArray(n);
if n==a
count=count+1;
c(j)=count;
s(j)=ImageArray(n);
elseif ImageArray(n)==ImageArray(n+1)
count=count+1;
elseif ImageArray(n)==b
count=count+1;
c(j)=count;
s(j)=ImageArray(n);
j=j+1;
count=0;
end
end
%%Calculation Bit Cost
InputBitcost=row*col*8;
InputBitcost=(InputBitcost);
c1=length(c);
s1=length(s);
OutputBitcost= (c1*8)+(s1*8);
OutputBitcost=(OutputBitcost);
%%Run Length Decoding g=length(s);
j=1;
l=1;
for i=1:g
v(l)=s(j);
if c(j)~=0
w=l+c(j)-1;
for p=l:w
v(l)=s(j);
l=l+1;
end
end
j=j+1;
end
ReconstructedImageArray=v;
%%Inverse ZigZag
ReconstructedImage=invZigzag(ReconstructedImageArray)
%%Inverse Quantization
ReconstructedImage=ReconstructedImage*quantizedvalue;

4 件のコメント

gowtham munuswami reddy
gowtham munuswami reddy 2019 年 4 月 4 日
can u do this code by using threshloding and RLC
Walter Roberson
Walter Roberson 2019 年 4 月 4 日
Yes, it already does thresholding and Run Length Coding. The thresholding is the quantization step. The Run Length Encoding has a block of commented code right there.
karthika
karthika 2024 年 6 月 16 日
So can't we apply zigzag scanning in rle??
Walter Roberson
Walter Roberson 2024 年 6 月 16 日
Sure, you can combine zigzag scanning with RLE. The resulting code would be unclear and probably would be difficult to maintain. It would probably be much more effective to have a zigzag scan function separate from the RLE function.

サインインしてコメントする。

回答 (1 件)

Walter Roberson
Walter Roberson 2018 年 3 月 28 日

0 投票

The complete code is being sold for 2000 rupees. It is not our place to duplicate commercial code for free.
Code for RLE encoding with zigzag scan has been posted a few times on MATLAB Answers -- zigzag scan is used by JPEG encoding, so there have been a number of posts of the code for that.

カテゴリ

ヘルプ センター および File ExchangeDenoising and Compression についてさらに検索

タグ

質問済み:

2018 年 3 月 28 日

コメント済み:

2024 年 6 月 16 日

Community Treasure Hunt

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

Start Hunting!

Translated by