您现在的位置:首页 >> ★免费资源 >> 源码下载 >> 内容

matlab代做|FPGA代做-matlab图像代写编程霍夫曼图像压缩重建

时间:2018-2-6 23:21:05 点击:

  核心提示:"matlab代做|matlab专业点做|FPGA代做|FPGA专业点做|simulink代做|simulink专业点做 QQ :1224848052 微信:HuangL1121 邮箱:1224848052@qq.com" ...

matlab代做|matlab专业点做|FPGA代做|FPGA专业点做|simulink代做|simulink专业点做
QQ  :1224848052
微信:HuangL1121
邮箱:1224848052@qq.com"

function SnapImage()

imagesPath = '.\\snap_images';
if ~exist(imagesPath, 'dir')
    mkdir(imagesPath);
end

[FileName,PathName,FilterIndex] = uiputfile({'*.jpg;*.tif;*.png;*.gif','All Image Files';...
          '*.*','All Files' },'保存截图',...
          '.\\snap_images\\temp.jpg');
if isequal(FileName, 0) || isequal(PathName, 0)
    return;
end
fileStr = fullfile(PathName, FileName);
f = getframe(gcf);
f = frame2im(f);
imwrite(f, fileStr);
msgbox('抓图文件保存成功!', '提示信息');

function SaveImage(Img)

imagesPath = '.\\results';
if ~exist(imagesPath, 'dir')
    mkdir(imagesPath);
end

[FileName,PathName,FilterIndex] = uiputfile({'*.jpg;*.tif;*.png;*.gif','All Image Files';...
          '*.*','All Files' },'保存截图',...
          '.\\results\\result.jpg');
if isequal(FileName, 0) || isequal(PathName, 0)
    return;
end
fileStr = fullfile(PathName, FileName);
imwrite(mat2gray(Img), fileStr);
 

function S=PSNR(sss,aaa)

[m n p]=size(sss);
A=double(sss);
B=double(aaa);
sumaDif=0;
maxI=m*n*max(max(A.^2));
for u=1:m
    for v=1:n
        sumaDif=sumaDif+(A(u,v)-B(u,v))^2;
    end
end
if  (sumaDif==0)
    sumaDif=1;
end
S=maxI/sumaDif;
S=10*log10(S);


function [zvec, zi] = Mat2Huff(vec)

if ~isa(vec,'uint8')
    fprintf('\n请确认输入uint8类型数据向量!\n');
    return;
end

vec = vec(:)';
f = Frequency(vec);
syminfos = find(f~=0); 
f = f(syminfos);
[f, sind] = sort(f);
syminfos = syminfos(sind);
len = length(syminfos);
syminfos_ind = num2cell(1:len);
cw_temp = cell(len,1);
while length(f)>1
    ind1 = syminfos_ind{1};
    ind2 = syminfos_ind{2};
    cw_temp(ind1) = AddNode(cw_temp(ind1),uint8(0));
    cw_temp(ind2) = AddNode(cw_temp(ind2),uint8(1));
    f = [sum(f(1:2)) f(3:end)];
    syminfos_ind = [{[ind1 ind2]} syminfos_ind(3:end)];
    [f,sind] = sort(f);
    syminfos_ind = syminfos_ind(sind);
end
cw = cell(256,1);
cw(syminfos) = cw_temp;
len = 0;
for i = 1 : length(vec),
    len = len+length(cw{double(vec(i))+1});
end
str_temp = repmat(uint8(0),1,len);
pt = 1;
for index=1:length(vec)
    cd = cw{double(vec(index))+1};
    len = length(cd);
    str_temp(pt+(0:len-1)) = cd;
    pt = pt+len;
end
len = length(str_temp);
pad = 8-mod(len,8);
if pad > 0
    str_temp = [str_temp uint8(zeros(1,pad))];
end
cw = cw(syminfos);
cl = zeros(size(cw));
ws = 2.^(0:51);
mcl = 0;
for index = 1:length(cw)
    len = length(cw{index});
    if len>mcl
        mcl = len;
    end
    if len>0
        cd = sum(ws(cw{index}==1));
        cd = bitset(cd,len+1);
        cw{index} = cd;
        cl(index) = len;
    end
end
cw = [cw{:}];
cols = length(str_temp)/8;
str_temp = reshape(str_temp,8,cols);
ws = 2.^(0:7);
zvec = uint8(ws*double(str_temp));
huffcodes = sparse(1,1);
for index = 1:numel(cw)
    huffcodes(cw(index),1) = syminfos(index);
end
zi.pad = pad;
zi.huffcodes = huffcodes;
zi.ratio = cols./length(vec);
zi.length = length(vec);
zi.maxcodelen = mcl;

    
function vec = Huff2Mat(zvec, zi)
if ~isa(zvec,'uint8')
    fprintf('\n请确认输入uint8类型数据向量!\n');
    return;
end
len = length(zvec);
str_tmp = repmat(uint8(0),1,len.*8);
bi = 1:8;
for index = 1:len
    str_tmp(bi+8.*(index-1)) = uint8(bitget(zvec(index),bi));
end
str_tmp = logical(str_tmp(:)'); 
len = length(str_tmp);
str_tmp((len-zi.pad+1):end) = []; 
len = length(str_tmp);
vec = repmat(uint8(0),1,zi.length);
vi = 1;
ci = 1;
cd = 0;
for index = 1:len
    cd = bitset(cd,ci,str_tmp(index));
    ci = ci+1;
    byte = Decode(bitset(cd,ci),zi);
    if byte > 0
        vec(vi) = byte-1;
        ci = 1;
        cd = 0;
        vi = vi+1;
    end
end

function InitFig(hObject,handles)
axes(handles.axes1); 
cla; axis on; box on;
set(gca, 'Color', [0.8039 0.8784 0.9686]);
set(gca, 'XTickLabel', [], 'YTickLabel', [], 'XTick', [], 'YTick', []);
axes(handles.axes2); 
cla; axis on; box on;
set(gca, 'Color', [0.8039 0.8784 0.9686]);
set(gca, 'XTickLabel', [], 'YTickLabel', [], 'XTick', [], 'YTick', []);
set(handles.textInfo, 'String', ...
    '图像压缩系统,载入图像,选择压缩算法,比较压缩效果。');   

作者:matlab代做|FPGA代做-matlab图像代写编程霍夫曼图像压缩重建 来源:matlab代做|FPGA代做-matlab图像代写编程霍夫曼图像压缩重建
  • 您是如何找到本站的?
  • 百度搜索
  • Google搜索
  • 查阅资料过程中
  • 论坛发现
  • 百度贴吧发现
  • 朋友介绍
本站最新成功开发工程项目案例
相关文章
相关评论
发表我的评论
  • 大名:
  • 内容:
  • matlab代做|matlab专业代做|matlab淘宝代做(www.hslogic.com) © 2018 版权所有 All Rights Reserved.
  • Email:highspeed_logic@163.com 站长QQ: 1224848052

    专业代做/代写/承接、MATLAB、SIMULINK、FPGA项目、博士/硕士/本科毕业设计、课题设计、论文,毕业论文,Coursework、Eassy、Assignment