原始 MediaWiki 页面

我知道编辑这个网站吗?

细分评估指标 - 脚本

自迁移出 MediaWiki 以来,本页内容尚未经过审查。如果您愿意帮忙,请查看帮助指南

以下Beanshell script允许您评估segmentation方法的性能。

将其复制/粘贴到Script Editor中或将其保存到.bsh文件中并运行它(FileOpen):

/**
 * Script to calculate the segmentation error between some 2D 
 * original labels and their corresponding proposed labels. 
 * 
 * The evaluation metrics are:
 *  - Pixel error: 1 - maximal F-score of pixel similarity
 *  - Minimum Splits & Mergers Warping error
 *  - Foreground-restricted Rand error: 1 - maximal F-score of 
 *    foreground-restricted Rand index
 * 
 * @author Ignacio Arganda-Carreras (iarganda@mit.edu)
 * @version January 22, 2015
 */
 
import trainableSegmentation.metrics.*;
import ij.WindowManager;
import ij.gui.GenericDialog;
import ij.IJ;

 
// Get the list of images that are open
ids = WindowManager.getIDList();
 
if ( ids == null || ids.length < 2 )
{
    IJ.showMessage( "You should have at least two images open." );
    return;
}
 
// Get all the titles of the open images        
titles = new String[ ids.length ];
for ( int i = 0; i < ids.length; ++i )
{
    titles[ i ] = ( WindowManager.getImage( ids[ i ] ) ).getTitle();
}
 
// Create dialog        
gd = new GenericDialog( "Evaluate segmentation results" );
         
gd.addMessage( "Image Selection:" );
current = WindowManager.getCurrentImage().getTitle();
gd.addChoice( "Original_labels", titles, current );
gd.addChoice( "Proposal", titles, current.equals( titles[ 0 ] ) ? titles[ 1 ] : titles[ 0 ] );
         
gd.addMessage( "Segmentation error metrics:" );
gd.addCheckbox( "Maximal F-score pixel_error", true );
gd.addCheckbox( "Minimum split-mergers ratio", true );
gd.addCheckbox( "Maximal F-Score foreground-restricted Rand index", true );

gd.showDialog();
         
if (gd.wasCanceled()) 
    return;
         
originalLabels = WindowManager.getImage( ids[ gd.getNextChoiceIndex() ] );
proposedLabels = WindowManager.getImage( ids[ gd.getNextChoiceIndex() ] );
 
calculatePixelError = gd.getNextBoolean();
calculateWarpingError = gd.getNextBoolean();
calculateRandError = gd.getNextBoolean();
         
 
IJ.log("---");
IJ.log("Evaluating segmentation...");
IJ.log("  Original labels: " + originalLabels.getTitle());
IJ.log("  Proposed labels: " + proposedLabels.getTitle() + "\n");

 
// Calculate segmentation error with the selected metrics
 
if( calculatePixelError )
{
    IJ.log("\nCalculating pixel error...");
    metric = new PixelError( originalLabels, proposedLabels );
    maxFScore = metric.getPixelErrorMaximalFScore( 0.0, 1.0, 0.1 ); 
    IJ.log("  Minimum pixel error: " + (1.0 - maxFScore) ); 
}

if( calculateWarpingError )
{
    IJ.log("\nCalculating warping error by minimizing splits and mergers...");
    metric = new WarpingError( originalLabels, proposedLabels );    
    warpingError = metric.getMinimumSplitsAndMergersErrorValue( 0.0, 0.9, 0.1, false, 20 );
    IJ.log("  Minimum warping error: " + warpingError);
    IJ.log("  # errors (splits + mergers pixels) = " + Math.round(warpingError * originalLabels.getWidth() * originalLabels.getHeight() * originalLabels.getImageStackSize() ) );
}
 
if( calculateRandError )
{   
    IJ.log("\nCalculating maximal F-score of the foreground-restricted Rand index...");
    metric = new RandError( originalLabels, proposedLabels );
    maxFScore = metric.getForegroundRestrictedRandIndexMaximalFScore( 0.0, 1.0, 0.1 );  
    IJ.log("  Minimum foreground-restricted Rand error: " + (1.0 - maxFScore) );     
}

如果运行它,将弹出以下对话框:

Challenge segmentation metrics script

在这里,您可以在打开的图像中选择哪些是原始标签,哪些是建议的标签,以及您想要应用来评估分割结果的具体指标。

单击“确定”后,将应用指标,结果将显示在“日志”窗口中:

Challenge script log window