当前位置: 首页>>代码示例>>Java>>正文


Java ByteProcessor.setColorModel方法代码示例

本文整理汇总了Java中ij.process.ByteProcessor.setColorModel方法的典型用法代码示例。如果您正苦于以下问题:Java ByteProcessor.setColorModel方法的具体用法?Java ByteProcessor.setColorModel怎么用?Java ByteProcessor.setColorModel使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在ij.process.ByteProcessor的用法示例。


在下文中一共展示了ByteProcessor.setColorModel方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: call

import ij.process.ByteProcessor; //导入方法依赖的package包/类
@Override
public ByteProcessor call() throws Exception {
    // Setup SRG
    final SRG srg = new SRG();
    srg.setImage(image);
    srg.setSeeds(seeds);
    // Forward progress notification
    srg.addProgressListener(new ProgressListener() {
        @Override
        public void progressNotification(final ProgressEvent e) {
            notifyProgressListeners(e.getProgress(), e.getMessage());
        }
    });

    // Run segmentation
    srg.run();
    final ByteProcessor r = srg.getRegionMarkers();
    r.setColorModel(seeds.getCurrentColorModel());
    return r;
}
 
开发者ID:ij-plugins,项目名称:ijp-toolkit,代码行数:21,代码来源:RegionGrowingPlugIn.java

示例2: run

import ij.process.ByteProcessor; //导入方法依赖的package包/类
private static void run(final ImageProcessor image, final ByteProcessor seeds, final String prefix) {
    final SRG srg = new SRG();
    srg.setImage(image);
    srg.setSeeds(seeds);

    // Forward progress notification
    srg.addProgressListener(new IJProgressBarAdapter());

    // Run segmentation
    srg.run();

    final ByteProcessor r = srg.getRegionMarkers();
    r.setColorModel(seeds.getColorModel());
    new ImagePlus(prefix + "-SRG", r).show();
}
 
开发者ID:ij-plugins,项目名称:ijp-toolkit,代码行数:16,代码来源:RegionGrowingPlugIn.java

示例3: run

import ij.process.ByteProcessor; //导入方法依赖的package包/类
@Override
public void run(String arg) {
    if ("about".equalsIgnoreCase(arg)) {
        IJ.showMessage("About " + TITLE, ABOUT);
        return;
    }

    final Pair<List<ResultsTable>, List<String>> resultTables = listTextWindows();
    if (resultTables.getFirst().size() < 1) {
        IJ.error("Expecting at least one open Result Table window.");
        return;
    }

    final Pair<List<ImagePlus>, List<String>> images = listSupportedImages();
    if (images.getFirst().size() < 1) {
        IJ.error("Expecting at least one open image (that is not indexed color).");
        return;
    }

    // Ask user for image, results table, and other options
    if (!showOptionsDialog(resultTables.getSecond(), images.getSecond())) {
        return;
    }

    if (CONFIG.interpretStackAs3D) {
        IJ.error(TITLE, "Interpreting stacks as 3D images not yet supported.");
        return;
    }

    final ResultsTable rt = resultTables.getFirst().get(CONFIG.tableIndex);
    final ImagePlus imp = images.getFirst().get(CONFIG.imageIndex);

    //
    // Verify that table headings match image bands
    //
    final ImagePlus stack = KMeansClusteringPlugin.convertToFloatStack(imp);

    final int stackSize = stack.getStackSize();
    final String[] bandLabels = stack.getStack().getSliceLabels();
    final String[] expectedHeadings = new String[stackSize + 1];
    expectedHeadings[0] = "Cluster";
    System.arraycopy(bandLabels, 0, expectedHeadings, 1, stackSize);
    final String[] tableHeadings = rt.getHeadings();
    if (tableHeadings.length < expectedHeadings.length) {
        IJ.error(TITLE, "Not enough headings, expecting: " + Arrays.toString(expectedHeadings));
        return;
    }
    for (int i = 0; i < expectedHeadings.length; i++) {
        if (!expectedHeadings[i].equals(tableHeadings[i])) {
            IJ.error(TITLE, "Expecting heading " + (i + 1) + " to be " + expectedHeadings[i] + ", but got: " + tableHeadings[i] + ".");
            return;
        }
    }

    // Read cluster centers from the table
    final int nbClusters = rt.getCounter();
    final float[][] clusterCenters = new float[nbClusters][expectedHeadings.length - 1];
    for (int clusterIndex = 0; clusterIndex < nbClusters; clusterIndex++) {
        for (int bandIndex = 1; bandIndex < expectedHeadings.length; bandIndex++)
            clusterCenters[clusterIndex][bandIndex - 1] = (float) rt.getValueAsDouble(bandIndex, clusterIndex);
    }

    // Apply clustering to input image
    final VectorProcessor vp = new VectorProcessor(stack);
    final ByteProcessor bp = KMeans2D.encodeSegmentedImage(vp, clusterCenters);
    // Apply default color map
    if (KMeansClusteringPlugin.APPLY_LUT) {
        bp.setColorModel(KMeansClusteringPlugin.defaultColorModel());
    }
    if (KMeansClusteringPlugin.AUTO_BRIGHTNESS) {
        bp.setMinAndMax(0, nbClusters);
    }
    new ImagePlus("Clusters", bp).show();

    // Apply clustering
    if (CONFIG.showCentroidImage) {
        final ImageStack clustered = KMeansUtils.encodeCentroidValueImage(clusterCenters, new VectorProcessor(stack));
        final ImagePlus cvImp = KMeansUtils.createCentroidImage(imp.getType(), clustered);
        cvImp.show();
    }
}
 
