当前位置:网站首页>[Chapter 15 wavelet based image compression technology deep learning machine learning image processing application matlab.]
[Chapter 15 wavelet based image compression technology deep learning machine learning image processing application matlab.]
2022-06-22 01:55:00 【Haibao 7】
The first 15 Chapter Wavelet based image compression technology –matlab Deep learning algorithm to achieve sorting source code analysis
The main function
main.m
clc; clear all; close all;
filename = fullfile(pwd, 'images', 'cameraman.tif');
x = imread(filename);
num = 2;
[cf_vec, dim_vec] = wavedec_process(x, num, 'haar');
th = 10;
y = waverec_process(cf_vec, dim_vec, 'haar', th);
output_img(x, y, filename, th, 'png');
p = PSNR(x,y);
fprintf('\n Image before and after compression PSNR The value is %.2f\n', p);
Case effect display :


Function Directory :
Output subfunction :
function output_img(x, y, filename, th, ext)
if nargin < 5
ext = 'png';
end
[~, file, ~] = fileparts(filename);
foldername = fullfile(pwd, 'output');
if ~exist(foldername, 'dir')
mkdir(foldername);
end
file1 = fullfile(foldername, sprintf('%s_origin.%s', file, ext));
file2 = fullfile(foldername, sprintf('%s_wave_%.1f.%s', file, th, ext));
imwrite(x, file1);
imwrite(y, file2);
info1 = imfinfo(file1);
info2 = imfinfo(file2);
fprintf('\n The storage space required for the image before compression is %.2fbytes', info1.FileSize);
fprintf('\n The storage space required for the compressed image is %.2fbytes', info2.FileSize);
fprintf('\n The file size ratio is %.2f', info1.FileSize/info2.FileSize);
Drawing subfunction 1
function plot_wave_coef(cf_vec)
dn = 3;
num = (length(cf_vec)-1)/dn;
figure;
subplot(num+1, 3, 2);
yt = im2uint8(mat2gray(cf_vec{
1}));
imshow(yt, []);
title(sprintf(' Approximate component A_{%d}', num));
info = {
' Vertical details V', ' Level of detail H', ' Diagonal details D'};
ps = 2;
for i = 1 : num
for j = 1 : dn
yt = im2uint8(mat2gray(cf_vec{
ps}));
subplot(num+1, dn, ps+2);
imshow(yt, []);
title(sprintf('%s_{%d}', info{
j}, num-i+1));
ps = ps+1;
end
end
Drawing subfunction 2
function plot_wave_coef_join(cf_vec,dim_vec)
dn = 3;
num = (length(cf_vec)-1)/dn;
tmpa = wkeep(cf_vec{
1}, dim_vec(1, :), 'c');
tmpa = im2uint8(mat2gray(tmpa));
tmpa(1, :) = 255; tmpa(end, :) = 255;
tmpa(:, 1) = 255; tmpa(:, end) = 255;
for j = 1:num
tmpv = wkeep(cf_vec{
(j-1)*dn+2}, dim_vec(j, :), 'c');
tmph = wkeep(cf_vec{
(j-1)*dn+3}, dim_vec(j, :), 'c');
tmpd = wkeep(cf_vec{
(j-1)*dn+4}, dim_vec(j, :), 'c');
tmpv = im2uint8(mat2gray(tmpv));
tmph = im2uint8(mat2gray(tmph));
tmpd = im2uint8(mat2gray(tmpd));
tmpv(1, :) = 255; tmpv(end, :) = 255;
tmpv(:, 1) = 255; tmpv(:, end) = 255;
tmph(1, :) = 255; tmph(end, :) = 255;
tmph(:, 1) = 255; tmph(:, end) = 255;
tmpd(1, :) = 255; tmpd(end, :) = 255;
tmpd(:, 1) = 255; tmpd(:, end) = 255;
tmp = [tmpa,tmpv;tmph,tmpd];
stc = size(tmp);
if stc >= dim_vec(j+1, :)
tmpa = tmp(1:dim_vec(j+1, 1), 1:dim_vec(j+1,2));
else
tmp = tmp([1:end-1, end-2:end-1], [1:end-1, end-2:end-1]);
tmpa = tmp(1:dim_vec(j+1, 1), 1:dim_vec(j+1,2));
end
tmpa = im2uint8(mat2gray(tmpa));
tmpa(1, :) = 255; tmpa(end, :) = 255;
tmpa(:, 1) = 255; tmpa(:, end) = 255;
end
figure;
imshow(tmpa, []);
title(' Tower graph of wavelet coefficients ');
PSNR
If not used in inverse discrete cosine transform 8 As a coefficient , But use 4 As a coefficient , The image quality will deteriorate . To calculate the peak signal-to-noise ratio of the input image and the image after inverse discrete cosine transform ! Then the bit rate of inverse discrete cosine transform is obtained
Peak signal to noise ratio (Peak Signal to Noise Ratio) Abbreviation for PSNR, The ratio of the maximum possible power of a signal to the destructive noise power that affects its representation accuracy , It can display the degree of image quality loss .
Tips : The content is organized from :
https://github.com/gzr2017/ImageProcessing100Wen
The higher the peak signal-to-noise ratio , Indicates that the smaller the image quality loss . The peak signal-to-noise ratio is defined by the following formula .MAX Represents the maximum value of the image point color . If the range is [0,255] Words , that MAX The value is 255. Reference source
PSNR Processing function
function S=PSNR(s,t)
[m, n, ~]=size(s);
s = im2uint8(mat2gray(s));
t = im2uint8(mat2gray(t));
s = double(s);
t = double(t);
sd = 0;
mi = m*n*max(max(s.^2));
for u = 1:m
for v = 1:n
sd = sd+(s(u,v)-t(u,v))^2;
end
end
if sd == 0
sd = 1;
end
S = mi/sd;
S = 10*log10(S);
Partial reference :https://blog.csdn.net/weixin_29732003/article/details/122569893
SNR Is the reciprocal of the coefficient of variation , Same as the coefficient of variation , Eliminate units and ( or ) The influence of different means on the comparison of variation degree of two or more data , At the same time, there may be a corresponding relationship between the numerical value and the visual image quality :
SNR The higher the , The less discrete the pixels are , image quality ( Probably ) The better .
Code source of this article Arrangement –> Portal
边栏推荐
- es-object vs nested vs has_child and has_parent
- 第 03 章 基于多尺度形态学提取眼前节组织-全套系统MATLAB智能驾驶深度学习
- Intranet learning notes (9)
- Amazon evaluation browser, core knowledge points of Amazon evaluation risk control
- 众昂矿业:萤石稀缺资源属性增强,未来或出现供需缺口
- Leetcode + 46 - 50
- Commission contract on BSV (3)
- 【第 17 章 基于 Harris 的角点特征检测--Matlab机器学习项目实战】
- 第 09 章 基于特征匹配的英文印刷字符识别 MATLAB深度学习实战案例
- 【第 20 章 基于帧间差法进行视频目标检测--MATLAB软件深度学习应用】
猜你喜欢

