Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

add option to disable image processing #971

Merged
merged 2 commits into from
Oct 3, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion indi_allsky/flask/forms.py
Original file line number Diff line number Diff line change
Expand Up @@ -3387,7 +3387,7 @@ def __init__(self, *args, **kwargs):


class IndiAllskyImageProcessingForm(FlaskForm):
DISABLE_PROCESSING = HiddenField('Disable processing', validators=[], default='1') # disabled by default
DISABLE_PROCESSING = BooleanField('Disable processing')
CAMERA_ID = HiddenField('Camera ID', validators=[DataRequired()])
FITS_ID = HiddenField('FITS ID', validators=[DataRequired()])
NIGHT_CONTRAST_ENHANCE = BooleanField('Contrast Enhance')
Expand Down Expand Up @@ -3422,4 +3422,5 @@ class IndiAllskyImageProcessingForm(FlaskForm):
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')
PROCESSING_SPLIT_SCREEN = BooleanField('Split screen')

44 changes: 34 additions & 10 deletions indi_allsky/flask/templates/imageprocessing.html
Original file line number Diff line number Diff line change
Expand Up @@ -48,13 +48,6 @@

<form id="form_image_processing" onSubmit="return false;">

<div class="form-group row">
<div class="col-sm-3">
{{ form_image_processing.DISABLE_PROCESSING(class='form-control bg-secondary') }}
<div id="DISABLE_PROCESSING-error" class="invalid-feedback text-danger" style="display: none;"></div>
</div>
</div>

<div class="form-group row">
<div class="col-sm-3">
{{ form_image_processing.CAMERA_ID(class='form-control bg-secondary') }}
Expand All @@ -78,6 +71,16 @@
<div class="col-sm-1">
<div class="loader" id="loader_processing"></div>
</div>

<div class="col-sm-1">
<div class="form-switch">
{{ form_image_processing.DISABLE_PROCESSING(class='form-check-input') }}
<div id="NIGHT_CONTRAST_ENHANCE-error" class="invalid-feedback text-danger" style="display: none;"></div>
</div>
</div>
<div class="col-sm-2">
{{ form_image_processing.DISABLE_PROCESSING.label }}
</div>
</div>

<div class="form-group row">
Expand All @@ -89,6 +92,23 @@

<hr>

<!--
<div class="form-group row">
<div class="col-sm-2">
{{ form_image_processing.PROCESSING_SPLIT_SCREEN.label }}
</div>
<div class="col-sm-2">
<div class="form-switch">
{{ form_image_processing.PROCESSING_SPLIT_SCREEN(class='form-check-input') }}
<div id="PROCESSING_SPLIT_SCREEN-error" class="invalid-feedback text-danger" style="display: none;"></div>
</div>
</div>
<div class="col-sm-8"></div>
</div>

<hr>
-->

<div class="form-group row">
<div class="col-sm-2">
{{ form_image_processing.DETECT_MASK.label(class='col-form-label') }}
Expand Down Expand Up @@ -557,7 +577,6 @@ <h5>These options are applied to the unprocessed image automatically</h5>
const failureMessage = $('#failure-message');
const field_names = [
'csrf_token',
'DISABLE_PROCESSING',
'CAMERA_ID',
'FITS_ID',
'CLAHE_CLIPLIMIT',
Expand Down Expand Up @@ -588,11 +607,13 @@ <h5>These options are applied to the unprocessed image automatically</h5>
];

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

var fields = {};
Expand Down Expand Up @@ -674,16 +695,19 @@ <h5>These options are applied to the unprocessed image automatically</h5>


$('#form_image_processing').on('submit', function() {
$("#DISABLE_PROCESSING").val(''); // enable processing
submitProcessingData();
$('#processing_time').text('Processed in ' + json_data['processing_elapsed_s'] + 's');
});


function init() {
$("#DISABLE_PROCESSING").val('1'); // disable processing to get original image
// disable processing for initial image
$('#DISABLE_PROCESSING').prop('checked', true);

submitProcessingData();
$('#processing_time').text('Unprocessed image');

$('#DISABLE_PROCESSING').prop('checked', false);
}


Expand Down
2 changes: 2 additions & 0 deletions indi_allsky/flask/views.py
Original file line number Diff line number Diff line change
Expand Up @@ -3554,6 +3554,7 @@ def get_context(self):
'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),
'PROCESSING_SPLIT_SCREEN' : False,
}

# SQM_ROI
Expand Down Expand Up @@ -3658,6 +3659,7 @@ def dispatch_request(self):
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
p_config['PROCESSING_SPLIT_SCREEN'] = bool(request.json.get('PROCESSING_SPLIT_SCREEN', False))


# SQM_ROI
Expand Down
10 changes: 5 additions & 5 deletions indi_allsky/processing.py
Original file line number Diff line number Diff line change
Expand Up @@ -881,7 +881,7 @@ def stack(self):


if self.config.get('IMAGE_STACK_SPLIT'):
self.image = self._splitscreen(i_ref['hdulist'][0].data, self.image)
self.image = self.splitscreen(i_ref['hdulist'][0].data, self.image)


stack_elapsed_s = time.time() - stack_start
Expand Down Expand Up @@ -1466,14 +1466,14 @@ def scale_image(self):
self.image = cv2.resize(self.image, (new_width, new_height), interpolation=cv2.INTER_AREA)


def _splitscreen(self, original_data, stacked_data):
def splitscreen(self, original_data, new_data):
# if flip horizontal is set, this data will swap sides later
if self.config.get('IMAGE_FLIP_H'):
left_data = stacked_data
left_data = new_data
right_data = original_data
else:
left_data = original_data
right_data = stacked_data
right_data = new_data


image_height, image_width = left_data.shape[:2]
Expand Down Expand Up @@ -2362,7 +2362,7 @@ def stretch(self):


if is_stretched and self.config.get('IMAGE_STRETCH', {}).get('SPLIT'):
self.image = self._splitscreen(self.image, stretched_image)
self.image = self.splitscreen(self.image, stretched_image)
return


Expand Down
4 changes: 2 additions & 2 deletions testing/align_rolling.py
Original file line number Diff line number Diff line change
Expand Up @@ -169,7 +169,7 @@ def main(self, inputfiles):


if self.split_screen:
stacked_img = self._splitscreen(reference_hdulist[0].data, stacked_img)
stacked_img = self.splitscreen(reference_hdulist[0].data, stacked_img)


stacked_bitdepth = self._detectBitDepth(stacked_img)
Expand Down Expand Up @@ -260,7 +260,7 @@ def _crop(self, image):
]


def _splitscreen(self, left_data, right_data):
def splitscreen(self, left_data, right_data):
image_height, image_width = left_data.shape[:2]


Expand Down
Loading