[Insight-users] SingleBitBinaryImage

Dan Mueller dan.muel at gmail.com
Mon Jan 31 03:39:56 EST 2011


Hi Gib,

Indeed, IO is not (yet) supported for itk::SingleBitBinaryImage.

It may be possible to "hack" IO support. This could be achieved using
the following approach:

Writing:
1. Create single-bit-binary image as desired
2. Create empty normal image with same metadata as single-bit-binary image
3. Divide width/height of normal image by number of bits per pixel (eg. 8)
4. Set the buffer of the normal image to the buffer of the
single-bit-binary image
5. Use file-writer to write normal image to disk

Reading:
1. Use file-reader to read 'normal' image from disk
2. Create empty single-bit-binary image with same metadata as image
read from disk
3. Multiply width/height of single-bit-binary image by number of bits
per pixel (eg. 8)
4. Set the buffer of the single-bit-binary image to the buffer of the read image
5. Use the single-bit-binary image as desired

Note: care must be taken if the image dimensions are not multiples of 32...

HTH

Cheers, Dan

On 28 January 2011 22:12, Gib  Bogle <g.bogle at auckland.ac.nz> wrote:
> Hi Dan,
>
> Actually my main reason for pursuing this was to be able to read/write
> single-bit binary images with ITK (e.g. GIPL format), but as it turns out
> binary is not yet supported for IO.  Oh well.
>
> Thanks anyway
> Gib
>
> Quoting Dan Mueller <dan.muel at gmail.com>:
>
>> Hi Gib,
>>
>> Great to hear that you got things working. Consider leaving a review
>> on the Insight Journal article, so that the contribution may be
>> considered for inclusion in the toolkit.
>>
>> Cheers, Dan
>>
>> On 26 January 2011 06:31, Gib Bogle <g.bogle at auckland.ac.nz> wrote:
>>>
>>> Hi Dan,
>>>
>>> I've now located the code package for your binary image method, and of
>>> course my previous message is rendered invalid.  I'll now try to use your
>>> code.
>>>
>>> Thanks
>>> Gib


More information about the Insight-users mailing list