Skip to content

Commit

Permalink
add stacking to image processing
Browse files Browse the repository at this point in the history
  • Loading branch information
aaronwmorris committed Oct 2, 2023
1 parent 686b52f commit 0fb81cc
Show file tree
Hide file tree
Showing 4 changed files with 127 additions and 10 deletions.
7 changes: 7 additions & 0 deletions indi_allsky/flask/forms.py
Original file line number Diff line number Diff line change
Expand Up @@ -3415,4 +3415,11 @@ class IndiAllskyImageProcessingForm(FlaskForm):
SQM_ROI_X2 = IntegerField('SQM ROI x2', validators=[SQM_ROI_validator])
SQM_ROI_Y2 = IntegerField('SQM ROI y2', validators=[SQM_ROI_validator])
SQM_FOV_DIV = SelectField('SQM FoV', choices=IndiAllskyConfigForm.SQM_FOV_DIV_choices, validators=[SQM_FOV_DIV_validator])
IMAGE_STACK_METHOD = SelectField('Image stacking method', choices=IndiAllskyConfigForm.IMAGE_STACK_METHOD_choices, validators=[DataRequired(), IMAGE_STACK_METHOD_validator])
IMAGE_STACK_COUNT = SelectField('Stack count', choices=IndiAllskyConfigForm.IMAGE_STACK_COUNT_choices, validators=[DataRequired(), IMAGE_STACK_COUNT_validator])
IMAGE_STACK_ALIGN = BooleanField('Register images')
IMAGE_ALIGN_DETECTSIGMA = IntegerField('Alignment sensitivity', validators=[DataRequired(), IMAGE_ALIGN_DETECTSIGMA_validator])
IMAGE_ALIGN_POINTS = IntegerField('Alignment points', validators=[DataRequired(), IMAGE_ALIGN_POINTS_validator])
IMAGE_ALIGN_SOURCEMINAREA = IntegerField('Minimum point area', validators=[DataRequired(), IMAGE_ALIGN_SOURCEMINAREA_validator])
#IMAGE_STACK_SPLIT = BooleanField('Stack split screen')

18 changes: 9 additions & 9 deletions indi_allsky/flask/templates/config.html
Original file line number Diff line number Diff line change
Expand Up @@ -1613,28 +1613,28 @@

<div class="form-group row">
<div class="col-sm-2">
{{ form_config.IMAGE_STACK_METHOD.label(class='col-form-label') }}
{{ form_config.IMAGE_STACK_COUNT.label(class='col-form-label') }}
</div>
<div class="col-sm-2">
{{ form_config.IMAGE_STACK_METHOD(class='form-control bg-secondary') }}
<div id="IMAGE_STACK_METHOD-error" class="invalid-feedback text-danger" style="display: none;"></div>
{{ form_config.IMAGE_STACK_COUNT(class='form-control bg-secondary') }}
<div id="IMAGE_STACK_COUNT-error" class="invalid-feedback text-danger" style="display: none;"></div>
</div>
<div class="col-sm-8">
<div>Method to use for image stacking</div>
<div><span class="badge rounded-pill bg-info text-dark">Note</span>Stacking disabled during daytime and moon mode</div>
<div>Number of images to be stacked</div>
</div>
</div>

<div class="form-group row">
<div class="col-sm-2">
{{ form_config.IMAGE_STACK_COUNT.label(class='col-form-label') }}
{{ form_config.IMAGE_STACK_METHOD.label(class='col-form-label') }}
</div>
<div class="col-sm-2">
{{ form_config.IMAGE_STACK_COUNT(class='form-control bg-secondary') }}
<div id="IMAGE_STACK_COUNT-error" class="invalid-feedback text-danger" style="display: none;"></div>
{{ form_config.IMAGE_STACK_METHOD(class='form-control bg-secondary') }}
<div id="IMAGE_STACK_METHOD-error" class="invalid-feedback text-danger" style="display: none;"></div>
</div>
<div class="col-sm-8">
<div>Number of images to be stacked</div>
<div>Method to use for image stacking</div>
<div><span class="badge rounded-pill bg-info text-dark">Note</span>Stacking disabled during daytime and moon mode</div>
</div>
</div>

