Use interp2 to transform a binary matrix with polar values to cartesian values
6 visualizzazioni (ultimi 30 giorni)
Mostra commenti meno recenti
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 Commenti
Risposta accettata
KALYAN ACHARJYA
il 1 Lug 2023
Modificato: KALYAN ACHARJYA
il 1 Lug 2023
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
Più risposte (0)
Vedere anche
Categorie
Scopri di più su Read, Write, and Modify Image in Help Center e File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!