# Combining probing of pixel values with streaming

**URL:** https://discourse.itk.org/t/combining-probing-of-pixel-values-with-streaming/2010
**Category:** Engineering
**Created:** [July 5, 2019, 10:55am UTC](https://discourse.itk.org/t/combining-probing-of-pixel-values-with-streaming/2010 "2019-07-05T10:55:22Z")
**Posts on this page:** 6
**Page:** 1

<div class="post-metadata">

### Author: ![grothausmann.roman](https://discourse.itk.org/user_avatar/discourse.itk.org/grothausmann.roman/32/582_2.png) [@grothausmann.roman](https://discourse.itk.org/u/grothausmann.roman)
#### Post date: [July 5, 2019, 10:55am UTC](https://discourse.itk.org/t/combining-probing-of-pixel-values-with-streaming/2010/1 "2019-07-05T10:55:22Z")

</div>

Hi!

How would I have to adjust the code of my CLI [probeCoords](https://github.com/romangrothausmann/ITK-CLIs/blob/4e3cb84b2a86203cd4f376b27aa8999599a45858/probeCoords.cxx) to employ streaming? It just loads an image and reports the pixel values for some specific indices and is based on [https://itk.org/Doxygen/html/Examples\_2DataRepresentation\_2Image\_2Image3\_8cxx-example.html](https://itk.org/Doxygen/html/Examples_2DataRepresentation_2Image_2Image3_8cxx-example.html).  
This should be possible to realise with streaming, however just adding `StreamingImageFilter` does not suffice because only for one chunk `GetPixel()` will work and when all pixels are probed further streaming is not necessary and should be stopped. I guess most efficient would be to test every chunk if `GetPixel()` succeeds for all specified indices and to continue until all are found. But how to check if `GetPixel()` succeeded within a chunk?

Thanks for any help or hints.  
Roman

---

<div class="post-metadata">

### Author: ![blowekamp](https://discourse.itk.org/user_avatar/discourse.itk.org/blowekamp/32/79_2.png) [@blowekamp](https://discourse.itk.org/u/blowekamp)
#### Post date: [July 5, 2019, 12:03pm UTC](https://discourse.itk.org/t/combining-probing-of-pixel-values-with-streaming/2010/2 "2019-07-05T12:03:29Z")

</div>

You should call [`Image::SetRequestedRegion`](https://itk.org/Doxygen/html/classitk_1_1ImageBase.html#a07a352e10a135c720fbb85cb1135d403) before calling update. If the input Image file format supports streaming then just the requested region will be read.

---

<div class="post-metadata">

### Author: ![grothausmann.roman](https://discourse.itk.org/user_avatar/discourse.itk.org/grothausmann.roman/32/582_2.png) [@grothausmann.roman](https://discourse.itk.org/u/grothausmann.roman)
#### Post date: [July 5, 2019, 12:12pm UTC](https://discourse.itk.org/t/combining-probing-of-pixel-values-with-streaming/2010/3 "2019-07-05T12:12:38Z")

</div>

Many thanks @blowekamp for your feedback. So I basically should create a one-pixel sized region for each index before each `GetPixel()`? Would it matter (be faster) if the list of indices is sorted according to their first appearance when streaming?

---

<div class="post-metadata">

### Author: ![blowekamp](https://discourse.itk.org/user_avatar/discourse.itk.org/blowekamp/32/79_2.png) [@blowekamp](https://discourse.itk.org/u/blowekamp)
#### Post date: [July 5, 2019, 12:18pm UTC](https://discourse.itk.org/t/combining-probing-of-pixel-values-with-streaming/2010/4 "2019-07-05T12:18:25Z")

</div>

I don’t think doing them in order would make much of a difference since this operation is going all the way out to disk.

If you ordered the query points, then grouped them into the same slice or scan line. Then reduced the number of requested region to take advantage of the coherence it might make a performance difference.

---

<div class="post-metadata">

### Author: ![grothausmann.roman](https://discourse.itk.org/user_avatar/discourse.itk.org/grothausmann.roman/32/582_2.png) [@grothausmann.roman](https://discourse.itk.org/u/grothausmann.roman)
#### Post date: [July 5, 2019, 12:48pm UTC](https://discourse.itk.org/t/combining-probing-of-pixel-values-with-streaming/2010/5 "2019-07-05T12:48:53Z")

</div>

Wonderful, works like a charm with these [changes](https://github.com/romangrothausmann/ITK-CLIs/commit/9a09e5910e85a707729b9262b81d4f953a684374), nearly no loading time and hardly any memory footprint. Many thanks @blowekamp for the help!

---

<div class="post-metadata">

### Author: ![blowekamp](https://discourse.itk.org/user_avatar/discourse.itk.org/blowekamp/32/79_2.png) [@blowekamp](https://discourse.itk.org/u/blowekamp)
#### Post date: [July 5, 2019, 12:57pm UTC](https://discourse.itk.org/t/combining-probing-of-pixel-values-with-streaming/2010/6 "2019-07-05T12:57:31Z")

</div>

Great! Glad you were able to get it working.
