# DataAugmentation error with masks

**URL:** <https://discourse.julialang.org/t/dataaugmentation-error-with-masks/133574>\
**Category:** General Usage\
**Tags:** augmentation\
**Created:** [October 31, 2025, 11:31am UTC](https://discourse.julialang.org/t/dataaugmentation-error-with-masks/133574 "2025-10-31T11:31:23Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![cirobr](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/cirobr/32/219994_2.png) [@cirobr](https://discourse.julialang.org/u/cirobr)\
**Post date:** [October 31, 2025, 11:31am UTC](https://discourse.julialang.org/t/dataaugmentation-error-with-masks/133574/1 "2025-10-31T11:31:23Z")

</div>

Cheers,

I’m receiving an error when augmenting masks prior to training a model for semantic segmentation. Consider `img` as RGB image matrix. Consider `mask` as a matrix with integer elements from 1 to 11. Code is as follows:

```julia-auto
item1 = Image(img)
item2 = MaskMulti(mask)

tfm = Maybe(FlipX{2}()) |> Rotate(15) |> Zoom((1.0, 1.2)) |>
      AdjustBrightness(0.3) |> AdjustContrast(0.3) |>
      CenterCrop((256,256))
img_tf = apply(tfm, (item1, item2))

```

Error message as follows:

```julia-auto
ERROR: MethodError: no method matching length(::DataAugmentation.MaskMulti{2, Int64, Int64})
The function `length` exists, but no method is defined for this combination of argument types.

Closest candidates are:
  length(::LLVM.ArrayType)
   @ LLVM ~/.julia/packages/LLVM/iza6e/src/core/type.jl:343
  length(::DataStructures.EnumerateAll)
   @ DataStructures ~/.julia/packages/DataStructures/IrAJn/src/multi_dict.jl:96
  length(::LLVM.ConstantArray)
   @ LLVM ~/.julia/packages/LLVM/iza6e/src/core/value/constant.jl:421
  ...

```

The error disappears in the following conditions:

1. If the transformation is restricted to the image only.
2. If the transformation is applied to image and mask, but the command line corresponding to `AdjustBrightness` and `AdjustContrast` is commented out.

Thanks in advance for advising.
