LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Circular scanning and smoothing

hi!
 
I am working on an image processing program. The project involves capturing images of Haidinger intereference fringes and analysing them. I am able to acquire the image, and can find the center of the fringes using a Vision script and a low pass frequency filter. Attached are two images, the captured image and the image after it is filtered. Now that I have found the center, I need to smooth it more and then perform a best fit. Vision smoothing filters such as average and median do not significantly improve the image. I want to perform a circular smoothing of the image using a median filter. Since I am working with an IMAQ image file, as a starting approach I considered converting the image to a matrix of coordinates. After that convert the x y coordinates to polar coordinates and sort them based on angle and radius, followed by a processing step that performs a median smoothing on all the pixels of each radius. However I think this method is quite inefficient, and I need to process images as quickly as possible.
 
Another possibility along those same lines. All of the images are the same size, so if I were to design a vi that used the described method to find what order pixels would be processed around an chosen center point, I could store that order in a constant array. During actual processing, once the true center point is found, the offset from previously chosen center point could be calculated and this offset could then be applied to the constant array, reducing processing time per image.
 
Has anyone done a project at all similar to this and have any suggestions for any other ways I could approach this? Any suggestions would be appreciated, even just relating to how I could best make use of labview to approach this. I have been working with Labview for about 8 months, so I am still just learning some of the finer points of using labview.
 
Thanks a lot in advance!
Jeff


Using Labview 7 Express
Download All
0 Kudos
Message 1 of 8
(4,490 Views)
Hi Jeff,

Could you give me more information on what you are trying to do or what your end result will be.  What do you mean by smooth it more? By circular filter, do you mean you want to take the median pixel value for each circle around the center point and set that circle equal to the value?  What do you mean by perform a best fit?

Thanks,
Maclean G.
Applications Engineering
National Instruments
0 Kudos
Message 2 of 8
(4,451 Views)
Hi Maclean, thanks for replying
 
My complete application is as follows: An optic is placed in front of a instrument that captures images of the haidinger intereference fringes (see first post attachments for examples). The fringes are being captured from a small area of the optic, and since the optic is on a rotating base, when it is rotated the fringes represent different areas of optics. The slight height fluctuation causes the fringes (the rings) to move in and out. My final application needs to acquire images from the frame grabber, display them in realtime on the front panel, while still analysing images as quickly as possible to monitor the motion of the rings from frame to frame. To do this I need to effectively track the changes in the image. 
 
Currently my program does the following:
1) Acquires images from camera and stores them in a circular array, displaying them as they are acquired.
2) A parallel while loop takes the most recently acquired image from the array, makes a copy of it (so that both loops wont deal with the same data) and then proceeds to analyse it as follows:
    i) A frequency filter is used to clean up the image, and the center of the rings is determined.
    ii) I would like to perform a best fit on the pattern here, because the fringes pattern corresponds to a known equation. If i can fit the fringe locations to this 
       equation, I can effectively determine the thickness of the optic. 
 
In order to do the fit, I need to make the data more uniform (what I called smoothing (since I am new to image processing I make up my own terms)), in a circular way though. So when I said a circular filter, what I meant was that I am grouping pixels based on their distance from the center (into circles), and then I am averaging those rings (orignally I was going to do a median fit followed by an averaging). This effectively reduces the 2D picture to a 1D line, which is much easier to fit to the known function.
 
So I was wondering if anyone had any suggestions for an effective way to approach this "circular smoothing." Currently my method for grouping pixels is an array of arrays (actually an array of clusters that each contain an array) and the first array in indexed by radius, then the second array contains all the pixels that radius away from the center. This way I can just process the array in a loop 'circle' by 'circle.' I was wondering if there were any labview functions or alternative methods I am unaware of that might improve the efficiency of this process.
 
Thanks 
Jeff


Using Labview 7 Express
Message 3 of 8
(4,452 Views)
Hi Jeff,

