EranOfek / AstroPack

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

`imProc.background.background` doesn't work for u16 images #494

Closed EastEriq closed 3 months ago

EastEriq commented 3 months ago

e.g.

>> imProc.background.background(AI(1))
Check for missing argument or incorrect argument data type in call to function 'log'.

Error in imUtil.background.modeVar_LogHist (line 91)
    LogArray = log(Array(1:Args.DiluteFactor1:end));

Error in imUtil.background.background (line 138)
        [SubImage(Isub).Back, SubImage(Isub).Var] =
        Args.BackFun(SubI,Args.BackFunPar{:});

Error in imProc.background.background (line 131)
                            imUtil.background.background(Obj(Iobj).(Args.ImageProp).(Args.ImagePropIn),... 

Or with other parameters

>> nwindbg=64;
>> imProc.background.background(AI, 'SubSizeXY',nwindbg*[1,1],...
    'Overlap',nwindbg/2,'BackFun',@median,...
    'BackFunPar',{'all','omitnan'},'VarFun',@imUtil.background.rvar);
Error using griddedInterpolant
Sample values must be of type double or single.

Error in interp2>makegriddedinterp (line 226)
    F = griddedInterpolant(varargin{:});

Error in interp2 (line 126)
        F = makegriddedinterp({X, Y}, V, method,extrap);

Error in imUtil.image.sparse2full (line 62)
            Result = interp2(VecX, VecY, SparseImage, VecXX, VecYY,
            Args.InterpMethod);

Error in imUtil.background.background (line 169)
    Back   = imUtil.image.sparse2full(Back, VecX, VecY, size(Image), 'Smooth',false);

Error in imProc.background.background (line 131)
                            imUtil.background.background(Obj(Iobj).(Args.ImageProp).(Args.ImagePropIn),... 

however converting to single all is ok

>> AI(1).Image=single(AI(1).Image);
>> imProc.background.background(AI(1))

ans = 

  AstroImage with properties:

         Image: [9600×6422 single]
          Back: [9600×6422 single]
           Var: [9600×6422 single]
...

Probably it is well known, and other similar functions don't support u16 (see e.g. #73), but why?

EranOfek commented 3 months ago

We decided early on that it will be the user responsibility to convert to single/doube. You can use: AI=cast(AI, 'single');

On Sun, Aug 11, 2024 at 4:55 PM EastEriq @.***> wrote:

e.g.

imProc.background.background(AI(1)) Check for missing argument or incorrect argument data type in call to function 'log'.

Error in imUtil.background.modeVar_LogHist (line 91) LogArray = log(Array(1:Args.DiluteFactor1:end));

Error in imUtil.background.background (line 138) [SubImage(Isub).Back, SubImage(Isub).Var] = Args.BackFun(SubI,Args.BackFunPar{:});

Error in imProc.background.background (line 131) imUtil.background.background(Obj(Iobj).(Args.ImageProp).(Args.ImagePropIn),...

Or with other parameters

nwindbg=64; imProc.background.background(AI, 'SubSizeXY',nwindbg*[1,1],... @.,... @.); Error using griddedInterpolant Sample values must be of type double or single.

Error in interp2>makegriddedinterp (line 226) F = griddedInterpolant(varargin{:});

Error in interp2 (line 126) F = makegriddedinterp({X, Y}, V, method,extrap);

Error in imUtil.image.sparse2full (line 62) Result = interp2(VecX, VecY, SparseImage, VecXX, VecYY, Args.InterpMethod);

Error in imUtil.background.background (line 169) Back = imUtil.image.sparse2full(Back, VecX, VecY, size(Image), 'Smooth',false);

Error in imProc.background.background (line 131) imUtil.background.background(Obj(Iobj).(Args.ImageProp).(Args.ImagePropIn),...

however converting to single all is ok

AI(1).Image=single(AI(1).Image); imProc.background.background(AI(1))

ans =

AstroImage with properties:

     Image: [9600×6422 single]
      Back: [9600×6422 single]
       Var: [9600×6422 single]

...

Probably it is well known, and other similar functions don't support u16 (see e.g. #73 https://github.com/EranOfek/AstroPack/issues/73), but why?

— Reply to this email directly, view it on GitHub https://github.com/EranOfek/AstroPack/issues/494, or unsubscribe https://github.com/notifications/unsubscribe-auth/ABJUQ4LLGOONYTKGY72TTULZQ5UMBAVCNFSM6AAAAABMKY4ZMCVHI2DSMVQWIX3LMV43ASLTON2WKOZSGQ2TSNRQGQ2DSMQ . You are receiving this because you are subscribed to this thread.Message ID: @.***>