# Cylindrical to rectangular correction in image processing

2 ビュー (過去 30 日間)
mustafa alnasser 2015 年 3 月 31 日
コメント済み: mustafa alnasser 2015 年 4 月 2 日
Dear All;
if have an image for cylindrical object ( say pipe). when take the image of the pipe it will project as rectangular image ,which may lead to projection error, how i can compensate for that.\
Best Regards;

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

### 回答 (1 件)

Adam Wyatt 2015 年 3 月 31 日

Create projected co-ordinates of original image
[Ny, Nx] = size(Img);
x = (1:Nx).';
y = (1:Ny).';
Create original co-ordinates of orignal image (you need to know the transfer function - you probably want to look up Mercator projection
[x1, y1] = MyCoordinateTransferFunction(x, y);
Create new co-ordinates on uniform grid
x2 = linspace(min(x1), max(x1), Nx).';
y2 = linspace(min(y1), max(y1), Ny).';
Interpolate image on new uniform grid
Img2 = interp2(x1.', y1, Img, x2.', y2, 'spline');
Note that I've defined the vectors as columns, so had to transpose the x-coordinates. Also, I've used spline interpolation - you could use linear or nearest if your want better speed but lower accuracy. Check the documentation.
##### 1 件のコメント-1 件の古いコメントを表示-1 件の古いコメントを非表示
mustafa alnasser 2015 年 4 月 2 日
Thank You Adam for kind support
I am trying to follow to your code but i am not familiar how to implement Mercator projection for image , the code is as follow: clc; clear;
%Create projected co-ordinates of original image
[Ny, Nx] = size('001.jpg'); x = (1:Nx).'; y = (1:Ny).'; %Create original co-ordinates of orignal image (you need to know the transfer function - you probably want to look up Mercator projection
[x1, y1] = mercator(x, y); %Create new co-ordinates on uniform grid
x2 = linspace(min(x1), max(x1), Nx).'; y2 = linspace(min(y1), max(y1), Ny).'; Interpolate image on new uniform grid Img2 = interp2(x1.', y1, Img, x2.', y2, 'spline');
but there is a problem in the number of parameters as shown below:
Error using applyProjection (line 15) Incorrect number of arguments.
Error in mercator (line 38) varargout = applyProjection(mproj, varargin{:});
Error in imagecorrec (line 11) [x1, y1] = mercator(x, y);

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

### カテゴリ

Help Center および File ExchangeRead, Write, and Modify Image についてさらに検索

### Community Treasure Hunt

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

Start Hunting!

Translated by