当前位置:网站首页>[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
边栏推荐
- 如何获取自由和财富
- Individual problem solution of the 298th round of force deduction
- BSV上的委托合约(3)
- 【第 07 章 基于主成分分析的人脸二维码识别MATLAB深度学习实战案例】
- 众昂矿业:萤石稀缺资源属性增强,未来或出现供需缺口
- NOIP 提高组 初赛 三、问题求解 习题集NOIP1995-NOIP2018
- Leetcode + 46 - 50
- acwing 837. Number of points in connected blocks (additional information maintained by querying sets - number of sets)
- 数学知识复习:三重积分
- The sandbox has reached a cooperation with Time magazine to establish "New York Times Square" in metauniverse
猜你喜欢

Test APK exception control WiFi scan attacker development

【第 15 章 基于小波的图像压缩技术深度学习机器学习的图像处理应用matlab.】

【Proteus仿真】INT0和INT1中断计数

功能测试——MySQL数据库简介

BSV上的委托合约

The Sandbox 与《时代周刊》达成合作,在元宇宙建立“纽约时报广场”
![[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]

DAST 黑盒漏洞扫描器 第四篇:扫描性能

数字信号处理

【第 01 章 基于直方图优化的图像去雾技术-全套系统MATLAB智能驾驶深度学习】
随机推荐
数字信号处理
【第 17 章 基于 Harris 的角点特征检测--Matlab机器学习项目实战】
word中mathtype公式右编号右对齐
Mysql数据库轻松学07—select语句书写顺序及执行顺序
MBA-day18 消元法
【随笔】昨天研究了一天 RN 生态的 Expo 的确牛逼,从开发构建到部署一条龙,很好使。
Shell脚本语法概览
联发科技 --联发科技简介++附上笔经面经
The Sandbox 与《时代周刊》达成合作,在元宇宙建立“纽约时报广场”
GAMES-101-个人总结归纳-Transformation
Winform项目控制台调试方式
GAMES-101-个人总结归纳-Rasterization
测试用例设计方法——因果图法
MBA-day23 至多至少问题-练习题
twenty-one
Download links to components, frameworks and development tools commonly used by programmers
LeetCode+ 46 - 50
shadertoy 实现简易指南针
第 25 章 基于小波变换的数字水印技术
第 24 章 基于 Simulink 进行图像和视频处理--matlab深度学习实战整理