[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: Nearest neighbor interpolation.
From: |
Ismael Núñez-Riboni |
Subject: |
Re: Nearest neighbor interpolation. |
Date: |
Fri, 20 Apr 2012 10:04:39 +0200 |
User-agent: |
Mozilla/5.0 (X11; Linux i686; rv:10.0.2) Gecko/20120216 Thunderbird/10.0.2 |
On 04/20/2012 09:40 AM, rikydzee wrote:
Hy there, i need some help. I have a matrix obtained from a picture, let's
say that my matrix is [1 2 3 ; 4 5 6 ; 7 8 9] and i need to transform this
matrix into [ 1 0 2 0 3; 0 0 0 0 0 ; 4 0 5 0 6 ; 0 0 0 0 0; 7 0 8 0 9 ]. I
managed to do that making another matrix filled with zeros and put pixel by
pixel from first matrix in the second one.
You mean here with a double for-loop? Yes, this might be not very
efficient in Octave, but I see no other way to do it, particularly not
with nearest neighbor interpolation... With nearest neighbor
interpolation you will never get zeros in your interpolated matrix,
since the interpolation algorithm always looks for a value (i.e. the
nearest one).
I can suggest to reduce the two for-loops to one to make it faster:
a = [1 2 3 ; 4 5 6 ; 7 8 9];
b = zeros(2.*size(a,1), 2.*size(a,2));
for i = 1:size(a,1)
b(2.*i-1,1:2:end) = a(i,:);
end
Have luck, Ismael.
- Nearest neighbor interpolation., rikydzee, 2012/04/20
- Re: Nearest neighbor interpolation.,
Ismael Núñez-Riboni <=
- Re: Nearest neighbor interpolation., Ismael Núñez-Riboni, 2012/04/20
- Re: Nearest neighbor interpolation., Ismael Núñez-Riboni, 2012/04/20
- Re: Nearest neighbor interpolation., Francesco Potortì, 2012/04/20
- Re: Nearest neighbor interpolation., Ismael Núñez-Riboni, 2012/04/20
- Re: Nearest neighbor interpolation., rikydzee, 2012/04/20
- Re: Nearest neighbor interpolation., Ben Abbott, 2012/04/20