フィルターのクリア

2D Interpolation (Linear and spline) of a greyscale image

83 ビュー (過去 30 日間)
Graham Boag
Graham Boag 2011 年 2 月 25 日
コメント済み: image-pro 2022 年 4 月 17 日
Hi Guys,
I have a grey scale image (shown below):
http://www.qfpost.com/download.do?get=f8295c24e09fe632b90a1d09ae5ac69a
Which I wish to interpolate to give 10 times the number of pixels - This is so I can find the edge of the beam when using a white-black intensity graph across the image as the edge is not exactly on a pixel - after carrying out a Canny edge detection.
The following code:
ZI = interp2(X,Y,Z,XI,YI,method)
seems to be the code I require where method will be 'linear' etc, however, I am not sure what the values X,Y,Z,XI and YI should be.
I guess that Z is my image, and the X and Y are co-ordinates of some kind but how would I determine then? I think it has something to do with meshgrids but I do not know very much about such techniques.
Any help would be much appreciated! Thanks, Graham
  4 件のコメント
Deepshikha Bhargava
Deepshikha Bhargava 2018 年 12 月 3 日
did you find the solution?
Image Analyst
Image Analyst 2018 年 12 月 3 日
Yes. Scroll down the page and see the Answer with the green check mark, meaning he accepted that answer.

サインインしてコメントする。

採用された回答

Sean de Wolski
Sean de Wolski 2011 年 2 月 25 日
Z is your image. You'll want to convert it to double for the interpolation and then back to uint8 or whatever other class after:
I = your_image;
class_of_I = class(I);
[x y] = meshgrid(1:256);
[xi yi] = meshgrid(1:0.1:256);
class_of_I
New_Image = cast(interp2(x,y,double(I),xi,yi,'linear'),class_of_I);
  9 件のコメント
Graham Boag
Graham Boag 2011 年 3 月 1 日
It does show me the new_image but also it says:
Warning: Image is too big to fit on screen; displaying at 25%
> In imuitools\private\initSize at 73
In imshow at 262
Is there a way I can save the full image to avoid the warning?
Graham Boag
Graham Boag 2011 年 3 月 1 日
I got it, sorry, nevermind!
imwrite(New_Image, 'new.tif')
seems to work! Thanks again for all your help with this problem Sean!

サインインしてコメントする。

その他の回答 (4 件)

Sean de Wolski
Sean de Wolski 2011 年 2 月 25 日
X,Y are the results of:
[X Y] = meshgrid(1:256)
Xi, Yi are the locations that you want an interpolated value at, for your example:
[Xi Yi] = meshgrid(1:0.1:256);
%SCd
  3 件のコメント
Graham Boag
Graham Boag 2011 年 2 月 25 日
I seem to get the following error when I type my code:
ZI = interp2(X,Y,Z,Xi,Yi)
??? Error using ==> times
Integers can only be combined with integers of the same
class, or scalar doubles.
Error in ==> interp2>linear at 354
F = ( arg3(ndx).*(onemt) + arg3(ndx+1).*t ).*(1-s)
+ ...
Error in ==> interp2 at 220
zi = linear(ExtrapVal,x,y,z,xi,yi);
Graham Boag
Graham Boag 2011 年 2 月 25 日
Sorry the above answer is when i typed a random value for Z. If I type:
Z = peaks(X,Y);
It seems to run for ages..then i type imshow(ZI) and I get a message saying the image is too big to fit on screen. Have I run the method correctly? Sorry If this is not so clear

サインインしてコメントする。


pooja chandrabose
pooja chandrabose 2018 年 1 月 25 日
I need to know how to apply interpolation in a image (biliner,cubic, convolution)plz I need this info as soon as possible

image-pro
image-pro 2022 年 4 月 16 日
did you get the answer please tell me the code?
  1 件のコメント
Image Analyst
Image Analyst 2022 年 4 月 16 日
I don't know why all the answers were using interp2 and meshgrid when you can do it simply with imresize()
outputImage = imresize(inputImage, [numDesiredRows, numDesiredColumns]);

サインインしてコメントする。


Image Analyst
Image Analyst 2022 年 4 月 16 日
I don't know why all the answers were using interp2 and meshgrid when you can do it simply with imresize()
outputImage = imresize(inputImage, [numDesiredRows, numDesiredColumns]);
imresize() has several interpolation schemes you can choose from.
  2 件のコメント
Bruno Luong
Bruno Luong 2022 年 4 月 16 日
Because imresize requires image processing toolbox.
image-pro
image-pro 2022 年 4 月 17 日
i want to know how to apply newton divided difference interpolation in image

サインインしてコメントする。

カテゴリ

Help Center および File ExchangeGeometric Transformation and Image Registration についてさらに検索

Community Treasure Hunt

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

Start Hunting!

Translated by