当前位置:首页 > 代码 > 正文

图像修复的代码(图像修复的代码是什么)

admin 发布:2022-12-19 12:33 111


本篇文章给大家谈谈图像修复的代码,以及图像修复的代码是什么对应的知识点,希望对各位有所帮助,不要忘了收藏本站喔。

本文目录一览:

matlab图像复原维纳滤波,最小二乘方,L-R,盲去卷积图像复原比较的程序代码

clc;clear all;

%读原始图像%

format long

Blurred=imread('fig525(b).bmp');

subplot(1,2,1);imshow( Blurred);title('原图像');

%自编函数进行维纳滤波%

k=0.0025;

[m,n]=size(Blurred);

spectrum=zeros(m,n);

H=zeros(m,n);

for u=1:m

for v=1:n

H(u,v)=exp(-k*((u-m/2)^2+(v-n/2)^2)^(5/6));

spectrum(u,v)=H(u,v)^2;

end

end

f=double(Blurred);

F1=fftshift(fft2(f));

HW=H./(spectrum+0.001);

restore1=HW.*F1;

restored=real(ifft2(ifftshift(restore1)));

subplot(1,2,2);imshow(restored,[]);title('自编函数进行维纳滤波');

%调用matlab提供的维纳滤波函数%

figure;

hw1=real(ifft2(ifftshift(H)));%转化到空域上来

result1=deconvwnr(Blurred,hw1,0.001);

result2=ifftshift(result1);%再去图像进行1,3象限对调,2与4象限对调

subplot(1,2,1);imshow(result2,[]);title('调用维纳滤波函数');

照片损坏如何恢复

第一种方法:

在损坏的图像点击鼠标右键的打开方式,用UltraEdit打开。

然后看看图片二进制代码有没有损坏,

然后拷贝一个可以正常观看的图片格式,用UltraEdit打开参考它的文件开头和文件结束数据块,

然后在你损坏的JPG文件添加正确的文件开头和结束数据块,

第二种方法:

用最新版PHTOPOSHOP9。0(图像编辑软件)打开试试看看,

然后在另存你想要的格式图片这样就可以正常观看了    

照片恢复不成功因素: 删除、剪切或格式化后又放入新文件,将原来内容覆盖破坏

照片损坏如何修复?

您好,方法步骤如下:

1、首先打开格式工厂,用格式工厂,进行照片的修复,到网页浏览器界面,可以下载格式工厂点击右下角的普通下载。

2、下载好之后要对软件进行安装,可以安装到d盘,避免磁盘不必要的浪费空间以及卡顿,安装完后我们要对格式工厂进行调整,可以调动一些小的参数,如果是新人就不必调动格式工厂的数据。

3、打开软件格式工厂后,要注意看界面,有一个图片选项,点进去打开之后要对图片的格式进行调整。如果之前损坏的是gif格式我们要对格式进行改动把它调整成JPG或NPG的格式因为只有这两种格式。

4、点击右方的添加文件,进行打开 按确定,然后添加文件到格式工厂选择添加文件。

5、最后选择已经损坏的照片,按确定即可。

如何用matlab编程将运动模糊图像用维纳滤波法复原?

PSF

=

fspecial('motion',len,ang);

%建立扩散子,其中len是模糊长度,ang是模糊角度

img2=deconvlucy(img,PSF,n);

%用lucy-richardson方法复原图像,其中img是运动模糊图像,PSF是扩散子,n是迭代次数,img2是复原图像

excel点击图片放大恢复正常代码

Dim

v

As

Boolean,

s_with,

s_height

Sub

zoomandback()

