이 질문을 팔로우합니다.
- 팔로우하는 게시물 피드에서 업데이트를 확인할 수 있습니다.
- 정보 수신 기본 설정에 따라 이메일을 받을 수 있습니다.
오류 발생
페이지가 변경되었기 때문에 동작을 완료할 수 없습니다. 업데이트된 상태를 보려면 페이지를 다시 불러오십시오.
이전 댓글 표시
0 개 추천
my code is
A=imread('imagcp.bmp');
A=A(:);
YourVector=double(A);
symbols = unique(YourVector(:));
counts = hist(YourVector(:), symbols);
p = double(counts) ./ sum(counts)
[dict,avglen]=huffmandict(symbols,p);
comp=huffmanenco(A,dict);
I want to dispaly image after encoding,plz help
채택된 답변
Walter Roberson
2012년 12월 26일
0 개 추천
"comp" is not something that can be displayed. You need to do a huffman decoding of "comp" with "dict" in order to restore the image.
댓글 수: 7
FIR
2012년 12월 27일
편집: Walter Roberson
2012년 12월 27일
walter i have displayed decoded image but the thing is i need encoded image to be displayed and find compression ratio
my code
clc
clear all
a=imread('cameraman.tif')
I=a;
[m,n]=size(I);
Totalcount=m*n;
cnt=1;
sigma=0;
%computing the cumulative probability.
for i=0:255
k=I==i;
count(cnt)=sum(k(:))
pro(cnt)=count(cnt)/Totalcount;
sigma=sigma+pro(cnt);
cumpro(cnt)=sigma;
cnt=cnt+1;
end;
symbols = [0:255];
%Huffman code Dictionary
dict = huffmandict(symbols,pro);
%function which converts array to vector
vec_size = 1;
for p = 1:m
for q = 1:n
newvec(vec_size) = I(p,q);
vec_size = vec_size+1;
end
end
%Huffman Encodig
hcode = huffmanenco(newvec,dict);
%Huffman Decoding
dhsig1 = huffmandeco(hcode,dict);
% convertign dhsig1 double to dhsig uint8
dhsig = uint8(dhsig1);
%vector to array conversion
dec_row=sqrt(length(dhsig));
dec_col=dec_row;
%variables using to convert vector 2 array
arr_row = 1;
arr_col = 1;
vec_si = 1;
for x = 1:m
for y = 1:n
back(x,y)=dhsig(vec_si);
arr_col = arr_col+1;
vec_si = vec_si + 1;
end
arr_row = arr_row+1;
end
imshow(back),title('decoded_Image')
Notice that your code never resets arr_col to 1 when the row changes. Not that it matters in your code as you never use arr_col or arr_row for anything.
I don't know why you don't use reshape() to construct "back", but anyhow...
Assuming that your image is square is a bad idea. You should take my earlier advice of including the sizes along with the data being logically transmitted (that is, include the sizes at the beginning of hcode, and strip them out of hcode before decoding.
Does the assignment say anything about having to display the encoded image in the form of an image ? If it does, then
imagesc(hcode)
and prepare to be underwhelmed (and to get a warning about how the image has been scaled down to fit in the window.)
FIR
2012년 12월 27일
shows the encoded image,why i get like this,
please as per ur advice can u send the code for dislaying encoded and decoded image as u said the code above is not sufficient as u said to use reshape,plz assist in sending some codes
Instead of your "for x" "for y" loop,
back = reshape(dhsig, n, m) .';
As to why the encoded image shows up like it does, what were you expecting when you display a vector of binary values?
FIR
2012년 12월 27일
ok walter thanks
FIR
2012년 12월 27일
walter but why the size increases after encoding
Walter Roberson
2012년 12월 27일
Each element of the output represents one bit. The original data was 8 bits per element.
추가 답변 (0개)
카테고리
도움말 센터 및 File Exchange에서 Denoising and Compression에 대해 자세히 알아보기
태그
참고 항목
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!웹사이트 선택
번역된 콘텐츠를 보고 지역별 이벤트와 혜택을 살펴보려면 웹사이트를 선택하십시오. 현재 계신 지역에 따라 다음 웹사이트를 권장합니다:
또한 다음 목록에서 웹사이트를 선택하실 수도 있습니다.
사이트 성능 최적화 방법
최고의 사이트 성능을 위해 중국 사이트(중국어 또는 영어)를 선택하십시오. 현재 계신 지역에서는 다른 국가의 MathWorks 사이트 방문이 최적화되지 않았습니다.
미주
- América Latina (Español)
- Canada (English)
- United States (English)
유럽
- Belgium (English)
- Denmark (English)
- Deutschland (Deutsch)
- España (Español)
- Finland (English)
- France (Français)
- Ireland (English)
- Italia (Italiano)
- Luxembourg (English)
- Netherlands (English)
- Norway (English)
- Österreich (Deutsch)
- Portugal (English)
- Sweden (English)
- Switzerland
- United Kingdom (English)
