LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Converting a Rectangular Image to a Polar Image

Solved!
Go to solution

Reference: OpenCV LinearPolar/WarpPolar

 

Hello! I would like to ask if there is a LabView-only fast or efficient way of converting a grayscale rectangular image (Integer Array) to a grayscale polar image without resorting to using external libraries. I currently have a Python wrapper to execute the conversion with OpenCV but it would be preferable if there is no external dependencies other than LabView itself.

0 Kudos
Message 1 of 13
(7,616 Views)

It is not clear what you want to do.  What is the nature of your input "Rectangular Image"?  I'm guessing that you have a 2D array with N rows and M columns representing X and Y coordinates, and you display them as an NxM pixel display.  So what do you mean by a "Polar Image"?  I would think it means a 2D array representing Radius and Azimuth angle (rho and theta).  The problem is that LabVIEW Images are rectangular arrays of pixels.  You can, of course, represent a circle (constant rho, theta varying from 0 to 2 pi) on an XY plot (x = rho cos theta, y = rho sin theta), but this will need to "map" to the integer pixel locations.

 

Can you provide some more details and explanations?  Is this simply an exercise in coordinate transformations (which can be simplified by clever use of LabVIEW Complex conversion functions, see past ingenious Solutions by Christian Altenbach on this Forum)?  What am I missing?

 

Bob Schor

0 Kudos
Message 2 of 13
(7,552 Views)

It is a coordinate transformation exercise. The intent is to remap an image's pixels from cartesian (X,Y) coordinates to polar (R,θ) coordinates. From the reference in my OP, if I were to have an image of a bunch of vertically parallel lines then it would become concentric circles after the coordinate transform and vice versa. I am aware that there are libraries (such as OpenCV with cvLinearPolar and cvWarpPolar) that can do this though I am curious if there is a way to do this only in LabView.

0 Kudos
Message 3 of 13
(7,532 Views)

Just use straight up math primitives.

 

Or look at Real/Imaginary to Polar function.  x=Real, y= imaginary.  It outputs r and theta!

 

It is under Numeric >> Complex palette.

0 Kudos
Message 4 of 13
(7,525 Views)

My attempts at remapping the pixels using (rcos(theta),rsin(theta) in LabView seems to tank performance too much that I've resorted to creating a wrapper for OpenCV instead to do the transformation to eliminate the Python dependency. Thank you for the replies!

0 Kudos
Message 5 of 13
(7,469 Views)

@lukewarmcoffee wrote:

My attempts at remapping the pixels using (rcos(theta),rsin(theta) in LabView seems to tank performance too much... 


You are probably doing it wrong. How many pixels do you have and how do you interpolate (nearest? bilinear?)

0 Kudos
Message 6 of 13
(7,459 Views)
Solution
Accepted by topic author lukewarmcoffee

Here's a quick test, takes about 70ms* for 1M inputs/outputs (1000x1000 pixels).

 

(picture shows 128x128, though)

 

2Dremapping.png

 

*You can parallelize the outer FOR loop and it drops to ~4ms (for 1000x1000) on my 16(32) core dual Xeon

 

(Note that this is intentionally simple and does more work than needed. In principle you only need to go radii for the longest diagonal and can thus reduce the points in the r domain, for example)

Message 7 of 13
(7,454 Views)

Hello,

 

I tried recreating your VI but the center of rotation isn't correct. My result is the following:

 

MaxPhysics_0-1583853253855.png

MaxPhysics_1-1583853280597.png

Since I'm quite new to Labview, I'm not sure what I'm going wrong, do you see where I'm making a mistake? Thank you in advance.

 

 

 

0 Kudos
Message 9 of 13
(6,950 Views)

@MaxPhysics

 


attach your actual .vi or a snippet  not an image

attach your imagedata or save your vi/snippet with "make values default"

 

this revision is less convoluted:

 

polar-to-cartesian_mod.png

0 Kudos
Message 10 of 13
(6,939 Views)