acwing 835. Trie字符串统计

Intranet learning notes (3)

初识Unity3D(项目结构、ProBuilder第三方插件)

Creating a successful paradigm for cross-border e-commerce: Amazon cloud technology helps sellers lay out the next growth point

测试用例设计方法——因果图法

Test APK exception control sensor attacker development

Redis缓存异常及处理方案总结

Expenditure budget and adjustment records and use records output use progress construction process records
![[Chapter 10: a website digital verification code recognition based on moment invariants matlab deep learning practical application case]](/img/19/867c03660cb9127dbb967402d8ca8f.png)
[Chapter 10: a website digital verification code recognition based on moment invariants matlab deep learning practical application case]

acwing 835. Trie string statistics
随机推荐
AHA C language Chapter 5 the good play is later (Lecture 24-25)
众昂矿业:萤石稀缺资源属性增强,未来或出现供需缺口
【第 06 章 MATLAB实现基于分水岭分割进行肺癌诊断】
2020 csp-j1 csp-s1 first round preliminary round answer analysis and summary, video, etc
Redis cache exceptions and handling scheme summary
【第 17 章 基于 Harris 的角点特征检测--Matlab机器学习项目实战】
NOIP初赛 CSP-J1 CSP-S1 第1轮 初赛 信奥中的数学知识(一)
如何获取自由和财富
抓包工具:Fiddler,软件测试工程师必备技能
Apache Doris real-time data analysis nanny level tutorial
The Sandbox 与《时代周刊》达成合作,在元宇宙建立“纽约时报广场”
Creating a successful paradigm for cross-border e-commerce: Amazon cloud technology helps sellers lay out the next growth point
Benchmarking copilot, the first in China: natural language one click generation method level code aixcoder XL is coming
Five strokes first lesson fingering
Heidisql always makes errors when inserting data. What should I do
测试apk-异常管控WiFi Scan攻击者开发
[amd comprehensive job search experience sharing 618]
Divide the list into boxes and draw a histogram through pyechart
机器学习编译第1讲:机器学习编译概述
NVIDIA written interview questions sorting DIY