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

3 ビュー (過去 30 日間)
Kjell
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
KALYAN ACHARJYA 2023 年 7 月 1 日
編集済み: KALYAN ACHARJYA 2023 年 7 月 1 日
bscan=rgb2gray(imread('image.png'));
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

その他の回答 (0 件)

カテゴリ

Help Center および File ExchangeInterpolation についてさらに検索

製品


リリース

R2023a

Community Treasure Hunt

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

Start Hunting!

Translated by