亚洲欧美第一页_禁久久精品乱码_粉嫩av一区二区三区免费野_久草精品视频

? 歡迎來到蟲蟲下載站! | ?? 資源下載 ?? 資源專輯 ?? 關(guān)于我們
? 蟲蟲下載站

?? relativediffusion.m

?? 3D shape reconstruction matlab code. It used shape from defocus technique with diffusion. You can re
?? M
字號:
% 
% Depth from Defocus via Diffusion
%
% Copyright 2006 Paolo Favaro (p.favaro@hw.ac.uk)
% 
% School of Engineering and Physical Sciences
% Heriot-Watt University, Edinburgh, UK
% 
% Last revision: August 2006
%
% This program can be used only for research purposes.
% This program is distributed WITHOUT ANY WARRANTY; 
% without even the implied warranty of MERCHANTABILITY 
% or FITNESS FOR A PARTICULAR PURPOSE.

clear all
close all

No = 0;
Yes = 1;

% set the maximum number of iterations
MaxIterations = 100;

fprintf('Shape estimation via relative diffusion\n\n');
% shape type (wave, slope, box, sin, plane, realdata)
notValid = Yes;
while notValid
    shape = input(['What test do you want to perform?'...
        '\nChoose wave, slope, box, sin, plane, realdata: '],'s'); 
    notValid = ~strcmp(shape,'wave')&...
        ~strcmp(shape,'slope')&...
        ~strcmp(shape,'box')&...
        ~strcmp(shape,'sin')&...
        ~strcmp(shape,'plane')&...
        ~strcmp(shape,'realdata');
end

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% Dataset initialization
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% choose between loading or generating defocused images
LoadImage = strcmp(shape,'realdata');
if LoadImage == No
    % generate synthetic image
    fprintf('Generating synthetic dataset...');
    % set image size
    M = 101; % use odd numbers
    N = 101; % use odd numbers
    % lens parameters
    F = 12e-3; % focal length
    Fnumb = 2; % F number
    D = F/Fnumb; % aperture (effective lens diameter)
    gamma = 2e4; % calibration parameter
    p = 1./(1/F-1./[.52 .85]); % distance CCD-lens
    K = length(p); % number of focus settings
    % generate depth map
    [X,Y] = meshgrid([-(N-1)/2:(N-1)/2],[-(M-1)/2:(M-1)/2]);
    switch shape
        case 'wave'
            DepthMap = (1+cos(-(X.^2+Y.^2)/200))./...
                sqrt(X.^2/8600+Y.^2/8600+1)/2*.33+.52;
        case 'slope'
            % along X
            DepthMap = (X-min(X(:)))/(max(X(:))-min(X(:)))*.33+.52;
        case 'box'
            block1 = floor(M/5:M/5*3);
            block2 = floor(M/5*2:M/5*4);
            block3 = floor(N/10:N/2);
            block4 = floor(N/10*4:N/10*9);
            DepthMap = ones(M,N)*.52;
            DepthMap(block1,block3) = ...
                DepthMap(block1,block3)+.2;
            DepthMap(block2,block4) = ...
                DepthMap(block2,block4)+.13;
        case 'sin'
            DepthMap = (sin(X/3)+1)/2*.33+.52;
        otherwise % plane
            DepthMap = .05+ones(M,N)*sum(p)*F/(sum(p)-2*F);
    end
    % compute true domain
    OmegaTruth = double(DepthMap<sum(p)*F/(sum(p)-2*F));
    % generate random texture (test algorithm on different intensities)
    a1 = 50; a2 = 120; a3 = 255;
    Radiance = [a1*rand(floor(M/3),N);...
        a2*rand(floor(M/3),N);...
        a3*rand(M-2*floor(M/3),N)]+1; % skip zero
    % add space-varying blurring to test performance of algorithm with
    % different textures (high-freq to low-freq)
    TextureDepth = p(1)*F/(p(1)-F)*ones(M,N)+...
        [zeros(M,floor(N/3)) ...
        .15*ones(M,floor(N/3)) ...
        .3*ones(M,N-2*floor(N/3))];
    % set camera parameters
    parms.m = M;
    parms.n = N;
    parms.F = F;
    parms.Fnumb = Fnumb;
    parms.D = D;
    parms.gamma = gamma;
    % same settings for second image
    parms(2) = parms(1);
    % plane in focus distance (from the lens)
    parms(1).p = p(1);
    parms(2).p = p(2);
    % blur the radiance in three columns
    % compute the relative diffusion map
    Sigma = (gamma*D/2*abs(1-p(1).*(1/F-1./TextureDepth))).^2;
    Radiance = synthesize(Radiance,Sigma);
    % synthesizing blurred images
    Sigma1 = (gamma*D/2*abs(1-p(1).*(1/F-1./DepthMap))).^2;
    Sigma2 = (gamma*D/2*abs(1-p(2).*(1/F-1./DepthMap))).^2;
    I(:,:,1) = synthesize(Radiance,Sigma1);
    I(:,:,2) = synthesize(Radiance,Sigma2);
    % select the domain where the data term is considered
    ww = 3;
    mask = ones(M,N);
    mask(1:ww,:) = 0;
    mask(end-ww+1:end,:) = 0;
    mask(:,1:ww) = 0;
    mask(:,end-ww+1:end) = 0;
    dt_data = 2e-1;% data term step
    dt_reg  = 2e-1;% regularization term step
    maxDelta = 1; % max amount of relative blur
    win = 2; % regularization of initial depth map
    fprintf('done\n');
