Author Topic: Use of Erosion Filter  (Read 4984 times)

Offline georg.viehoever

  • PTeam Member
  • PixInsight Jedi Master
  • ******
  • Posts: 2132
Use of Erosion Filter
« on: 2011 June 29 23:50:25 »
Hi,

I would like to apply an ErosionFilter (http://pixinsight.com/developer/pcl/doc/html/classpcl_1_1ErosionFilter.html) to a 3x3 neigbourhood in a whole image.

- From the documentation, it is not clear to me how to best do this, since it appears to work on a linear memory region (which 3x3 pixel data is not).
- Do I always have to copy the data in a suitable layout? How to handle the border of an image?

Thanks.
Georg
Georg (6 inch Newton, unmodified Canon EOS40D+80D, unguided EQ5 mount)

Offline Carlos Milovic

  • PTeam Member
  • PixInsight Jedi Master
  • ******
  • Posts: 2172
  • Join the dark side... we have cookies
    • http://www.astrophoto.cl
Re: Use of Erosion Filter
« Reply #1 on: 2011 June 30 08:12:05 »
Hi Georg

This code is for a median filter, but is quite the same thing for erosion.

Code: [Select]
void NoiseReduction( image_array ratio, pcl_bool issmall )
{
MedianFilter M;
BoxStructure sK(3);
BoxStructure lK(5);

MorphologicalTransformation MT(M,sK);
if (!issmall)
MT.SetStructure( lK );

for (int i = 0; i < ratio.Length(); i++)
MT >> ratio[i];

    Console().Flush();
    ProcessInterface::ProcessEvents();
}

You just have to change "MedianFilter M;"  for "ErosionFilter M;" and you are ready to go. They are all defined in MorphologicalOperator.h. Also, look at the StructuringElement.h file for the predefined shapes.
Regards,

Carlos Milovic F.
--------------------------------
PixInsight Project Developer
http://www.pixinsight.com

Offline georg.viehoever

  • PTeam Member
  • PixInsight Jedi Master
  • ******
  • Posts: 2132
Re: Use of Erosion Filter
« Reply #2 on: 2011 June 30 08:27:56 »
Thanks !  8)
Just what I need.
Georg
Georg (6 inch Newton, unmodified Canon EOS40D+80D, unguided EQ5 mount)