View Issue Details

IDProjectCategoryView StatusLast Update
0002919CCdcielGeneralpublic26-05-08 20:11
ReporterHan Assigned ToPatrick Chevalley  
PrioritynormalSeverityfeatureReproducibilityhave not tried
Status resolvedResolutionfixed 
Summary0002919: Spectroscopy, ghost stars supression for focusing and solving.
DescriptionFor bright stars, a reflection on the slit glas results in two ghost stars with a different focus point. This is problematic for focusing and solving.

To fix this there are two options:

1) Focus on the brightest star only. This will not help for solving but in some case solving could cope with ghost stars.
2) Blackout the ghost star above and below using a software routine.

Which option to implement? 1) or 2) or both?

For 2) I have developed a simple brute force procedure which works. I will attach it later.
TagsNo tags attached.

Activities

Han

26-05-03 12:32

reporter  

Untitled_blackout.png (700,323 bytes)   
Untitled_blackout.png (700,323 bytes)   

Nicolàs de Hilster

26-05-03 13:38

reporter   ~0009780

Option 2 has my preference for the following reasons:

Focussing: when not suppressing double reflections the average HFD will depend on the average of the direct star image and its reflection, but as the reflection has its best focus in another plane (while the direct image of the star reduces in size its reflection will get larger), the software will end up with a focus distance which is not at the slit, causing lower efficiency in the spectroscope. Of course it will help when focussing is done on the brightest star alone.

Plate-solving: the double reflections add 'new' stars to the image, which in turn are detected by the plate-solve software. This can be mitigated by lowering the exposure time, but that will cause issues when doing a slew with an offset to get a very bright star on the slit. With that procedure three slews, two plate-solves, and one focussing procedure are involved. As we cannot predict what the star field will look like it must assume that three different exposure times are required. Masking the double reflection will avoid this issue.

We have seen that brute-force method works well (thanks Han!), but it could be improved by not looking at each bright pixel and adding a mask for that, but to find the bright centroid, calculate its HFD, and generate the mask based on that, in which the diameter of the masking dots is a percentage of the HFD (generally a value larger than 100% would be required). It is no problem if that takes an additional second or two, as this masking is only required during the initial stage of the spectroscopic sequence (and during focussing).

Nicolàs

Patrick Chevalley

26-05-03 14:10

administrator   ~0009782

I agree it is good to have your masking method with option 2, this reflections are very annoying so having an option to get rid of them is interesting.
I never try the mask personally, but the good experience by Nicolàs is important.
Personally I autofocus only once per night and I select a field without bright star for that. This probably work for me because I have a RC with a carbon tube.

It need to take account for the slit orientation in the camera, it can be horizontal as in Nicolàs image, but also vertical, other angle are not used.
It also need parameters for the reflection distance from the star and diameter of the reflection.
One reflection is always larger than the other but it is probably sufficient to have the diameter of the larger one.
This also need an option to deactivate the function because other spectroscope use a polished metallic slit that not have secondary reflection.

Nicolàs de Hilster

26-05-03 14:23

reporter   ~0009783

The way Han has currently implemented it is by defining both dX and dY for the centre of the masking dots relative to the direct image of the star. If I am right the dX is positive for the upper reflection and negative for the lower, so that it can still work with a slit with a non perpendicular orientation. In an ideal world the double reflections could be automatically detecting by aiming the telescope at a very bright star (only once to detect the offsets, which can then be stored, so similar to doing a guiding calibration run). Currently I have these masking dots in my guider/finder darks.

Han

26-05-03 16:46

reporter   ~0009784

Last edited: 26-05-03 16:50

I lost my code {rare but it happened} but here is a new version. It is a very simple brute force approach to blackout the two reflections. Threshold default something like 5000. dx=0, dy=45, diameter=10. No star detection. Just simply a threshold. Any pixel above the threshold results in two round black spot drawn at dx, dy distance.

corrected code:

procedure TFits.ghost_blackout(threshold,dx,dy,diameter: integer);//blackout of ghost stars for spectroscopy
var jy,jx,m,n,xm,ym,qy,rx, radius,sqrradius,ny,nx: integer;
    procedure setpixel(ay,ax : integer; val: single);
    begin
      if ((ax>=0) and (ax<Fwidth) and (ay>=0) and (ay<Fheight)) then
        Fimage[0,ay ,ax]:=val;
    end;
    function getpixel(ay,ax: integer): single;
    begin
      if ((ax>=0) and (ax<Fwidth) and (ay>=0) and (ay<Fheight)) then
        result:=Fimage[0,ay ,ax]
      else
        result:=9999999;
    end;