ActiveSheet.Shapes("矩形

1").Select

If

v

=

False

Then

Selection.ShapeRange.ScaleWidth

2.5,

msoFalse,

msoScaleFromTopLeft

Selection.ShapeRange.ScaleHeight

2.5,

msoFalse,

msoScaleFromTopLeft

v

=

True

Else

Selection.ShapeRange.ScaleWidth

0.4,

msoFalse,

msoScaleFromTopLeft

Selection.ShapeRange.ScaleHeight

0.4,

msoFalse,

msoScaleFromTopLeft

v

=

False

End

If

End

Sub

其中“矩形1”换成你的图片的代码,然后将这段宏zoomandback指定给你的图片就OK了

求基于BP神经网络的图像复原算法的matlab代码

function Solar_SAE

tic;

n = 300;

m=20;

train_x = [];

test_x = [];

for i = 1:n

%filename = strcat(['D:\Program Files\MATLAB\R2012a\work\DeepLearn\Solar_SAE\64_64_3train\' num2str(i,'%03d') '.bmp']);

%filename = strcat(['E:\matlab\work\c0\TrainImage' num2str(i,'%03d') '.bmp']);

filename = strcat(['E:\image restoration\3-(' num2str(i) ')-4.jpg']);

b = imread(filename);

%c = rgb2gray(b);

c=b;

[ImageRow ImageCol] = size(c);

c = reshape(c,[1,ImageRow*ImageCol]);

train_x = [train_x;c];

end

for i = 1:m

%filename = strcat(['D:\Program Files\MATLAB\R2012a\work\DeepLearn\Solar_SAE\64_64_3test\' num2str(i,'%03d') '.bmp']);

%filename = strcat(['E:\matlab\work\c0\TestImage' num2str(i+100,'%03d') '-1.bmp']);

filename = strcat(['E:\image restoration\3-(' num2str(i+100) ').jpg']);

b = imread(filename);

%c = rgb2gray(b);

c=b;

[ImageRow ImageCol] = size(c);

c = reshape(c,[1,ImageRow*ImageCol]);

test_x = [test_x;c];

end

train_x = double(train_x)/255;

test_x = double(test_x)/255;

%train_y = double(train_y);

%test_y = double(test_y);

% Setup and train a stacked denoising autoencoder (SDAE)

rng(0);

%sae = saesetup([4096 500 200 50]);

%sae.ae{1}.activation_function = 'sigm';

%sae.ae{1}.learningRate = 0.5;

%sae.ae{1}.inputZeroMaskedFraction = 0.0;

%sae.ae{2}.activation_function = 'sigm';

%sae.ae{2}.learningRate = 0.5

%%sae.ae{2}.inputZeroMaskedFraction = 0.0;

%sae.ae{3}.activation_function = 'sigm';

%sae.ae{3}.learningRate = 0.5;

%sae.ae{3}.inputZeroMaskedFraction = 0.0;

%sae.ae{4}.activation_function = 'sigm';

%sae.ae{4}.learningRate = 0.5;

%sae.ae{4}.inputZeroMaskedFraction = 0.0;

%opts.numepochs = 10;

%opts.batchsize = 50;

%sae = saetrain(sae, train_x, opts);

%visualize(sae.ae{1}.W{1}(:,2:end)');

% Use the SDAE to initialize a FFNN

nn = nnsetup([4096 1500 500 200 50 200 500 1500 4096]);

nn.activation_function = 'sigm';

nn.learningRate = 0.03;

nn.output = 'linear'; % output unit 'sigm' (=logistic), 'softmax' and 'linear'

%add pretrained weights

%nn.W{1} = sae.ae{1}.W{1};

%nn.W{2} = sae.ae{2}.W{1};

%nn.W{3} = sae.ae{3}.W{1};

%nn.W{4} = sae.ae{3}.W{2};

%nn.W{5} = sae.ae{2}.W{2};

%nn.W{6} = sae.ae{1}.W{2};

%nn.W{7} = sae.ae{2}.W{2};

%nn.W{8} = sae.ae{1}.W{2};

% Train the FFNN

opts.numepochs = 30;

opts.batchsize = 150;

tx = test_x(14,:);

nn1 = nnff(nn,tx,tx);

ty1 = reshape(nn1.a{9},64,64);

nn = nntrain(nn, train_x, train_x, opts);

toc;

tic;

nn2 = nnff(nn,tx,tx);

toc;

tic;

ty2 = reshape(nn2.a{9},64,64);

tx = reshape(tx,64,64);

tz = tx - ty2;

tz = im2bw(tz,0.1);

%imshow(tx);

%figure,imshow(ty2);

%figure,imshow(tz);

ty = cat(2,tx,ty2,tz);

montage(ty);

filename3 = strcat(['E:\image restoration\3.jpg']);

e=imread(filename3);

f= rgb2gray(e);

f=imresize(f,[64,64]);

%imshow(ty2);

f=double (f)/255;

[PSNR, MSE] = psnr(ty2,f)

imwrite(ty2,'E:\image restoration\bptest.jpg','jpg');

toc;

%visualize(ty);

%[er, bad] = nntest(nn, tx, tx);

%assert(er 0.1, 'Too big error');

关于图像修复的代码和图像修复的代码是什么的介绍到此就结束了,不知道你从中找到你需要的信息了吗 ?如果你还想了解更多这方面的信息,记得收藏关注本站。

版权说明:如非注明,本站文章均为 AH站长 原创,转载请注明出处和附带本文链接;

本文地址:http://ahzz.com.cn/post/8168.html


取消回复欢迎 发表评论:

分享到

温馨提示

下载成功了么?或者链接失效了?

联系我们反馈

立即下载