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

2 visualizaciones (últimos 30 días)
Kjell el 1 de Jul. de 2023
Comentada: Kjell el 1 de Jul. de 2023
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
##### 0 comentariosMostrar -2 comentarios más antiguosOcultar -2 comentarios más antiguos

Iniciar sesión para comentar.

KALYAN ACHARJYA el 1 de Jul. de 2023
Editada: KALYAN ACHARJYA el 1 de Jul. de 2023
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 comentarioMostrar -1 comentarios más antiguosOcultar -1 comentarios más antiguos
Kjell el 1 de Jul. de 2023
thank you

Iniciar sesión para comentar.

### Categorías

Más información sobre Read, Write, and Modify Image en Help Center y File Exchange.

R2023a

### Community Treasure Hunt

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

Start Hunting!

Translated by