📄 wavesyn.m
字号:
function [syn, low, im] = wavesyn(file, nlevels, wname)
% WAVESYN Wavelet-based texture synthesis
%
% Input:
% file: filename of the input texture image
% Support all formats by imread
% nlevels: number of wavelet decomposition levels
% wname: string of wavelet name
%
% Output:
% syn: synthetic texture image (low + synthetic details)
% low: texture image from low resolution
%
% See also: WAVEFEAT
% Read in the image
if ischar(file)
im = imread(file);
% If image is true color, convert it into an intensity image
if ndims(im) == 3
im = double(rgb2gray(im));
else
im = double(im);
end
else
% Input is a matrix
im = double(file);
end
% Standard wavelet decomposition
[c, s] = wavedec2(im, nlevels, wname);
nbands = 3 * nlevels;
% Options for use in GGMLE
options = optimset('display', 'off', 'TolX', 1e-6, 'MaxIter', 10);
for b = 1:nbands
ind = sbind2(s, b);
band = c(ind);
% Features from model parameters
% Maximum likelihood estimation
[alpha, beta] = ggmle(band, options);
% Generate subband coefficients based on model parameters
r = ggrnd(alpha, beta, 1, length(band));
% Update wavelet coefficients
c(ind) = r;
end
% Reconstruct with generated detail coefficients
syn = waverec2(c, s, wname);
% And also recontructed approximation at coarset level
if nargout > 1
low = wrcoef2('a', c, s, wname, nlevels);%computes the matrix of reconstructed approximation coefficients of nlevels, based on the wavelet decomposition structure[c,s]
end
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -