LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

2d FFT Mask Filter & IMAQ Complex Truncate (LabVIEW 8.2/Vision 8.2)

Hello:

Although this question is another of mine that involves IMAQ Vision routines, I feel it is best to be posted on the LabVIEW board since it is a non-hardware-related question.  This involves using FFT filters.

If one looks at the attached 4506.vi, it shows a way to create a 2d mask fft filter.  I have a subVI that I have developed that allows one to draw a mask on an intensity graph but uses the underlying IMAQ Vision fxs to essentially do the equivalent of 4506.vi.  I go to the trouble to use the intensity graph instead of the vision container or IMAQ window because the former auotmatically scales the image dimensions and has many more property nodes associated it.

One can also use IMAQ Complex Truncate to perform 2d FFT filtering also.   I did some experiments in which I drew a mask, then filtered the image using the mask method per the attached example.  Then I used IMAQ ComplexTruncate with Truncation Frequency % set to the same value as determined by the following so that I could compare results.  I calculated the Truncation Frequency % by taking the diagonal dimension of the mask and dividing it into the diagonal dimension of the FFT image (then multiplying by 100) as per the definition of the truncation frequency %.   The filtered image results from each filter method are not the same - they are not doing the same filtering process. A screen shot of the front panel is attached so you can see the basic strategy of drawing a rectangle on the image and/or selecting a truncation frequency. I can post the code but it is a little complex due to the use of the draw on the intensity graph.

Thoughts are welcome....Don


Download All
0 Kudos
Message 1 of 10
(4,216 Views)
I put together a modified 4506.vi that illustrates both using the truncation frequency % control and the mask ROI methods to perform the FFT filtering.  For the purposes of our discussion, my use of the intensity graph in my actual application does not need to be considered here. If in the first run, one performs the FFT using the mask method, truncation frequency % value will calculated (via local variable).  Then, with this new truncation fequency % value, click on 'Mask ROI/Control' boolean to get to 'Control' method.  Then do the same run.  You will see that there are some gray scale gradations present in the filtered image using 'Mask ROI' method that are not present in the filtered image of the 'Control' method.

I think this simplies things so you can see my point.  Any comments as to why there might be differences are welcome.
0 Kudos
Message 2 of 10
(4,200 Views)

Hi Don,

I ran your code and I noticed that if I select my ROI to be off centered (a region that is all black) the filtered image will also be black on the “Mask ROI” run.  But if I select “Control” the filtered image is similar to the image you would receive if the ROI had been centered.  It appears that the calculation of the truncation frequency assumes that the ROI is centered.  The further off center the ROI is, the greater the difference between the two images will be.  Let me know what you think.

Have a great day,

Gavin

0 Kudos
Message 3 of 10
(4,176 Views)
This is an interesting point.  I suppose the true test then would be to create a perfectly-centered ROI mask and with the new truncation frequency %, then try the control method to see how well the two images match up.  (On travel for work at the moment, let me try to program such an experiment and evaluate the results.....)....thanks, Don
0 Kudos
Message 4 of 10
(4,174 Views)
Hi Gavin:

I did some tests where I drew almost perfectly symmetrical ROIs and compared the results against the use of the truncation frequency % method.  The results are certainly different.  Please test this and give me your comments.

ps. To get this to work right for both high and low pass filter tests, change the 'final' 'Imaq Create' fx  image type to Grayscale (SGL) in both the true and false cases, or use the attached revised 4506 - mod.vi.

Thanks,

Don

Message Edited by DonRoth on 04-12-2007 01:56 PM

Download All
0 Kudos
Message 5 of 10
(4,163 Views)
Now after testing again I realize that you may be correct.  It is just too hard to get a perfectly symmetric and centered manual draw.  I next will program up a perfectly centered mask and test and report results.....Don
0 Kudos
Message 6 of 10
(4,160 Views)
I created a small subVI that alters the drawn ROI so that it becomes centered prior to constructing the mask.  I still come up with pretty much the same conclusion - there is a difference.  Take a look and tell me what you think.

Sincerely,

Don
Download All
0 Kudos
Message 7 of 10
(4,149 Views)
Just a quick update here.  Please see the NI Vision Concepts manual, chapter 7, p. 7-10.  The images indicate that a circular filter mask would be the proper mask.  I had been using a rectangular mask.  I tried the circular mask and I think we are getting closer but still no cigar yet.  Further comments are appreciated....Don
0 Kudos
Message 8 of 10
(4,128 Views)

You are right to get the correct truncation filter you will need to use a circle as your ROI.  And that circle will have to be centered correctly.   I haven’t written anything to programmatically get a centered ROI yet, but with every ROI I have tested the closer I am to the center the more similar the two methods are.  So I believe the difference is still from our off centered images. 

Gavin       

0 Kudos
Message 9 of 10
(4,106 Views)

You could be right.  I just wish I knew for sure that the mask method was 100% right.

By the way, see my post above where I wrote an auto-centering routine and incorporated it into the 4506 - mod.vi.

I also ended up writing a passband routine so that in case the FFT energy is not all centered either high or low, one can create a donut-type mask and place it over the areas where the energy is centered.  It is incorporated into my main program.  Most likely, it would be used very infrequently given the characteristics of most images.  Still, I wanted to provide the option.

Sincerely,

Don

0 Kudos
Message 10 of 10
(4,098 Views)