Repeat elements in a 2D vector

I am trying to hardcode the upsampling of an image. The problem I am having is trying to do it in a loop. It seems impossible.Here is what I did.
Image = imread('grayscale.jpg');
%imshow(Image);
% Downsampling
[row, col] = size(Image);
Downimage = Image(1:2:row,1:2:col);
%imshow(Downimage);
%Upsampling
newrow = row*2;
newcol = col*2;
Upimage = zeros(newrow,newcol);
for r = 1:2:newrow
for c = 1:2:newcol
Upimage(r,c) = Downimage(r,c;
Upimage(r+1,c+1) = Downimage;
end
end
%Upimage = reshape([Downimage ; Downimage],1,[]);
%Upimage = repmat(Downimage, 2, 1);
imshow(Upimage);
Now I realize that for the loop to work it needs parameters beside the Downimage in the loop, but I can's seem to make it work due to the downimage being of the shorter size then the upimage. P.S I cant use imresize...I have to hardcode it

Antworten (2)

dpb
dpb am 22 Nov. 2015

0 Stimmen

I'm no image processing guru, but look at
doc filter2
Mayhaps there a specific equivalent for image reconstruction in the appropriate toolbox'en the which of I haveth not...
Jos (10584)
Jos (10584) am 22 Nov. 2015

0 Stimmen

OutImage = imresize(InImage, 2, 'nearest')

4 Kommentare

Junaid Pirzada
Junaid Pirzada am 22 Nov. 2015
I cant use imresize
dpb
dpb am 22 Nov. 2015
Why not?
You can also use
OutImage = kron(InImage,ones(2))
Junaid Pirzada
Junaid Pirzada am 23 Nov. 2015
I cant because the instructor wanted us to make a code that does this, but imresize does that easily...I dont think she would accept...@Jos will try using kron...I used it before it just displayed two images joined beside each other...will try using your one.

Melden Sie sich an, um zu kommentieren.

Kategorien

Mehr zu Loops and Conditional Statements finden Sie in Hilfe-Center und File Exchange

Gefragt:

am 22 Nov. 2015

Kommentiert:

am 23 Nov. 2015

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by