From: rain h. on 29 Sep 2009 04:44 I am trying to resize a 256*256 into 160*160 image using bilinear interpolation (without using imresize) I tried to write my own code I just don't get how bilinear interpolation is used for resize my small code is a desperate attempt to get that done, any help will be highly appreciated. here is my desperate try: for x=2:159 for y=2:159 i(x,y)=.25*i(floor(x),floor(y))+.25*i(ceil(x),floor(y))+.25*i(floor(x),ceil(y))+.25*i(ceil(x),ceil(y));// that’s the bilinear interpolation formula end end
From: Titus Edelhofer on 29 Sep 2009 05:22 "rain h." <reda02812(a)gmail.com> schrieb im Newsbeitrag news:h9shch$gup$1(a)fred.mathworks.com... >I am trying to resize a 256*256 into 160*160 image using bilinear >interpolation (without using imresize) I tried to write my own code I just >don't get how bilinear interpolation is used for resize my small code is a >desperate attempt to get that done, any help will be highly appreciated. > here is my desperate try: > for x=2:159 > for y=2:159 > i(x,y)=.25*i(floor(x),floor(y))+.25*i(ceil(x),floor(y))+.25*i(floor(x),ceil(y))+.25*i(ceil(x),ceil(y));// > that’s the bilinear interpolation formula > end > end Hi, what about using interp2 instead? Titus
From: ImageAnalyst on 29 Sep 2009 06:40 On Sep 29, 4:44 am, "rain h." <reda02...(a)gmail.com> wrote: > I am trying to resize a 256*256 into 160*160 image using bilinear interpolation (without using imresize) I tried to write my own code I just don't get how bilinear interpolation is used for resize my small code is a desperate attempt to get that done, any help will be highly appreciated. > here is my desperate try: > for x=2:159 > for y=2:159 > i(x,y)=.25*i(floor(x),floor(y))+.25*i(ceil(x),floor(y))+.25*i(floor(x),ceil(y))+.25*i(ceil(x),ceil(y));// that’s the bilinear interpolation formula > end > end ------------------------------------------------------------ You should pick a different output variable than your input variable (you used i in both cases, not to mention that i is a bad name anyway because it is a complex number). Otherwise you're changing it as you're trying to use it and that might lead to problems. Plus ceil and floor aren't doing anything since your loop only has integers: 2,3,4,5,6,7,8,9,....159. So basically you're just setting your output equal to your input. For example i(2,2) = 0.25*i(2,2) + 0.25*i(2,2) + 0.25*i(2,2) + 0.25*i(2,2)
|
Pages: 1 Prev: Merge matrix with strings in text file Next: bar3() question |