Hi list,
I'm not getting the results I expect when I call the "Custom Filter..." menu command from a plugin. I'm writing a plugin that iteratively applies a custom filter to a series of small pixel blocks of the input image. All images are 32 bit floats. Here is a schematic of the steps I take: - Create a filter image block, a 4x4px imageplus (imFilter) in a window titled "Filter" - For simple testing I'm using a filter where the values are unity at the edges and zero elsewhere: 1 1 1 1 1 0 0 1 1 0 0 1 1 1 1 1 - I create a new image from the original image (imp) to form my current "block" (imBlock), again a 4x4 square image block - For testing I'm forcing the values in this block to have known values: 0 1 2 3 0 0 0 0 4 5 6 7 0 0 0 0 - I use "Custom Filter..." to filter imBlock with imFilter. If I do the Custom Filter manually by using the menus I get an image block that appears smoothed, which I'm expecting. But if I try to automate this in my plugin, the image block ends up as just a 4x4 image with zero-valued pixels everywhere. The command I'm using to call the filter is: ij.IJ.run(imBlock, "Custom Filter...", "filter=[Filter]"); Is there something implicitly wrong with the way I am calling the filter? Any suggestions/criticisms would be gratefully received. Many thanks, Neil |
Neil,
not sure, but the IJ-manual (always a good source for inspiration) says: "There is no arbitrary limit to the size of the kernel but it must be square and have an odd width." >Hi list, > >I'm not getting the results I expect when I call the "Custom Filter..." menu >command from a plugin. I'm writing a plugin that iteratively applies a >custom filter to a series of small pixel blocks of the input image. All >images are 32 bit floats. Here is a schematic of the steps I take: > >- Create a filter image block, a 4x4px imageplus (imFilter) in a window >titled "Filter" >- For simple testing I'm using a filter where the values are unity at the >edges and zero elsewhere: > 1 1 1 1 > 1 0 0 1 > 1 0 0 1 > 1 1 1 1 >- I create a new image from the original image (imp) to form my current >"block" (imBlock), again a 4x4 square image block >- For testing I'm forcing the values in this block to have known values: > 0 1 2 3 > 0 0 0 0 > 4 5 6 7 > 0 0 0 0 >- I use "Custom Filter..." to filter imBlock with imFilter. > >If I do the Custom Filter manually by using the menus I get an image block >that appears smoothed, which I'm expecting. But if I try to automate this >in my plugin, the image block ends up as just a 4x4 image with zero-valued >pixels everywhere. > >The command I'm using to call the filter is: > ij.IJ.run(imBlock, "Custom Filter...", "filter=[Filter]"); > >Is there something implicitly wrong with the way I am calling the filter? >Any suggestions/criticisms would be gratefully received. > >Many thanks, Neil HTH -- Herbie ------------------------ <http://www.gluender.de> |
In reply to this post by ph73nt
Hi Neil,
just to make sure there are no misunderstandings: Process>FFT>Custom Filter is in the Fourier domain, with low frequencies at the center. So, your filter is actually a high-pass filter. The filter should have values of 255 for the frequencies that should pass unattanuated. If you want a convolution operation, use Process>Filters>Convolve. You will need a kernel size that is an odd number (e.g., 3x3, 5x5; you can also have 1D kernels like 1x7 or 7x1). Michael ________________________________________________________________ On 15 Mar 2010, at 23:34, ph73nt wrote: > Hi list, > > I'm not getting the results I expect when I call the "Custom > Filter..." menu > command from a plugin. I'm writing a plugin that iteratively > applies a > custom filter to a series of small pixel blocks of the input > image. All > images are 32 bit floats. Here is a schematic of the steps I take: > > - Create a filter image block, a 4x4px imageplus (imFilter) in a > window > titled "Filter" > - For simple testing I'm using a filter where the values are unity > at the > edges and zero elsewhere: > 1 1 1 1 > 1 0 0 1 > 1 0 0 1 > 1 1 1 1 > - I create a new image from the original image (imp) to form my > current > "block" (imBlock), again a 4x4 square image block > - For testing I'm forcing the values in this block to have known > values: > 0 1 2 3 > 0 0 0 0 > 4 5 6 7 > 0 0 0 0 > - I use "Custom Filter..." to filter imBlock with imFilter. > > If I do the Custom Filter manually by using the menus I get an > image block > that appears smoothed, which I'm expecting. But if I try to > automate this > in my plugin, the image block ends up as just a 4x4 image with zero- > valued > pixels everywhere. > > The command I'm using to call the filter is: > ij.IJ.run(imBlock, "Custom Filter...", "filter=[Filter]"); > > Is there something implicitly wrong with the way I am calling the > filter? > Any suggestions/criticisms would be gratefully received. > > Many thanks, Neil > > -- > View this message in context: http://n2.nabble.com/Trouble-running- > Custom-filter-from-plugin-tp4740352p4740352.html > Sent from the ImageJ mailing list archive at Nabble.com. |
Thanks for your responses.
My original issue was a typo in my code (I feel so ashamed). Those tips for filtering have given me some food for thought and are much appreciated. Thanks again, Neil |
Free forum by Nabble | Edit this page |