EranOfek / AstroPack

Astronomy & Astrophysics Software Pacakge
Other
16 stars 4 forks source link

Mask is not propagated in AstroImage.funBinaryProp(Obj1, Obj2, operator) if the mask of Obj1 is empty. #429

Closed michayesh closed 4 months ago

michayesh commented 4 months ago

Here is an example: Obj1 = AstroImage({ones(3,3)}); % empty mask Obj2 = AstroImage({ones(3,3)}); Obj2.Mask = uint32([0 0 0; 0 0 0; 1 1 1]); % mask for Obj2 res = funBinaryProp(Obj1, Obj2, @plus,'DataProp','MaskData','DataPropIn','Data');

res.Mask

ans =

 []

Now if I run: Obj1 = AstroImage({ones(3,3)}); Obj1.Mask = uint32(zeros(3,3)); % mask for Obj1 Obj2 = AstroImage({ones(3,3)}); Obj2.Mask = uint32(rand(3,3)); % mask for Obj2 res = funBinaryProp(Obj1, Obj2, @plus,'DataProp','MaskData','DataPropIn','Data'); The mask is propagated into res:

res.Mask ans =

3×3 uint32 matrix

0 0 0 0 0 0 1 1 1

EranOfek commented 4 months ago

This behavior is now mentioned in the help of this function. In order to avoid it, populate the Mask of the primary image. Note that you typically have to do it using: imProc.mask.maskSaturated which you are supposed to run on the raw image prior to any reduction step.