3

超解像度画像再構成のトピックを読んでいます。この分野の目的は、複数のシフトされた (サブピクセル) 低解像度 (LR) 画像から高解像度 (HR) 画像を作成することです。次のコードは、1 つの HR 画像から 4 つの LR 画像を作成します。次に、non-unifrom 補間を使用して、高解像度グリッド上の 4 つの LR 画像を補間し、両側で LR 画像よりも 4 大きい HR 画像を取得します。

main.m

im=double(imread('lena.bmp'));

figure,imshow(uint8(im)),title('original HR image');
shifts=[ 0,         0;
        4.1,    2.68;
       -3.7,    7.8;
       -1.1,  -6.5];

factor=4;

im1=create_low(im,shifts(1,1),shifts(1,2),factor);
im2=create_low(im,shifts(2,1),shifts(2,2),factor);
im3=create_low(im,shifts(3,1),shifts(3,2),factor);
im4=create_low(im,shifts(4,1),shifts(4,2),factor);

LR_images={im1,im2,im3,im4};

estimated_image =  interpolate(LR_images,shifts,factor);
figure,imshow(uint8(estimated_image)),title('reconstructed image');

create_low.m この関数は、4 つの LR イメージを作成します。

function [ low ] = create_low(im,x_shift,y_shift,factor)

 low = shift(im,x_shift,y_shift);

 low=downsample(low,factor);
 low=low';
 low = downsample(low,factor);
 low=low';

end

shift.mこの関数は、線形補間によってサブピクセル シフトを行います。

interpolate.m 4 つの LR 画像を HR グリッドに補間します。

function rec = interpolate(s,shifts,factor)                                   

n=length(s);
ss = size(s{1});
if (length(ss)==2) ss=[ss 1]; end

% compute the coordinates of the pixels from the N images.
for k=1:ss(3) % for each color channel
  for i=1:n % for each image
    s_c{i}=s{i}(:,:,k);
    s_c{i} = s_c{i}(:);     
    r{i} = [1:factor:factor*ss(1)]'*ones(1,ss(2)); % create matrix with row indices
    c{i} = ones(ss(1),1)*[1:factor:factor*ss(2)]; % create matrix with column indices
    r{i} = r{i}+factor*shifts(i,2);     %% the problem is here.
    c{i} = c{i}+factor*shifts(i,1);     %% the problem is here.
    rn{i} = r{i}((r{i}>0)&(r{i}<=factor*ss(1))&(c{i}>0)&(c{i}<=factor*ss(2)));
    cn{i} = c{i}((r{i}>0)&(r{i}<=factor*ss(1))&(c{i}>0)&(c{i}<=factor*ss(2)));
    sn{i} = s_c{i}((r{i}>0)&(r{i}<=factor*ss(1))&(c{i}>0)&(c{i}<=factor*ss(2)));
 end

 s_ = []; r_ = []; c_ = []; sr_ = []; rr_ = []; cr_ = [];
 for i=1:n % for each image
    s_ = [s_; sn{i}];
    r_ = [r_; rn{i}];
    c_ = [c_; cn{i}];
 end
 clear s_c r c coord rn cn sn

 % interpolate the high resolution pixels using cubic interpolation
 rec_col = griddata(c_,r_,s_,[1:ss(2)*factor],[1:ss(1)*factor]','cubic'); 
 rec(:,:,k) = reshape(rec_col,ss(1)*factor,ss(2)*factor);
end
rec(isnan(rec))=0;

griddata補間関数(cubic)を使ったのですが、griddataの引数の値が間違っているのではないかと思うので、再構成画像が粗すぎます。それらを修正する方法は?

注:このコードを変更すると

r{i} = r{i}+factor*shifts(i,2);     %% the problem is here.
c{i} = c{i}+factor*shifts(i,1);     %% the problem is here. 

r{i} = r{i}-shifts(i,2);     %% the problem is here.
c{i} = c{i}-shifts(i,1);     %% the problem is here.

良いイメージが湧いてきますが、その理由がわかりません!

編集 lena.bmp

ここに画像の説明を入力

4

1 に答える 1

0

create_low では、高解像度座標にシフトを適用します。したがって、補間では、高解像度座標のシフトも適用する必要があります。そのため、すでにわかっているように、それらを係数で乗算しないことは完全に理にかなっています。

于 2013-11-15T20:44:12.767 に答える