Expand Down
84 changes: 84 additions & 0 deletions indi_allsky/flask/templates/imageprocessing.html
Original file line number Diff line number Diff line change
Expand Up @@ -241,6 +241,84 @@
<div class="col-sm-8">Black level cutoff in standard deviations. Lower number results in greater dynamic range.</div>
</div>

<hr>

<div class="form-group row">
<div class="col-sm-2">
{{ form_image_processing.IMAGE_STACK_COUNT.label(class='col-form-label') }}
</div>
<div class="col-sm-2">
{{ form_image_processing.IMAGE_STACK_COUNT(class='form-control bg-secondary') }}
<div id="IMAGE_STACK_COUNT-error" class="invalid-feedback text-danger" style="display: none;"></div>
</div>
<div class="col-sm-8">
<div>Number of images to be stacked</div>
</div>
</div>

<div class="form-group row">
<div class="col-sm-2">
{{ form_image_processing.IMAGE_STACK_METHOD.label(class='col-form-label') }}
</div>
<div class="col-sm-2">
{{ form_image_processing.IMAGE_STACK_METHOD(class='form-control bg-secondary') }}
<div id="IMAGE_STACK_METHOD-error" class="invalid-feedback text-danger" style="display: none;"></div>
</div>
<div class="col-sm-8">
<div>Method to use for image stacking</div>
</div>
</div>

<div class="form-group row">
<div class="col-sm-2">
{{ form_image_processing.IMAGE_STACK_ALIGN.label }}
</div>
<div class="col-sm-2">
<div class="form-switch">
{{ form_image_processing.IMAGE_STACK_ALIGN(class='form-check-input') }}
<div id="IMAGE_STACK_ALIGN-error" class="invalid-feedback text-danger" style="display: none;"></div>
</div>
</div>
<div class="col-sm-8">
<div><span class="badge rounded-pill bg-warning text-dark">Warning</span>Here be dragons</div>
<div>Align images before stacking.</div>
</div>
</div>

<div class="form-group row">
<div class="col-sm-2">
{{ form_image_processing.IMAGE_ALIGN_DETECTSIGMA.label(class='col-form-label') }}
</div>
<div class="col-sm-2">
{{ form_image_processing.IMAGE_ALIGN_DETECTSIGMA(class='form-control bg-secondary') }}
<div id="IMAGE_ALIGN_DETECTSIGMA-error" class="invalid-feedback text-danger" style="display: none;"></div>
</div>
<div class="col-sm-8">Factor of background std-dev above which is considered a detection.</div>
</div>

<div class="form-group row">
<div class="col-sm-2">
{{ form_image_processing.IMAGE_ALIGN_POINTS.label(class='col-form-label') }}
</div>
<div class="col-sm-2">
{{ form_image_processing.IMAGE_ALIGN_POINTS(class='form-control bg-secondary') }}
<div id="IMAGE_ALIGN_POINTS-error" class="invalid-feedback text-danger" style="display: none;"></div>
</div>
<div class="col-sm-8">The maximum number of control point-sources to find the transformation.</div>
</div>

<div class="form-group row">
<div class="col-sm-2">
{{ form_image_processing.IMAGE_ALIGN_SOURCEMINAREA.label(class='col-form-label') }}
</div>
<div class="col-sm-2">
{{ form_image_processing.IMAGE_ALIGN_SOURCEMINAREA(class='form-control bg-secondary') }}
<div id="IMAGE_ALIGN_SOURCEMINAREA-error" class="invalid-feedback text-danger" style="display: none;"></div>
</div>
<div class="col-sm-8">Minimum number of connected pixels to be considered a source.</div>
</div>


<hr>

<div class="form-group row">
Expand Down Expand Up @@ -502,13 +580,19 @@ <h5>These options are applied to the unprocessed image automatically</h5>
'SQM_ROI_Y1',
'SQM_ROI_X2',
'SQM_ROI_Y2',
'IMAGE_STACK_METHOD',
'IMAGE_STACK_COUNT',
'IMAGE_ALIGN_DETECTSIGMA',
'IMAGE_ALIGN_POINTS',
'IMAGE_ALIGN_SOURCEMINAREA',
];