else
    % load images
    fprintf('Loading dataset...');
    load('DataSet.mat');
    % first resize
    scalingFactor = 1/2;
    I1 = imresize(I1,scalingFactor); % limit number of computations
    I2 = imresize(I2,scalingFactor); % limit number of computations
    % select region of interest
    I(:,:,2) = I1(1:end-10,60:end-50);
    I(:,:,1) = I2(1:end-10,60:end-50);
    [M,N,K] = size(I);
    % lens parameters
    F = 12e-3; % focal length
    Fnumb = 2; % F number
    D = F/Fnumb; % aperture (effective lens diameter)
    gamma = 3e4; % calibration parameter
    p = 1./(1/F-1./[.52 .85]); % distance CCD-lens)
    % set camera parameters
    parms.m = M;
    parms.n = N;
    parms.F = F;
    parms.Fnumb = Fnumb;
    parms.D = D;
    parms.gamma = gamma;
    % same settings for second image
    parms(2) = parms(1);
    % plane in focus distance (from the lens)
    parms(1).p = p(1);
    parms(2).p = p(2);
    % select the domain where the data term is considered
    ww = 3;
    mask = ones(M,N);
    mask(1:ww,:) = 0;
    mask(end-ww+1:end,:) = 0;
    mask(:,1:ww) = 0;
    mask(:,end-ww+1:end) = 0;
    dt_data = 2e-1;%6e-1; % data term step
    dt_reg  = 1e0;%2e0;  % regularization term step
    maxDelta = 1; % max amount of relative blur
    win = 5; % regularization of initial depth map
    K = length(p); % number of focus settings
    fprintf('done\n')
end

% preconditioning threshold
thresh = 6e-2;

% choose whether to use the fast initialization or not
% init type (Y,N)
notValid = Yes;
while notValid
    init = input(['Do you want to use '...
                  'the fast initialization (Y/N)?'],'s'); 
    notValid = ~strcmp(init,'Y')&...
        ~strcmp(init,'N');
end

if strcmp(init,'Y')
    % initialize depth map
    DepthMap_e = initialize(I,maxDelta,win,gamma,F,D,p,'l2');
else
    % initialize depth map with a plane
    DepthMap_e = sum(p)*F/(sum(p)-2*F)*ones(M,N);
end

% compute the relative diffusion map
Sigma1 = (gamma*D/2*abs(1-p(1).*(1/F-1./DepthMap_e))).^2;
Sigma2 = (gamma*D/2*abs(1-p(2).*(1/F-1./DepthMap_e))).^2;
Dsigma = Sigma2-Sigma1;

