interpolation done without imresize

How to do nearest neighbor interpolation and bilinear interpolation on a gray scale image without using imresize? The code is supposed to mimic the operation of imresize but should not use any functions available on matlab.

댓글 수: 2

Matt J
Matt J 2013년 1월 24일
should not use any functions available on matlab
I don't see how you're going to do nearest neighbor interpolation without MATLAB's round() function. You might want to clarify the scope of that restriction.
P
P 2013년 1월 24일
You are right. There is no way to do nearest without round(). The objective is to stay away from imresize, interp where you can enter the method as nearest, bilinear and get the answer. other functions are permissible.

댓글을 달려면 로그인하십시오.

 채택된 답변

Image Analyst
Image Analyst 2013년 1월 24일

0 개 추천

You'll have to scan your output image, figure out where the input pixel lies on your input pixel - it will be located somewhere in a square between 3 original input pixels. Then use the bilinear interpolation formula on Wikipedia to get the output pixel value. You can use a pair of for loops for this - one over rows and one over columns.

댓글 수: 6

P
P 2013년 1월 24일
would fspecial('avg') be doing the same thing as the formula with a 3x3 matrix? Just to better understand the concept.
P
P 2013년 1월 24일
not the same but similar.
Image Analyst
Image Analyst 2013년 1월 24일
That would only be the same if your output pixels happened to land exactly in the middle of the 4 input pixels. If you are 25% of the way over horizontally and 70% of the way over vertically you can't just take the average. It has to be weighted because it's closer to some pixels than others.
P
P 2013년 1월 24일
How is it possible to get weighted average when the values change for every pixel?
P
P 2013년 1월 24일
frow=min(round(((1:fscale(1))-1)./fs(1)+1),fim(1)); fcol=min(round(((1:fscale(2))-1)./fs(2)+1),fim(2));
this what I used for nearest neighbor but I am having difficulty in figuring out what should replace frow and fcol for bilinear.
Image Analyst
Image Analyst 2013년 1월 24일
The formula for weighting the value according to how close it is to the different corners is in Wikipedia.

댓글을 달려면 로그인하십시오.

추가 답변 (1개)

Sean de Wolski
Sean de Wolski 2013년 1월 24일

0 개 추천

I would use interp2 or griddedInterpolant.
doc interp2
doc griddedInterpolant

댓글 수: 2

Image Analyst
Image Analyst 2013년 1월 24일
"should not use any functions available on matlab."
Sean de Wolski
Sean de Wolski 2013년 1월 24일
Well technically griddedInterpolant is a class with methods ;)

댓글을 달려면 로그인하십시오.

카테고리

도움말 센터File Exchange에서 Interpolation에 대해 자세히 알아보기

태그

질문:

P
P
2013년 1월 24일

Community Treasure Hunt

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

Start Hunting!

Translated by