LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Insert circle array into 2d array.

There is one thing I need to achieve as part of a fienup interative routine, I need to be able to set all elements outside a specific circle in a 2d array to 0. Either by inserting the circle of elements from my array into an array of 0s. Or setting all the elements outside a 400 "pixel" - element - circle to 0. I've tried many ways of doing it but keep falling flat, I'm fairly new to labview. Any help appreicated.

0 Kudos
Message 1 of 5
(3,890 Views)

Hi Deccarrin,

 

iterate over your array. When the current element ("pixel") is outside your circle you replace it with zero…

 

You know how to calculate the distance of two points?

Best regards,
GerdW


using LV2016/2019/2021 on Win10/11+cRIO, TestStand2016/2019
0 Kudos
Message 2 of 5
(3,886 Views)

This is what I'm confused about. The distance between two points is sqrt(i^2+j^2) And if the centre of the circle was 0,0 I could set if sqrt(i^2+j^2)>200 replace with 0. That would make a quarter circle from 0,0. But I need to set it as a 200 radius circle from the centre of a 600,600 array. I'm sure i'm just being dense but this is frustrating me to no end.

0 Kudos
Message 3 of 5
(3,818 Views)

srt((600-x)^2 + (600-y)^2) > 200

0 Kudos
Message 4 of 5
(3,807 Views)

@Deccarrin wrote:

There is one thing I need to achieve as part of a fienup interative routine, I need to be able to set all elements outside a specific circle in a 2d array to 0. Either by inserting the circle of elements from my array into an array of 0s. Or setting all the elements outside a 400 "pixel" - element - circle to 0. I've tried many ways of doing it but keep falling flat, I'm fairly new to labview. Any help appreicated.


You can use Re/Im to polar to select inside/outside circle points. You need to do some offsetting to have the center at a different location than (0,0). Instead of a bool output you can use the bool to 0,1 function and multiply the resulting 0,1 array with the original array.

 

array problem.png

 

Ben64

 

EDIT: Probably more efficient to do the offset after the loop.

0 Kudos
Message 5 of 5
(3,799 Views)