begin
  Radius:=diameter div 2;
  sqrradius:=sqr(diameter) div 4;
  try
    for jy:=1 to Fheight-2 do
     for jx:=1 to Fwidth-2 do
     begin
       if ((fimage[0,jy , jx ]>threshold) and
           (fimage[0,jy+1 ,jx ]>threshold) and
           (fimage[0,jy ,jx+1]>threshold) and
           (fimage[0,jy+1 ,jx+1]>threshold)) then
       begin
         if ((getpixel(jy+dy,jx+dx))< (getpixel(jy,jx))) then //this is a fainter ghost
         for ny:=-radius to +radius do
           for nx:=-radius to +radius do
             if sqr(ny)+sqr(nx)<=sqr(radius) then
                 setpixel(jy+ny+dy,jx+nx+dx,$000000); //blackout ghost above


         if ((getpixel(jy-dy,jx-dx))< (getpixel(jy,jx))) then //this is a fainter ghost
         for ny:=-radius to +radius do
           for nx:=-radius to +radius do
             if sqr(ny)+sqr(nx)<=sqr(radius) then
                 setpixel(jy+ny-dy,jx+nx-dx,$000000); //blackout ghost below
       end;
     end;
  except
  end;
end;
Untitled.png (1,088,532 bytes)   
Untitled.png (1,088,532 bytes)   

Nicolàs de Hilster

26-05-03 17:41

reporter   ~0009785

Thanks Han, that brute-force method should do. Looking forward testing it! :-)

Nicolàs

Han

26-05-04 12:21

reporter   ~0009786

I have updated the code with a centering routine. This should work reliable. The only problem is how to squeeze the four input parameters in the spectroscopy tab which is already full. But I leave that to Patrick.

procedure TFits.ghost_blackout(threshold,dx,dy,diameter: integer);//blackout of ghost stars for spectroscopy
var
  jy,jx,radius,sqrradius,ny,nx,fwidth,fheight,cx,cy,fluxmain,fluxghost1,fluxghost2,gy,gx: integer;

    procedure setpixel(ay,ax : integer; val: single);
    begin
      if ((ax>=0) and (ax<Fwidth) and (ay>=0) and (ay<Fheight)) then
        fimage[0,ay ,ax]:=val;
    end;

    function getpixel(ay,ax: integer): single;
    begin
      if ((ax>=0) and (ax<Fwidth) and (ay>=0) and (ay<Fheight)) then
        result:=fimage[0,ay ,ax]
      else
        result:=0;
    end;

    function center_of_gravity(iy,ix : integer; out cy,cx,flux : integer): boolean;
    var
      sumval,sumvalx,sumvaly : double;
      val : single;
      i,j,signal_counter: integer;
    begin
      result:=false;//default failure
      flux:=0;//default failure
      SumVal:=0;
      SumValX:=0;
      SumValY:=0;
      signal_counter:=0;

      for j:=-diameter to diameter do //search wide enough to center on donuts
      for i:=-diameter to diameter do
      begin
        val:=getpixel(iy+j,ix+i);
        if val>threshold div 2 then
        begin
          SumVal:=SumVal+val;
          SumValX:=SumValX+val*(i);
          SumValY:=SumValY+val*(j);
          inc(signal_counter); {how many pixels are illuminated}
        end;
      end;
      if signal_counter<4 then //no star detected
      begin
        cy:=iy;
        cx:=ix;
      end
      else
      begin //center of gravity
        cy:=round(iy+SumValY/SumVal);
        cx:=round(ix+SumValX/SumVal);
        flux:=round(Sumval);
        result:=true;

      end;
    end;

