public ConfigThreshold createConfig() { ConfigThreshold config; if( type == ThresholdType.BLOCK_MIN_MAX) { ConfigThresholdBlockMinMax _config = new ConfigThresholdBlockMinMax(); _config.minimumSpread = minimumSpread; config = _config; } else if( type == ThresholdType.BLOCK_OTSU || type == ThresholdType.LOCAL_OTSU ) { ConfigThresholdLocalOtsu _config = new ConfigThresholdLocalOtsu(); _config.tuning = otsuTuning; _config.useOtsu2 = useOtsu2; config = _config; } else { config = new ConfigThreshold(); config.fixedThreshold = fixedThreshold; } config.type = type; config.scale = scale; config.down = down; config.width = regionWidth.copy(); config.savolaK = savolaK; config.nickK = nickK; config.minPixelValue = minPixelValue; config.maxPixelValue = maxPixelValue; config.thresholdFromLocalBlocks = thresholdLocalBlocks; return config; } }
public void setConfiguration(ConfigThreshold configuration) { comboType.removeActionListener(this); spinnerScale.removeChangeListener(this); buttonUpDown.removeActionListener(this); checkOtsu2.removeActionListener(this); comboType.setSelectedIndex(configuration.type.ordinal()); controlWidth.setValue(configuration.width); spinnerScale.setValue(configuration.scale); buttonUpDown.setSelected(configuration.down); type = configuration.type; regionWidth = configuration.width.copy(); scale = configuration.scale; down = configuration.down; if( type == ThresholdType.FIXED ) { fixedThreshold = (int)configuration.fixedThreshold; } else if( type == ThresholdType.BLOCK_MIN_MAX) { minimumSpread = ((ConfigThresholdBlockMinMax)configuration).minimumSpread; } else if( type == ThresholdType.BLOCK_OTSU || type == ThresholdType.LOCAL_OTSU ) { otsuTuning = (int)((ConfigThresholdLocalOtsu)configuration).tuning; useOtsu2 = ((ConfigThresholdLocalOtsu)configuration).useOtsu2; } comboType.addActionListener(this); spinnerScale.addChangeListener(this); buttonUpDown.addActionListener(this); checkOtsu2.addActionListener(this); updateThresholdValue(); }
this.scale = configThreshold.scale; this.down = configThreshold.down; this.regionWidth = configThreshold.width.copy(); this.savolaK = configThreshold.savolaK; this.nickK = configThreshold.nickK;