用matlab将图像分离块 *** 作 怎样在图像中选择其中的一部分进行分离块 *** 作?给我个程序,谢谢!

用matlab将图像分离块 *** 作 怎样在图像中选择其中的一部分进行分离块 *** 作?给我个程序,谢谢!,第1张

楼主太不专业了,还分块呢???是类似小波分州和凳解吧棚简,哈哈

刚好做了一段:

clear all

A=imread('Door.jpg') %读入原图

B=rgb2gray(A)%转灰度图像

newmap=rgb2gray(A)

C=double(B)

nbcol=size(B,1)

[cA1,cH1,cV1,cD1]=dwt2(C,'册旅db1') %第一次分解

dec1d=[cA1,cH1cV1,cD1]

[cA2,cH2,cV2,cD2]=dwt2(cA1,'db1') %第二次分解

dec2d=[cA2,cH2cV2,cD2]

% function [Ahat2, shat, n_iteration Test] = nc_fastica_svd(xold,typeStr,N,A)

function [shat Ahat2] = nc_fastica_svd(xold,typeStr,N)

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

%

% non-circular complex FastICA算法,基于型唤Newton迭代法,类似与fastICA

% ************************input***************************

% xold:混合信号,m*n,m为阵元衡橡数,n为快拍数

% typeStr: 非线性函数,'log'卜拦凯, 'kurt', or 'sqrt'

% **************************output**************************

% Ahat:解混矩阵

% shat: 估计的源信号

% ********************************************************

% Reference

% Mike Novey and T. Adali, "On Extending the complex FastICA algorithm

% to noncircular sources" in

% (To appear 2007/2008) IEEE Journel on Signal Processing.,

%

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

type = 0

if strcmp(typeStr,'log') == 1

type = 1

elseif strcmp(typeStr,'kurt') == 1

type = 2

elseif strcmp(typeStr,'sqrt') == 1

type = 3

end

tol = 1e-5

a2 = 0.1

defl = 1% components are estimated one by one in a deflationary mannerset this to 0 if you want them all estimated simultaneously

maxcounter = 50

[n,m] = size(xold)

% Whitening of s:

yyy = zeros(1,m)

[Ex, Dx] = svd(cov(xold'))

E = Ex(:,1:N)

D = Dx(1:N,1:N)

Q = mtimes(sqrt(inv(D)),E')

x = Q * xold

%Pseudo-covariance

pC = (x*transpose(x))/m

% FIXED POINT ALGORITHM

W = eye(N)

Wold = zeros(N)

k = 0

while (norm(abs(Wold'*W)-eye(N),'fro')>(N*1e-12) &&k <15*N)

k = k+1

Wold = W

for kk=1:N %Loop thru sources

yy = W(:,kk)'*x

absy =abs(yy).^2

%%Fixed point

if type == 1 %%log

g = 1./(a2 + absy)

gp = -1./(a2 + absy).^2

elseif type == 2 %Kurt

g = absy

gp = ones(size(absy))

elseif type == 3 %sqrt

g = 1./(2*sqrt(a2 + absy))

gp = -1./(4*(a2 + absy).^(3/2))

end

gRad = mean(ones(N,1)*(g.*conj(yy)).*x,2)

ggg = mean(gp.*absy + g)

B = mean(gp .* conj(yy).^2)*pC

W(:,kk) = Wold(:,kk)*(ggg) -(gRad) + (B*conj(Wold(:,kk)))

end

%Orthonormalization

[E,D] = eig(W'*W)

W = W * E * inv(sqrt(D)) * E'

end%Loop thru sources

n_iteration = k

shat = W'*x%Estimated sources

% Ahat1 = inv(Q)*W

Ahat2 = W'*Q

这个是NC-fastica,可以用。稍微注释了些

原始程序,不知道是谁写的了


欢迎分享,转载请注明来源:内存溢出

原文地址: https://outofmemory.cn/yw/12400951.html

(0)
打赏 微信扫一扫 微信扫一扫 支付宝扫一扫 支付宝扫一扫
上一篇 2023-05-25
下一篇 2023-05-25

发表评论

登录后才能评论

评论列表(0条)

保存