const checkbox_field_names = [
'NIGHT_CONTRAST_ENHANCE',
'CONTRAST_ENHANCE_16BIT',
'IMAGE_STRETCH__MODE1_ENABLE',
'AUTO_WB',
'IMAGE_STACK_ALIGN',
];

var fields = {};
Expand Down
28 changes: 27 additions & 1 deletion indi_allsky/flask/views.py
Original file line number Diff line number Diff line change
Expand Up @@ -3548,6 +3548,12 @@ def get_context(self):
'IMAGE_FLIP_H' : self.indi_allsky_config.get('IMAGE_FLIP_H', True),
'DETECT_MASK' : self.indi_allsky_config.get('DETECT_MASK', ''),
'SQM_FOV_DIV' : str(self.indi_allsky_config.get('SQM_FOV_DIV', 4)), # string in form, int in config
'IMAGE_STACK_METHOD' : self.indi_allsky_config.get('IMAGE_STACK_METHOD', 'maximum'),
'IMAGE_STACK_COUNT' : str(self.indi_allsky_config.get('IMAGE_STACK_COUNT', 1)), # string in form, int in config
'IMAGE_STACK_ALIGN' : self.indi_allsky_config.get('IMAGE_STACK_ALIGN', False),
'IMAGE_ALIGN_DETECTSIGMA' : self.indi_allsky_config.get('IMAGE_ALIGN_DETECTSIGMA', 5),
'IMAGE_ALIGN_POINTS' : self.indi_allsky_config.get('IMAGE_ALIGN_POINTS', 50),
'IMAGE_ALIGN_SOURCEMINAREA' : self.indi_allsky_config.get('IMAGE_ALIGN_SOURCEMINAREA', 10),
}

# SQM_ROI
Expand Down Expand Up @@ -3645,6 +3651,13 @@ def dispatch_request(self):
p_config['IMAGE_FLIP_H'] = bool(request.json['IMAGE_FLIP_H'])
p_config['DETECT_MASK'] = str(request.json['DETECT_MASK'])
p_config['SQM_FOV_DIV'] = int(request.json['SQM_FOV_DIV'])
p_config['IMAGE_STACK_METHOD'] = str(request.json['IMAGE_STACK_METHOD'])
p_config['IMAGE_STACK_COUNT'] = int(request.json['IMAGE_STACK_COUNT'])
p_config['IMAGE_STACK_ALIGN'] = bool(request.json['IMAGE_STACK_ALIGN'])
p_config['IMAGE_ALIGN_DETECTSIGMA'] = int(request.json['IMAGE_ALIGN_DETECTSIGMA'])
p_config['IMAGE_ALIGN_POINTS'] = int(request.json['IMAGE_ALIGN_POINTS'])
p_config['IMAGE_ALIGN_SOURCEMINAREA'] = int(request.json['IMAGE_ALIGN_SOURCEMINAREA'])
p_config['IMAGE_STACK_SPLIT'] = False


# SQM_ROI
Expand Down Expand Up @@ -3715,7 +3728,20 @@ def dispatch_request(self):
image_processor.colorize()

else:
image_processor.add(filename_p, 0.0, datetime.now(), 0.0, fits_entry.camera)
if p_config['IMAGE_STACK_COUNT'] > 1:
image_processor.add(filename_p, 0.0, datetime.now(), 0.0, fits_entry.camera)

fits_image_query = IndiAllSkyDbFitsImageTable.query\
.join(IndiAllSkyDbFitsImageTable.camera)\
.filter(IndiAllSkyDbCameraTable.id == camera_id)\
.filter(IndiAllSkyDbFitsImageTable.createDate < fits_entry.createDate)\
.order_by(IndiAllSkyDbFitsImageTable.createDate.desc())\
.limit(p_config['IMAGE_STACK_COUNT'] - 1)

for f_image in fits_image_query:
image_processor.add(f_image.filename, 0.0, datetime.now(), 0.0, f_image.camera)
else:
image_processor.add(filename_p, 0.0, datetime.now(), 0.0, fits_entry.camera)

image_processor.stack() # this just populates self.image

Expand Down

0 comments on commit 0fb81cc

Please sign in to comment.