% start deblurring iterations
fprintf('Shape estimation (%3i iterations)\n     ',MaxIterations);
for i=1:MaxIterations
    %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
    % visualize estimated depth map
    figure(1)
    set(gcf,'name',sprintf('Iteration %3i out of %3i',i,MaxIterations));
    if LoadImage == No
        % data is synthetic; show ground truth
        subplot(221)
        image([I(:,:,1) 200*ones(size(I,1),10) I(:,:,2)])
        axis equal
        axis off
        set(gca,'XTick',[],'YTick',[]);
        set(gca,'Box','off');
        colormap gray(256)
        title('Input #1/#2')
        drawnow;
        subplot(222)
        imagesc([DepthMap_e>sum(p)*F/(sum(p)-2*F) ...
                 .8*ones(size(I,1),10) ...
                 DepthMap>sum(p)*F/(sum(p)-2*F)])
        axis equal
        axis off
        colormap gray(256)
        title('Estimated/True Segmentation')
        drawnow;
        step = ceil(min([size(DepthMap_e,1) ...
               size(DepthMap_e,2)])/50);
        pix2mm = 1/200;
        [X,Y] = meshgrid(pix2mm*[1:step:size(DepthMap_e,2)],...
                pix2mm*[1:step:size(DepthMap_e,1)]);
        [X2,Y2] = meshgrid(pix2mm*(N+[1:step:size(DepthMap_e,2)]),...
                pix2mm*([1:step:size(DepthMap_e,1)]));
        axisZ = 1./(1/F-1./p);
        subplot(223)
        h1 = surf(X2,-DepthMap(1:step:end,1:step:end),-Y2,DepthMap(1:step:end,1:step:end));
        shading interp
        hold on
        h = surf(X,-DepthMap_e(1:step:end,1:step:end),-Y,DepthMap_e(1:step:end,1:step:end));
        shading interp
        hold off
        axis([0 2*N -axisZ(2) -axisZ(1) -M 0])
        set(gca,'XTick',[],'YTick',[],'ZTick',[]);
        colormap gray(256)
        title('Estimated(red)/True(blue) Depth Map')
        %legend('True Depth','Estimated Depth');
        view([-1 -2 1]);
        axis equal
        axis off
        set(h1,'EdgeColor','b');
        set(h,'EdgeColor','r');
        drawnow;
        subplot(224)
        imagesc([DepthMap_e ...
                 max(DepthMap(:))*ones(size(I,1),10) ...
                 DepthMap]);
        colormap gray(256)
        %axis off
        axis equal
        set(gca,'XTick',[],'YTick',[]);
        set(gca,'Box','off');
        title('Estimated/True Depth Map')
        drawnow;
    else
        % data is real
        subplot(211)
        image([I(:,:,1) 200*ones(size(I,1),10) ...
               I(:,:,2) 200*ones(size(I,1),10) ...
               256*(DepthMap_e>sum(p)*F/(sum(p)-2*F))])
        axis equal
        axis off
        set(gca,'XTick',[],'YTick',[]);
        set(gca,'Box','off');
        colormap gray(256)
        title('Input #1/Input #2/Estimated Segmentation')
        drawnow;
        step = ceil(min([size(DepthMap_e,1) ...
               size(DepthMap_e,2)])/50);
        pix2mm = 1/600;
        [X,Y] = meshgrid(pix2mm*[1:step:size(DepthMap_e,2)],...
                pix2mm*[1:step:size(DepthMap_e,1)]);
        axisZ = 1./(1/F-1./p);
        subplot(223)
        h = surf(X,-DepthMap_e(1:step:end,1:step:end),-Y,DepthMap_e(1:step:end,1:step:end));
        shading interp
        hold off
        axis([0 N -axisZ(2) -axisZ(1) -M 0])
        set(gca,'XTick',[],'YTick',[],'ZTick',[]);
        colormap gray(256)
        title('Estimated Depth Map')
        %legend('True Depth','Estimated Depth');
        view([-1 -2 1]);
        axis equal
        axis off
        set(h,'EdgeColor','r');
        drawnow;
        subplot(224)
        imagesc(DepthMap_e);
        colormap gray(256)
        %axis off
        axis equal
        set(gca,'XTick',[],'YTick',[]);
        set(gca,'Box','off');
        title('Estimated Depth Map')
        drawnow;
    end
    %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
    % end visualization
    %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

    %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
    % Optimization procedure starts here %
    %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
    modelnoise = 0;
    sensornoise = 0;
    Omega = double(Dsigma>0); % Heaviside function
    delta = zerocrossing(Dsigma); % Dirac delta
    % compute diffusion PDE solution by simulation
    [dummy,u1] = synthesize(I(:,:,1),Dsigma.*Omega,...
        modelnoise,sensornoise,5);
    [dummy,u2] = synthesize(I(:,:,2),-Dsigma.*(1-Omega),...
        modelnoise,sensornoise,5);
    % compute initial conditions for the adjoint PDE
    w01 = reshape(u1(:,:,end),M,N)-I(:,:,2);
    % compute adjoint diffusion PDE solution by simulation
    [dummy,w1] = synthesize(w01,Dsigma.*Omega,...
        modelnoise,sensornoise,5);
    w02 = reshape(u2(:,:,end),M,N)-I(:,:,1);
    % compute adjoint diffusion PDE solution by simulation
    [dummy,w2] = synthesize(w02,-Dsigma.*(1-Omega),...
        modelnoise,sensornoise,5);
    %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
    % cost functional gradients computation %
    %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
    % time integration (from 0 to T) of grad v grad u
    [dvdu1] = timeintegrate(u1,w1);
    % time integration (from 0 to T) of grad v grad u
    [dvdu2] = timeintegrate(u2,w2);
    dEdc = -2*Omega.*dvdu1+2*(1-Omega).*dvdu2+...
            delta.*((u1(:,:,end)-I(:,:,2)).^2-...
            (u2(:,:,end)-I(:,:,1)).^2);
    % preconditioning
    [dummy,p1] = synthesize(reshape(I(:,:,2),M,N,1),...
                  Dsigma.*Omega,modelnoise,sensornoise,5);
    [dummy,p2] = synthesize(reshape(I(:,:,1),M,N,1),...
                 -Dsigma.*(1-Omega),modelnoise,sensornoise,5);
    % time integration (from 0 to T) of grad p grad u
    [dpdu1] = timeintegrate(u1,p1);
    [dpdu2] = timeintegrate(u2,p2);
    precond = 1+abs(-2*Omega.*dpdu1+2*(1-Omega).*dpdu2);
    dEdc = dEdc./precond;
    dEdc = (abs(dEdc) <  thresh).*dEdc+...
           (abs(dEdc) >= thresh).*thresh.*sign(dEdc);
    dDatads = dEdc.*mask;
    % make sure the number of iterations is an even number
    nIt = 2*(floor(dt_reg/1e-1)+1); 
    beta_data = dt_data/nIt;
    beta_regularization = dt_reg/nIt;
    for tt=1:nIt
        % compute gradient of the cost functional (data term +
        % regularization) wrt the depth map
        if tt-floor(tt/2)*2==0
            dsigma = beta_data*dDatads - beta_regularization.*...
                laplacian(Dsigma,'forward');
        else
            dsigma = beta_data*dDatads - beta_regularization.*...
                laplacian(Dsigma,'backward');
        end
        Dsigma = Dsigma-dsigma;
    end
    DepthMap_e = 1./(1/F-(p(2)-p(1)-sqrt((p(2)-p(1))^2+...
                 4*(p(2)^2-p(1)^2)*Dsigma/gamma^2/D^2))/...
                 (p(2)^2-p(1)^2));
