# DivideImageFilter with a constant?

**URL:** https://discourse.itk.org/t/divideimagefilter-with-a-constant/1241
**Category:** Engineering
**Created:** [August 31, 2018, 5:58pm UTC](https://discourse.itk.org/t/divideimagefilter-with-a-constant/1241 "2018-08-31T17:58:20Z")
**Posts on this page:** 10
**Page:** 1

<div class="post-metadata">

### Author: ![gdevenyi](https://discourse.itk.org/user_avatar/discourse.itk.org/gdevenyi/32/355_2.png) [@gdevenyi](https://discourse.itk.org/u/gdevenyi)
#### Post date: [August 31, 2018, 5:58pm UTC](https://discourse.itk.org/t/divideimagefilter-with-a-constant/1241/1 "2018-08-31T17:58:21Z")

</div>

The documentation for this deprecated filter:  
[https://itk.org/Doxygen/html/classitk\_1\_1DivideByConstantImageFilter.html](https://itk.org/Doxygen/html/classitk_1_1DivideByConstantImageFilter.html)

Says DivideImageFilter can do the same thing, however I can’t find any detail on how, is it possible?

---

<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: [August 31, 2018, 6:04pm UTC](https://discourse.itk.org/t/divideimagefilter-with-a-constant/1241/2 "2018-08-31T18:04:53Z")

</div>

Divide, Multiply etc filters have a `SetConstant` methods, e.g. [`SetConstant2`](https://itk.org/Doxygen/html/classitk_1_1BinaryGeneratorImageFilter.html#a65e0d35f1d48c42f29605914d30bcb51) to set the second image to the provided constant.

---

<div class="post-metadata">

### Author: ![gdevenyi](https://discourse.itk.org/user_avatar/discourse.itk.org/gdevenyi/32/355_2.png) [@gdevenyi](https://discourse.itk.org/u/gdevenyi)
#### Post date: [August 31, 2018, 6:05pm UTC](https://discourse.itk.org/t/divideimagefilter-with-a-constant/1241/3 "2018-08-31T18:05:48Z")

</div>

Thanks @dzenanz

Where would I have found that? I can’t find any methods on the [https://itk.org/Doxygen/html/classitk\_1\_1DivideImageFilter.html](https://itk.org/Doxygen/html/classitk_1_1DivideImageFilter.html) page

---

<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: [August 31, 2018, 6:09pm UTC](https://discourse.itk.org/t/divideimagefilter-with-a-constant/1241/4 "2018-08-31T18:09:01Z")

</div>

On that page, expand heading “Public methods inherited from BinaryGenerator…”

---

<div class="post-metadata">

### Author: ![gdevenyi](https://discourse.itk.org/user_avatar/discourse.itk.org/gdevenyi/32/355_2.png) [@gdevenyi](https://discourse.itk.org/u/gdevenyi)
#### Post date: [August 31, 2018, 6:10pm UTC](https://discourse.itk.org/t/divideimagefilter-with-a-constant/1241/5 "2018-08-31T18:10:48Z")

</div>

Ahhh, that does not get included in a global text search if its closed 🙂

---

<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: [August 31, 2018, 6:10pm UTC](https://discourse.itk.org/t/divideimagefilter-with-a-constant/1241/6 "2018-08-31T18:10:54Z")

</div>

Also, if your editor has code completion, write `filter->Set` and invoke auto-complete (Ctrl+space usually) or wait a little bit to get a list of methods starting with `Set`.

---

<div class="post-metadata">

### Author: ![gdevenyi](https://discourse.itk.org/user_avatar/discourse.itk.org/gdevenyi/32/355_2.png) [@gdevenyi](https://discourse.itk.org/u/gdevenyi)
#### Post date: [August 31, 2018, 6:11pm UTC](https://discourse.itk.org/t/divideimagefilter-with-a-constant/1241/7 "2018-08-31T18:11:26Z")

</div>

Good point, I should figure out how to make Atom properly parse and complete this stuff.

---

<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: [August 31, 2018, 6:15pm UTC](https://discourse.itk.org/t/divideimagefilter-with-a-constant/1241/8 "2018-08-31T18:15:12Z")

</div>

Or use an IDE instead of a text editor 😃

I am not very hopeful about text editors giving good auto-complete results on heavily templated code. Even Visual Studio and Qt Creator are frequently losing the auto-complete during constant git version updates in my working copy ☹

---

<div class="post-metadata">

### Author: ![gdevenyi](https://discourse.itk.org/user_avatar/discourse.itk.org/gdevenyi/32/355_2.png) [@gdevenyi](https://discourse.itk.org/u/gdevenyi)
#### Post date: [August 31, 2018, 6:16pm UTC](https://discourse.itk.org/t/divideimagefilter-with-a-constant/1241/9 "2018-08-31T18:16:29Z")

</div>

[https://atom.io/](https://atom.io/) can definitely do it, but as mentioned in other threads, I’m just getting up to speed on C++ and so I’m not sure I’m using it “right” yet in terms of getting things parsed and such. Thanks!@

---

<div class="post-metadata">

### Author: ![phcerdan](https://discourse.itk.org/user_avatar/discourse.itk.org/phcerdan/32/286_2.png) [@phcerdan](https://discourse.itk.org/u/phcerdan)
#### Post date: [August 31, 2018, 6:38pm UTC](https://discourse.itk.org/t/divideimagefilter-with-a-constant/1241/10 "2018-08-31T18:38:38Z")

</div>

Editors FTW! 😛

Autocompletion in headers in c++ is a hard task, especially because the headers are headers, and they are not recognized by `compile_commands.json` that many clang-tools use.  
But there is indeed IDE features that works good in editors, I would recommend you have a look to LanguageServerProtocols (LSP), in c++ there are two, [cquery](https://github.com/cquery-project/cquery) and `clangd`. I would recommend right now `cquery`, but don’t miss `clangd` in the future, which lives inside the codebase of the clang compiler :). Cquery creates an index/database, IDE style, and you can call it from whatever connector Atom or any other editor has for LSP’s.

By the way, I have a hacky fork of the linter in vim `w0rp/ALE` [here](https://github.com/phcerdan/ale), that provides linting in template headers providing a `cpp` file that uses that header, and the `compile_commands.json` that can be generated by cmake with the option: `-DCMAKE_EXPORT_COMPILE_COMMANDS:BOOL=ON`.
