# Binary closing slower than grayscale closing

**URL:** https://discourse.itk.org/t/binary-closing-slower-than-grayscale-closing/2770
**Category:** Beginner Questions
**Created:** [February 27, 2020, 4:37pm UTC](https://discourse.itk.org/t/binary-closing-slower-than-grayscale-closing/2770 "2020-02-27T16:37:45Z")
**Posts on this page:** 3
**Page:** 1

<div class="post-metadata">

### Author: ![Come](https://discourse.itk.org/letter_avatar_proxy/v4/letter/c/9f8e36/32.png) [@Come](https://discourse.itk.org/u/Come)
#### Post date: [February 27, 2020, 4:37pm UTC](https://discourse.itk.org/t/binary-closing-slower-than-grayscale-closing/2770/1 "2020-02-27T16:37:45Z")

</div>

Hi,

**Context :** I have a binary input image of type `itk::Image<unsigned char, 2>` (the image is a 512x512 pixels) and I am applying a closing filter on it using a `itk::FlatStructuringElement<2>`. The type of the structuring element is a ball with a radius of 5 pixels. I am using c++ with Visual Studio, the code and the itk libraries are both compiled in release (itk version 5.1).

**Question #1:** for the exact same input image, if I use a `itk::BinaryMorphologicalClosingImageFilter`, it takes more time to run than using a `itk::GrayscaleMorphologicalClosingImageFilter` and I don’t understand why.

**Question #2:** I would like to get a better understanding of the `Update()` function and I couldn’t find its implementation. I know that it is used at the end of the pipeline to apply all the previously set operations/filters but I can’t find what it really does. Can someone help me find my way in the documentation for the Update() function?

_Note_ - For both filters, I only set the input image, set the kernel and call the `Update()` method as follows :

```auto
    closingFilter->SetInput(itkImg);
    closingFilter->SetKernel(structuringElement);
    closingFilter->Update();

```

Thank you for the help,  
Côme

---

<div class="post-metadata">

### Author: ![dzenanz](https://discourse.itk.org/user_avatar/discourse.itk.org/dzenanz/32/1093_2.png) [@dzenanz](https://discourse.itk.org/u/dzenanz)
#### Post date: [March 2, 2020, 6:54pm UTC](https://discourse.itk.org/t/binary-closing-slower-than-grayscale-closing/2770/2 "2020-03-02T18:54:59Z")

</div>

`Update()` method is the tip of the [pipeline](https://github.com/InsightSoftwareConsortium/ITK/blob/344e9bc58e69ed921f540c67d87dbb66fee4c466/Modules/Core/Common/src/itkProcessObject.cxx#L1265-L1272) iceberg. Some explanatory materials:  
[Documentation](https://itk.org/ITKSoftwareGuide/html/Book1/ITKSoftwareGuide-Book1ch3.html#x39-420003.5)  
[Lecture slides](http://biglab.ri.cmu.edu/galeotti/methods_course/medical_image_analysis_course_2018/ITK_Pipeline.pdf)  
[ITK example](https://itk.org/ITKExamples/src/Core/Common/ReRunPipelineWithChangingLargestPossibleRegion/Documentation.html)

---

<div class="post-metadata">

### Author: ![dzenanz](https://discourse.itk.org/user_avatar/discourse.itk.org/dzenanz/32/1093_2.png) [@dzenanz](https://discourse.itk.org/u/dzenanz)
#### Post date: [March 2, 2020, 6:56pm UTC](https://discourse.itk.org/t/binary-closing-slower-than-grayscale-closing/2770/3 "2020-03-02T18:56:18Z")

</div>

You can also use debugger’s **step into** function to trace the execution inside the pipeline update call.