end
fprintf('\ndone\n');

return

?? 快捷鍵說明

復(fù)制代碼 Ctrl + C
搜索代碼 Ctrl + F
全屏模式 F11
切換主題 Ctrl + Shift + D
顯示快捷鍵 ?
增大字號 Ctrl + =
減小字號 Ctrl + -
亚洲欧美第一页_禁久久精品乱码_粉嫩av一区二区三区免费野_久草精品视频
亚洲精品国产一区二区三区四区在线 | 人人狠狠综合久久亚洲| 久久综合一区二区| 一本大道av一区二区在线播放| 久久av老司机精品网站导航| 亚洲免费观看高清完整版在线观看熊| 欧美一二三区在线观看| 在线免费观看视频一区| 床上的激情91.| 久久99精品网久久| 亚洲一区免费观看| **网站欧美大片在线观看| 久久精品日产第一区二区三区高清版 | 国产精品乱码一区二区三区软件 | 88在线观看91蜜桃国自产| hitomi一区二区三区精品| 国模一区二区三区白浆 | 成人免费视频播放| 国产真实乱偷精品视频免| 天堂av在线一区| 亚洲狠狠爱一区二区三区| 国产精品福利av| 国产精品午夜电影| 久久久午夜电影| 欧美电影免费观看高清完整版在线| 欧洲亚洲国产日韩| 91麻豆视频网站| 成人av综合在线| 成人精品高清在线| 成人激情电影免费在线观看| 国产乱码精品一区二区三区忘忧草| 免费成人你懂的| 日韩国产精品久久久| 日韩中文字幕不卡| 视频一区视频二区在线观看| 亚洲aaa精品| 天堂在线亚洲视频| 日韩精品亚洲一区| 日韩成人午夜精品| 日本亚洲欧美天堂免费| 蜜桃精品视频在线观看| 日韩va欧美va亚洲va久久| 日本三级韩国三级欧美三级| 免费在线观看成人| 国内精品不卡在线| 国产精品1024| 成人黄色免费短视频| jlzzjlzz国产精品久久| 色婷婷综合五月| 欧美日韩中文精品| 欧美一区二区三区在线电影| 欧美大黄免费观看| 国产日韩欧美亚洲| 国产精品精品国产色婷婷| 亚洲美女视频一区| 亚洲gay无套男同| 久久超碰97中文字幕| 国产久卡久卡久卡久卡视频精品| 国产电影一区二区三区| 色综合久久久久久久久久久| 欧美在线色视频| 日韩美女视频在线| 国产三级一区二区| 亚洲婷婷在线视频| 五月天国产精品| 国产激情一区二区三区| 91丝袜美腿高跟国产极品老师 | 久久久久99精品国产片| 国产精品久久久久久久午夜片| 一区在线中文字幕| 三级在线观看一区二区| 国产一区二区三区免费| 91日韩在线专区| 欧美一二三区在线观看| 国产精品免费aⅴ片在线观看| 亚洲国产精品麻豆| 国产精品白丝jk白祙喷水网站| 99re这里都是精品| 欧美一区二区三区视频在线| 久久免费偷拍视频| 亚洲国产婷婷综合在线精品| 国产一区二区三区最好精华液| 91免费观看在线| 精品国内片67194| 日韩理论电影院| 精品一区二区三区在线视频| 一本色道**综合亚洲精品蜜桃冫| 日韩精品一区二区三区老鸭窝| 亚洲色图在线视频| 精品一区二区久久久| 色综合久久综合| 久久久精品蜜桃| 五月天婷婷综合| 91丨九色porny丨蝌蚪| 欧美成人aa大片| 亚洲午夜精品一区二区三区他趣| 国产原创一区二区三区| 欧美日韩一区高清| 中文字幕一区二区三区色视频| 蜜臂av日日欢夜夜爽一区| 色网综合在线观看| 国产欧美精品国产国产专区| 天天av天天翘天天综合网 | 在线亚洲高清视频| 国产欧美一区二区精品性| 日本成人在线一区| 精品视频1区2区| 国产精品高潮呻吟| 高清在线观看日韩| 精品久久久久久亚洲综合网| 亚洲第一会所有码转帖| 99在线热播精品免费| 国产欧美日本一区视频| 狠狠色丁香久久婷婷综合_中| 欧美日韩激情在线| 亚洲精品精品亚洲| 99r精品视频| 国产精品国产三级国产普通话99| 韩日欧美一区二区三区| 日韩亚洲欧美一区二区三区| 午夜精品成人在线| 欧美视频在线一区| 一区二区三区在线视频免费| 99精品久久免费看蜜臀剧情介绍| 久久久精品tv| 国产福利精品一区| 国产日韩av一区二区| 国产美女在线观看一区| 精品国产电影一区二区| 美女精品自拍一二三四| 欧美一级日韩免费不卡| 日韩中文字幕一区二区三区| 欧美精品vⅰdeose4hd| 亚洲成人免费视频| 欧美精品亚洲二区| 奇米影视在线99精品| 欧美一区二区三区四区视频| 亚洲v精品v日韩v欧美v专区| 欧美日韩国产123区| 日本亚洲视频在线| 欧美v国产在线一区二区三区| 麻豆成人久久精品二区三区红 | 一区二区三区国产豹纹内裤在线| 91网站黄www| 亚洲综合色视频| 欧美女孩性生活视频| 蜜桃视频在线观看一区| 久久综合久久综合亚洲| 国产精品自拍三区| 中文字幕国产精品一区二区| 91欧美一区二区| 亚洲1区2区3区视频| 91精品国产免费久久综合| 国内精品自线一区二区三区视频| 久久久久久久国产精品影院| 成人免费高清在线观看| 亚洲欧洲综合另类| 91精品国产黑色紧身裤美女| 紧缚捆绑精品一区二区| 日本一区二区视频在线| 91麻豆视频网站| 日韩成人av影视| 国产欧美精品在线观看| 91国产福利在线| 另类小说色综合网站| 中文字幕乱码亚洲精品一区 | 91久久线看在观草草青青| 亚洲bt欧美bt精品| 久久精品综合网| 色噜噜狠狠成人中文综合| 青草国产精品久久久久久| 欧美激情艳妇裸体舞| 欧美午夜免费电影| 国产主播一区二区三区| 一区二区三区蜜桃| 日韩精品自拍偷拍| 91理论电影在线观看| 美女视频免费一区| 亚洲欧美日韩中文播放| 欧美一级理论片| 成人激情校园春色| 麻豆91在线看| 艳妇臀荡乳欲伦亚洲一区| 精品精品欲导航| 日本韩国一区二区| 国模无码大尺度一区二区三区| 亚洲免费av在线| 国产亚洲精品aa| 欧美美女bb生活片| 北条麻妃国产九九精品视频| 日韩成人免费在线| 亚洲欧美日韩中文字幕一区二区三区 | 91久久精品午夜一区二区| 美女精品自拍一二三四| 一区二区三区在线观看视频| 久久免费的精品国产v∧| 欧美亚洲高清一区二区三区不卡| 国产成人免费av在线| 奇米亚洲午夜久久精品| 亚洲美腿欧美偷拍|