资源简介

CDD模型彩色图像修复系统,matlab语言。十分高效、效果显著。内含matlab源代码、注释及图片素材。可去除白色遮挡物,如旧照白色裂痕、白色涂鸦、白色文字,基本100%去除。

资源截图

代码片段和文件信息

close all;
clc;
clear;
%--------------------------读入图像------------------------------------------
imgoriginal=imread(‘c1003.bmp‘);                 %待处理的图片转化为矩阵,黑白2维矩阵,彩色三维,例a=imread(xxx.jpg)R=a(::1); G=a(::2); B=a(::3);
figure(1);                                       %figure创建图像,imshow显示图片,一起为避免覆盖
imshow(imgoriginal);                             %显示待处理的图片
[widthheight] = size(imgoriginal);              %size(),获取图片矩阵的行数为width、列数为height
img= double(imgoriginal);                        %转换成double精度
%--------------------------获取掩码图像(mask遮挡物)---------------------------------------------
mask = zeros(widthheight/33); 
for j = 1:height/3
    for i = 1:width
        if ((imgoriginal(ij1) >220)&&(imgoriginal(ij2) >220)&&(imgoriginal(ij3) >220)) 
            mask(ij1) = 255;                   %灰度255=白 ,0=黑
            mask(ij2) = 255; 
            mask(ij3) = 255; 
        else 
            mask(ij1) = 0; 
            mask(ij2) = 0;
            mask(ij3) = 0; 
        end 
    end 
end 
figure(2);
imshow(mask);                                    %显示遮挡物
%--------------------------更新原图修复区域内每点值------------------------------------------
a=zeros(widthheight);                           %生成全0矩阵
I=cat(3a2*a3*a);
J=cat(3a2*a3*a);
n = 1; 
itertimes=1000;                                  %迭代时间 iteration迭代
tic;                                             %tic与toc,记录命令执行的时间
while n <= itertimes
    for i = 2:width-1
        for j = 2:height/3-1
           if (mask(ij+11) == 255)||(mask(ij-11) == 255)||(mask(i+1j1) == 255)||(mask(i-1j1) == 255)
                for k=1:3 
                grid_w(k) = (img(ijk)-img(i-1jk))^2+(1.0/16)*(img(i-1j+1k)+img(ij+1k)-img(i-1j-1k)-img(ij-1k))^2;
                grid_e(k) = (img(ijk)-img(i+1jk))^2+(1.0/16)*(img(ij+1k)+img(i+1j+1k)-img(ij-1k)-img(i+1j-1k))^2;
                grid_s(k) = (img(ijk)-img(ij-1k))^2+(1.0/16)*(img(i+1jk)+img(i+1j-1k)-img(i-1jk)-img(i-1j-1k))^2;
                grid_n(k) = (img(ijk)-img(ij+1k))^2+(1.0/16)*(img(i+1jk)+img(i+1j+1k)-img(i-1jk)-img(i-1j+1k))^2;
                I(ijk)=0.5*(img(i+1jk)-img(i-1jk))/sqrt(0.25*(img(i+1jk)-img(i-1jk))^2+0.25*(img(ij+1k)-img(ij-1k))^2+1);
                J(ijk)=0.5*(img(ij+1k)-img(ij-1k))/sqrt(0.25*(img(i+1jk)-img(i-1jk))^2+0.25*(img(ij+1k)-img(ij-1k))^2+1);
                Kw(k)=sqrt((I(ijk)-I(i-1jk)+(I(i-1j+1k)+I(ij+1k)-I(i-1j-1k)-I(ij-1k))/2)^2+(J(ijk)-J(i-1jk)+(J(i-1j+1k)+J(ij+1k)-J(i-1j-1k)-J(ij-1k))/2)^2);
                Ke(k)=sqrt((I(i+1jk)-I(ijk)+(I(ij+1k)+I(i+1j+1k)-I(ij-1k)-I(i+1j-1k))/2)^2+(J(i+1jk)-J(ijk)+(J(ij+1k)+J(i+1j+1k)-J(ij-1k)-J(i+1j-1k))/2)^2);
                Ks(k)=sqrt((I(ijk)-I(ij-1k)+(I(i+1jk)+I(i+1j-1k)-I(i-1jk)-I(i-1j-1k))/2)^2+(J(ijk)-J(ij-1k)+(J(i+1jk)+J(i+1j-1k)-J(i-1jk)-J(i-1j-1k))/2)^2);
                

 属性            大小     日期    时间   名称
----------- ---------  ---------- -----  ----
     目录           0  2018-10-21 17:37  CDD\
     文件      196662  2012-10-04 21:21  CDD\C1.bmp
     文件      196662  2012-10-04 22:35  CDD\C1001.bmp
     文件      196662  2012-10-04 23:30  CDD\C1003.bmp
     文件      196662  2012-10-04 23:34  CDD\C1004.bmp
     文件      196662  2012-04-20 20:58  CDD\C13.bmp
     文件      196662  2012-04-20 20:55  CDD\C13x.bmp
     文件        3960  2018-10-21 17:36  CDD\CDD.m
     文件      196662  2012-05-01 10:26  CDD\CDD_n100.bmp
     文件      196662  2012-10-04 23:32  CDD\CDD_n1000.bmp
     文件      196662  2012-10-04 23:36  CDD\CDD_n10004.bmp
     文件      196662  2012-05-01 10:27  CDD\CDD_n200.bmp
     文件      196662  2012-05-01 10:23  CDD\CDD_n50.bmp
     文件      196662  2018-10-21 15:28  CDD\CDD修复后.bmp
     文件       66614  2012-10-07 20:44  CDD\TV1.bmp
     文件       66614  2012-04-14 18:39  CDD\bc.bmp
     文件       66614  2012-11-06 23:20  CDD\cdd.bmp
     文件       66614  2012-10-04 20:24  CDD\cdd2_abcd.bmp
     文件      786486  2012-04-20 22:03  CDD\dt.bmp
     文件      786486  2012-04-20 22:03  CDD\dtx.bmp
     文件      126849  2016-10-27 13:52  CDD\yuan.png
     文件      113992  2018-10-05 22:04  CDD\图片2.png

评论

共有 条评论