Carimas PackedMasks format
Carimas can store and utilize image masks in simple text format files (*.mask). The format of the PackedMasks file is as follows:
Format-PackedMasks [Number of VOIs in this file] [Name of VOI 1] [Width - Dimension of the masked image] [Height - Dimension of the masked image] [Depth - Dimension of the masked image] [Frames - Dimension of the masked image] [VOI color as uint where the Red, Green, Blue and alpha are coded inside the bits of integer 8bits each] [Number of run-length values (the lines for this one VOI coming after this line)] [Run-length of non-masked (negative number) or masked (positive) voxels] [Run-length of non-masked (negative number) or masked (positive) voxels] [Run-length of non-masked (negative number) or masked (positive) voxels] ... [Name of VOI 2] ...
The color is coded as ARGB as follows:
(uint)(Blue | Green << 8 | Red << 16 | Alpha << 24)
,
in other words each component has value 0-255 as follows:
bits 0-8: Blue bits 8-16: Green bits 16-24: Red bits 24-32: Alpha
so if you want to get the Red component, you can get it this way:
red=(byte)((color >> 16) % 256)
Color is used when showing the mask on image in Carimas, and can be otherwise ignored.
For example, if we have a 4×3 pixel image, and the following single mask for it:
0 | 0 | X | 0 |
0 | X | X | 0 |
0 | 0 | 0 | 0 |
Then the PackedMasks file would be (comments starting with // should not be included in the file):
Format-PackedMasks 1 // Nr of VOIs/Masks TestMask // Name of VOI 4 // Width of the image/mask matrix (x dim) 3 // Height of the image/mask matrix (y dim) 1 // Depth of the image/mask matrix (z dim) 1 // Number of image frames 0 // Black color 5 // Mask is defined by 5 values each on their own line -2 // First two voxels, starting from upper left corner, are not included in the mask 1 // Following one voxel belongs to the mask -2 // Following two voxels are not included in the mask 2 // Following two pixels belongs to the mask -5 // Following five pixels are not included in the mask
See also:
Tags: File format, Carimas, Mask, ROI, Image
Updated at: 2025-04-08
Created at: 2025-04-08
Written by: Sauli Piirola