Author Topic: Do error checking earlier in PhotometricColorCalibration process?  (Read 2651 times)

Offline johnpane

  • PixInsight Enthusiast
  • **
  • Posts: 93
Countless times I have run PCC to near the end and then get this error due to my own oversight:

Code: [Select]
*** Error: Empty background reference ROI defined
I have to fix this, then run through the very time consuming process again.

Would it be possible to do this check at the beginning?

Thanks,
John
« Last Edit: 2019 August 25 11:06:29 by johnpane »

Offline johnpane

  • PixInsight Enthusiast
  • **
  • Posts: 93
This may be as simple as inserting the following around line 496:

Code: [Select]
        if ( p_applyCalibration && p_neutralizeBackground && p_backgroundUseROI)
        {
        p_backgroundROI.Order();
        if ( !p_backgroundROI.IsRect() )
            throw Error( "Empty background reference ROI defined" );
}

and deleting lines 994-999.

Offline Juan Conejero

  • PTeam Member
  • PixInsight Jedi Grand Master
  • ********
  • Posts: 7111
    • http://pixinsight.com/
Agreed. Thank you for detecting and reporting this problem. I have already fixed it in the PCC version that will be released with the upcoming version 1.8.7 of PixInsight.

The best solution is checking for ROI validity in the CanExecuteOn member function:

Code: [Select]
bool PhotometricColorCalibrationInstance::CanExecuteOn( const View& view, pcl::String& whyNot ) const
{
   if ( view.IsPreview() )
   {
      whyNot = "PhotometricColorCalibration cannot be executed on previews.";
      return false;
   }
   if ( !view.IsColor() )
   {
      whyNot = "PhotometricColorCalibration can only be executed on color images.";
      return false;
   }
   if ( view.Image().IsComplexSample() )
   {
      whyNot = "PhotometricColorCalibration cannot be executed on complex images.";
      return false;
   }
   if ( p_neutralizeBackground )
      if ( p_backgroundUseROI )
         if ( !p_backgroundROI.IsRect() )
         {
            whyNot = "Empty background reference ROI defined.";
            return false;
         }
   
   return true;
}

Other checks that don't depend exclusively on instance parameters, such as verifying that the background reference view exists and is a color image, must be done at the point where the background neutralization task is performed (because of the multitasking nature of PixInsight).
Juan Conejero
PixInsight Development Team
http://pixinsight.com/

Offline johnpane

  • PixInsight Enthusiast
  • **
  • Posts: 93
Excellent! Thanks so much, Juan!