[Insight-users] Question for SingleBitBinaryImage

Luis Ibanez luis.ibanez at kitware.com
Wed Dec 1 22:51:56 EST 2010


On Tue, Nov 30, 2010 at 10:20 AM, Владимир Ткачук
<vova.tkachuk at gmail.com> wrote:
> Hi Dan!
>
> Thanks for the answer. I added the review to the article
> (http://www.insight-journal.org/user/view/2806), excuse me if it is
> not so good, but I do not have a lot of experience in reviewing.
>
> As a possible solution, that guaranties safe multi-thread access I
> used combination of SingleBitBinaryImage and SliceContiguousImage. So,
> I created my image type, similar to SliceContigouousImage, but each
> slice is a buffer where each bit means a pixel (like in
> SingleBitBinaryImage). If I understood ITK multi-threading right, in
> case of 3-d image it would not share one 2-d slice with different
> threads.
>
-----------------------------------------------------------------

That's correct.

This partition is done in:

       ImageSource::SplitRequestedRegion(...)

lines 145-171,

In retrospective,

        This could be improved/modifed by introducing a class
similar to the ImageRegionSplitter to provide other policies
for image splitting among multiple threads.

...maybe the ImageRegionSplitter family of classes could
be used in the ImageSource for partitioning the image.

Code/Common/itkImageRegionSplitter.h


       Luis


---
> From your experience and knowledge, would it work (be thread safe), or
> there are some pitfalls than I did not take in account?
>
> Thanks,
> Volodymyr
>
> On Thu, Nov 18, 2010 at 1:45 PM, Dan Mueller <dan.muel at gmail.com> wrote:
>> Hi Volodymyr,
>>
>> (I have also posted to Insight-Users mailing list)
>>
>> This is a good question. I would say that SingleBitBinaryImage is NOT
>> safe for writing from multiple threads. The reason being that another
>> thread may have written the 32-bit mask before the current thread
>> does. The only way it can be thread safe is if the multi-threader
>> divides the image into regions exactly aligned with the underlying
>> 32-bit masks (eg. the regions are modulo 32).
>>
>> Please add a review to the Insight Journal, and I will try to think of
>> the best way to address this...
>>
>> Regards, Dan
>>
>> On 18 November 2010 11:44, Владимир Ткачук <vova.tkachuk at gmail.com> wrote:
>>> Hello!
>>>
>>> I read your article "Alternative Memory Models for ITK Images" at ITK
>>> journal. And I want to use itk::SingleBitBinaryImage.
>>>
>>> But I cannot clearly understand, how it feel with multi threading. It
>>> is definitely safe for read, what about writing? If two regions do not
>>> overlap in pixels, but in fact use the same "unsigned int" memory
>>> block? For instance one use first 16 bits (pixels), and another - last
>>> 16 bits. Is it safe for parallel writing? Can I use
>>> SingleBitBinaryImage<> as output for standard ITK filters (such as
>>> BinaryThresholdFilter) as it, or additional work around needed?
>>>
>>>
>>> Thank you for answers,
>>>
>>> Volodymyr Tkachuk
>>>
>>
> _____________________________________
> Powered by www.kitware.com
>
> Visit other Kitware open-source projects at
> http://www.kitware.com/opensource/opensource.html
>
> Kitware offers ITK Training Courses, for more information visit:
> http://www.kitware.com/products/protraining.html
>
> Please keep messages on-topic and check the ITK FAQ at:
> http://www.itk.org/Wiki/ITK_FAQ
>
> Follow this link to subscribe/unsubscribe:
> http://www.itk.org/mailman/listinfo/insight-users
>


More information about the Insight-users mailing list