开发者ID:ij-plugins,项目名称:ijp-toolkit,代码行数:82,代码来源:KMeansClusteringReapplyPlugin.java

示例4: run

import ij.process.ByteProcessor; //导入方法依赖的package包/类
private void run(final ImagePlus imp) {
        // Convert to a stack of float images
        final ImagePlus stack = convertToFloatStack(imp);

        // Run clustering
        final KMeans2D kMeans = new KMeans2D(CONFIG);
//        Roi roi =  imp.getRoi();
//        ByteProcessor mask = (ByteProcessor) imp.getMask();
//        kMeans.setRoi(roi.getBoundingRect());
//        kMeans.setMask(mask);
        final long startTime = System.currentTimeMillis();
        final ByteProcessor bp = kMeans.run(stack.getStack());
        final long endTime = System.currentTimeMillis();

        // Apply default color map
        if (APPLY_LUT) {
            bp.setColorModel(defaultColorModel());
        }
        if (AUTO_BRIGHTNESS) {
            bp.setMinAndMax(0, CONFIG.getNumberOfClusters());
        }

        // Show result image
        final ImagePlus r = new ImagePlus("Clusters", bp);
        r.show();

        // Show animation
        if (CONFIG.isClusterAnimationEnabled()) {
            final ImageStack animationStack = kMeans.getClusterAnimation();
            if (APPLY_LUT) {
                animationStack.setColorModel(defaultColorModel());
            }
            final ImagePlus animation = new ImagePlus("Cluster animation", animationStack);
            animation.show();
            if (AUTO_BRIGHTNESS) {
                for (int i = 0; i < animationStack.getSize(); i++) {
                    animation.setSlice(i + 1);
                    animation.getProcessor().setMinAndMax(0, CONFIG.getNumberOfClusters());
                }
                animation.setSlice(1);
                animation.updateAndDraw();
            }
        }

        // Show centroid image
        if (showCentroidImage) {
            final ImagePlus cvImp = KMeansUtils.createCentroidImage(imp.getType(),
                    kMeans.getCentroidValueImage());
            cvImp.show();
        }

        if (sendToResultTable) {
            sendToResultTable(kMeans.getClusterCenters(), stack.getStack().getSliceLabels());
        }

        IJ.showStatus("Clustering completed in " + (endTime - startTime) + " ms.");
    }
 
开发者ID:ij-plugins,项目名称:ijp-toolkit,代码行数:58,代码来源:KMeansClusteringPlugin.java


注:本文中的ij.process.ByteProcessor.setColorModel方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。