begin
  Radius:=diameter div 2;
  sqrradius:=sqr(radius);
  fheight:=length(fimage[0]);
  fwidth:=length(fimage[0,0]);

  sqrradius:=sqr(diameter) div 4;
  try
    for jy:=1 to Fheight-2 do
    for jx:=1 to Fwidth-2 do
    begin
      if ((fimage[0,jy , jx ]>threshold) and
          (fimage[0,jy+1 ,jx ]>threshold) and
          (fimage[0,jy ,jx+1]>threshold) and
          (fimage[0,jy+1 ,jx+1]>threshold)) then //four pixels above threshold
      begin
        if center_of_gravity(jy,jx,cy,cx,fluxmain) then //found a possible true star
        begin
          if getpixel(cy+dy,cx+dx)<>0 then
            center_of_gravity(cy+dy,cx+dy,gy,gx,fluxghost1) //calculate ghost1 flux
          else //no need to check
            fluxghost1:=0;

          if getpixel(cy-dy,cx-dx)<>0 then
            center_of_gravity(cy-dy,cx-dy,gy,gx,fluxghost2) //calculate ghost2 flux
          else //no need to check
            fluxghost2:=0;

          if ((fluxghost1<fluxmain) and (fluxghost2<fluxmain)) then //found the main star and not a ghost
          begin
            if getpixel(cy+dy,cx+dx)<>0 then //ghost star is not yet blackouted
            for ny:=-radius to +radius do
              for nx:=-radius to +radius do
               if sqr(ny)+sqr(nx)<=sqrradius then //round spot
                 setpixel(cy+dy+ny,cx+dx+nx,$000000); //blackout ghost1 above

           if getpixel(cy-dy,cx-dx)<>0 then //ghost star is not yet blackouted
           for ny:=-radius to +radius do
              for nx:=-radius to +radius do
               if sqr(ny)+sqr(nx)<=sqrradius then //round spot
                 setpixel(cy-dy+ny,cx-dx+nx,$000000); //blackout ghost2 below
          end;
        end;
      end;
    end;
  except
  end;
end;
ghost_blackout v2.jpg (322,907 bytes)   
ghost_blackout v2.jpg (322,907 bytes)   

Patrick Chevalley

26-05-06 14:49

administrator   ~0009788

Thank you Han, I add your method to mask this ghost reflection.

The new method is called after an eventual dark removal and noise filter.

The settings are in the internal guider camera tab.
But to make it not intrusive for people that not need it, this is visible only if the spectroscopy function are active, and the detail setting is visible only if the main option to remove the reflection is checked.

There is no additional setting for the finder, but if the finder camera is the same as the guider the ghost reflection are also removed using the same settings.

This is available in version 0.9.94-4088 : https://vega.ap-i.net/pub/ccdciel/daily_build/

Nicolàs de Hilster

26-05-06 21:34

reporter   ~0009797

Thanks Patrick and Han, will test it as soon as weather allows.

Nicolàs de Hilster

26-05-06 23:48

reporter   ~0009798

I can now confirm that the masking algorithm works fine, once again thanks Han and Patrick!

Patrick Chevalley

26-05-07 11:45

administrator   ~0009801

Thank you for testing Nicolàs.

I make a change today so the mask position and size are adjusted automatically for binning change.

What it do is to save the current binning when you adjust the position.
If the binning change later the x,y,size number in the interface do not change but this is adjusted in the ghost_blackout() procedure using the binning in the current file header.
This way it work when using a different binning for the autofocus or the finder.

This can be tested with version 0.9.94-4093 : https://vega.ap-i.net/pub/ccdciel/daily_build/

Han

26-05-07 16:43

reporter   ~0009804

I have added some lines in the documentation about this new feature, tab camera and tab spectroscopy.

Nicolàs de Hilster

26-05-08 11:18

reporter   ~0009805

Thanks!

Patrick Chevalley

26-05-08 20:11

administrator   ~0009806

Thank you for the documentation Han.

Issue History

Date Modified Username Field Change
26-05-03 12:32 Han New Issue
26-05-03 12:32 Han File Added: Untitled_blackout.png
26-05-03 13:38 Nicolàs de Hilster Note Added: 0009780
26-05-03 14:10 Patrick Chevalley Note Added: 0009782
26-05-03 14:23 Nicolàs de Hilster Note Added: 0009783
26-05-03 16:46 Han Note Added: 0009784
26-05-03 16:46 Han File Added: Untitled.png
26-05-03 16:48 Han Note Edited: 0009784
26-05-03 16:50 Han Note Edited: 0009784
26-05-03 17:41 Nicolàs de Hilster Note Added: 0009785
26-05-04 12:21 Han Note Added: 0009786
26-05-04 12:21 Han File Added: ghost_blackout v2.jpg
26-05-06 14:49 Patrick Chevalley Note Added: 0009788
26-05-06 21:34 Nicolàs de Hilster Note Added: 0009797
26-05-06 23:48 Nicolàs de Hilster Note Added: 0009798
26-05-07 11:45 Patrick Chevalley Note Added: 0009801
26-05-07 16:43 Han Note Added: 0009804
26-05-08 11:18 Nicolàs de Hilster Note Added: 0009805
26-05-08 20:11 Patrick Chevalley Assigned To => Patrick Chevalley
26-05-08 20:11 Patrick Chevalley Status new => resolved
26-05-08 20:11 Patrick Chevalley Resolution open => fixed
26-05-08 20:11 Patrick Chevalley Note Added: 0009806