void RescaleIntensityFilterDialog::on_pushButtonApply_clicked()
{
    ImageLayer *imageLayer = ImageLayer::instance();
    int minimum = ui->spinBoxMinimum->value();
    int maximum = ui->spinBoxMaximum->value();

    rescaleFilter->SetInput(imageLayer->grayImagePointer(0));
    rescaleFilter->SetOutputMinimum(minimum);
    rescaleFilter->SetOutputMaximum(maximum);
    rescaleFilter->Update();

    imageLayer->resizeImageVector(2);
    imageLayer->setGrayImage(1, rescaleFilter->GetOutput());
}
void SigmoidFilterDialog::on_pushButtonApply_clicked()
{
    ImageLayer *imageLayer = ImageLayer::instance();
    int outputMinimum = ui->spinBoxMinimum->value();
    int outputMaximum = ui->spinBoxMaximum->value();
    double alpha = ui->spinBoxAlpha->value();
    double beta = ui->spinBoxBeta->value();

    sigmoidFilter->SetInput(imageLayer->grayImagePointer(0));
    sigmoidFilter->SetOutputMinimum(outputMinimum);
    sigmoidFilter->SetOutputMaximum(outputMaximum);
    sigmoidFilter->SetAlpha(alpha);
    sigmoidFilter->SetBeta(beta);
    sigmoidFilter->Update();

    imageLayer->resizeImageVector(2);
    imageLayer->setGrayImage(1, sigmoidFilter->GetOutput());
}
void BinaryThresholdFilterDialog::on_pushButtonApply_clicked()
{
    ImageLayer *imageLayer = ImageLayer::instance();
    int insideValue = ui->spinBoxInsideValue->value();
    int outsideValue = ui->spinBoxOutsideValue->value();
    int lowerThreshold = ui->spinBoxLowerThreshold->value();
    int upperThreshold = ui->spinBoxUpperThreshold->value();
    imageLayer->resizeImageVector(2);

    typedef itk::BinaryThresholdImageFilter<ImageLayer::GrayImageType, ImageLayer::GrayImageType> BinaryThresholdFilterType;

    BinaryThresholdFilterType::Pointer binaryThresholdFilter = BinaryThresholdFilterType::New();
    binaryThresholdFilter->SetInsideValue(insideValue);
    binaryThresholdFilter->SetOutsideValue(outsideValue);
    binaryThresholdFilter->SetLowerThreshold(lowerThreshold);
    binaryThresholdFilter->SetUpperThreshold(upperThreshold);
    binaryThresholdFilter->SetInput(imageLayer->grayImagePointer(0));
    binaryThresholdFilter->Update();

    imageLayer->setGrayImage(1, binaryThresholdFilter->GetOutput());
}
void ThresholdFilterDialog::on_pushButtonApply_clicked()
{
    ImageLayer *imageLayer = ImageLayer::instance();
    int outsideValue = ui->spinBoxOutsideValue->value();
    int threshold = ui->spinBoxThreshold->value();
    int lowerThreshold = ui->spinBoxLowerThreshold->value();
    int upperThreshold = ui->spinBoxUpperThreshold->value();
    thresholdFilter->SetInput(imageLayer->grayImagePointer(0));

    if (ui->radioButtonThresholdBelow->isChecked()) {
        thresholdFilter->SetOutsideValue(outsideValue);
        thresholdFilter->ThresholdBelow(threshold);
    } else if (ui->radioButtonThresholdAbove->isChecked()){
        thresholdFilter->SetOutsideValue(outsideValue);
        thresholdFilter->ThresholdAbove(threshold);
    } else {
        thresholdFilter->SetOutsideValue(outsideValue);
        thresholdFilter->ThresholdOutside(lowerThreshold, upperThreshold);
    }
    thresholdFilter->Update();
    imageLayer->resizeImageVector(2);
    imageLayer->setGrayImage(1, thresholdFilter->GetOutput());
}