# Use interp2 to transform a binary matrix with polar values to cartesian values

조회 수: 3 (최근 30일)
Kjell 2023년 7월 1일
댓글: Kjell 2023년 7월 1일
Hi,
I have a Matrix with binary values, which shows an edge of a bscan
I want to transform this binary matrix into Cartesian values. I already have a skript which can transform polar images into cartesian but using it on binary values gets the following Error:
Error using griddedInterpolant
Sample values must be of type double or single.
My Code to transform the Matrix is the following:
function [bscanCart] = image2Cart(bscan)
% Determine size
[height,length] = size(bscan);
theta = linspace(-pi,pi,length);
rho = 1:1:height;
[THETA,RHO] = meshgrid(theta,rho);
% Determine grid for interpolation
[XCart,YCart] = meshgrid(linspace(-512, 512, 512*2), linspace(-512, 512, 512*2));
[XPol,YPol] = cart2pol(XCart,YCart);
% interpolating
bscanCart = interp2(THETA,RHO,bscan,XPol,YPol);
end
This is how the bscan looks like after the transformation

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

### 채택된 답변

KALYAN ACHARJYA 2023년 7월 1일
편집: KALYAN ACHARJYA 2023년 7월 1일
result=image2Cart(double(bscan));
imshow(result);
function [bscanCart] = image2Cart(bscan)
% Determine size
[height,length] = size(bscan);
theta = linspace(-pi,pi,length);
rho = 1:1:height;
[THETA,RHO] = meshgrid(theta,rho);
% Determine grid for interpolation
[XCart,YCart] = meshgrid(linspace(-512, 512, 512*2), linspace(-512, 512, 512*2));
[XPol,YPol] = cart2pol(XCart,YCart);
% interpolating
bscanCart = interp2(THETA,RHO,bscan,XPol,YPol);
end
##### 댓글 수: 1이전 댓글 -1개 표시이전 댓글 -1개 숨기기
Kjell 2023년 7월 1일
thank you

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

### 카테고리

Help CenterFile Exchange에서 Interpolation에 대해 자세히 알아보기

R2023a

### Community Treasure Hunt

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

Start Hunting!

Translated by