Once you have found the center, and done your low pass filter, I suggest using line profiles. You can use IMAQ LineProfile to get the pixels in a line you can define, which means you can define the line at any angle, through any point.  I would use 4 lines (a + and an X), and calculate the position of the rings from those lines.  You are dealing with circles, so I assume 8 data points on each circle will be accurate enough.

Hope this helps!
Maclean G.
Applications Engineering
National Instruments
0 Kudos
Message 4 of 8
(4,435 Views)
yes your method would definately be faster, but it wouldnt be as accurate. I will test both methods and see which gives me the best performance in terms of speed vs. accuracy.
 
Thanks again
 
Jeff


Using Labview 7 Express
0 Kudos
Message 5 of 8
(4,427 Views)
Your main issue is the fact that you use LabVIEW 7.0. 😞
 
All of your data reduction and transformation steps have the problem that they:
  1. rely on the assumption of a center which might, or might not be precise.
  2. Skew the weighting of each pixel in the overall computation. The weigthing goes with ~r^2.

I assume that you have a model equation for the radial distribution using a few parameters P(i). So what you really need to do is a 2D fit of of your image with (xcenter, y-center, and P(i)) as parameters and with the initial estimates at reasonable values (e.g. the center coordinates from what you do now). This does not need any smoothing of the data, which again could skew the results.

This would be trivial to implement in LabVIEW 8+ using the new nonlinear fitting routines. (I actually presented an example of a 2D fit at NI week). It is much more difficult in 7.0, but I have written some routines that could do it. Unfortunately, I no longer have access to 7.0.

What is the equation for the radial function?

Message 6 of 8
(4,419 Views)
OK, for a very simple demo on how to do a 2D fit in LabVIEW 7.0, have a look at my old example (2DQuadraticPlaneFit_002.zip) from 2004 posted here:
 
 
As you can see, the implementation is a bit simplistic, because the model function assumes a fixed image size array of 64x64 and skips the independent variables completely. If your image is always the same size, you could directly re-use my code and just hardcode the size and scale into the model. Just change the model to calculate the image as a function of the parameters. (For the more general case, the model VI needs more information, e.g. scale and size information. For this you might need an additional inputs (such as a variant) or you could use a functional global to relay that information from the main VI to the model.)
 
Still, my code show the basic approach. All you need, is a model function that calculates the image, reshapes it from the 2D image to a 1D array, and returns it to the calling program to be compared with a similarly reshaped array of your input image.
 
See if this makes sense. (again, if you have LabVIEW 8.0 or higher, you can use the stock tools).
 
Good luck! 🙂
 
Message 7 of 8
(4,397 Views)
wow thanks a ton for all that help!
 
Although our company does have labview 8.5, I don't have access to it, so I am stuck with 7.0, which functions fine for most things; this is just one of those times where it would probably be very helpful to have 8.5! haha
 
You did make some excellent points about the method I have been exploring, I overlooked how skewed the weighting of the pixels would be, and I hadn't initially considered how large a difference it would make to be off even slightly from the center of the image.
 
The function that the image follows is
 
m = (2*n*h*cos(theta)) / lambda
where
m is the number of orders of phase shift (observed)
n is the index of refraction (known)
h is the thickness of the optic (variable over several images, but constant for each single image)
theta increases linearly with the radius from the center of the image at a rate that I have to test (as it is unique to the measurement setup)
and lambda is the wavelength of light (known)
 
The reason that the intensity decreases farther from the center is that the intensity of the incident ray onto the optic decreases as a Gaussian from the center of the pattern.
 
The objective is to fit to the above function and then from image to image, observe the delta m, to determine the delta h.
 
Thanks again for all your help, I am going to go through the link you posted, and I'll see what I can come up with!
 
(Once I get 50 posts I will come back and give you 5 stars haha)
 
Thanks
Jeff


Using Labview 7 Express
Message 8 of 8
(4,365 Views)