Package javax.media.jai

Examples of javax.media.jai.Histogram


            final OperationJAI op = new OperationJAI("Histogram"); //$NON-NLS-1$
            ParameterValueGroup params = op.getParameters();
            params.parameter("Source").setValue(recoloredGridCoverage); //$NON-NLS-1$

            recoloredGridCoverage = (GridCoverage2D) op.doOperation(params, null);
            final Histogram h = (Histogram) recoloredGridCoverage.getProperty("histogram"); //$NON-NLS-1$

            Display.getDefault().asyncExec(new Runnable(){
                public void run() {
                    rgbViewer.updateHistograms(h.getBins());
                }
            });

            return Status.OK_STATUS;
        }
View Full Code Here


            new String[]{"512", Integer.toString((512 - splitOffset) / 2),
                         Integer.toString(
                             512 - splitOffset - (512 - splitOffset) / 2),
                         Integer.toString(splitOffset)}
        };
        Histogram histogram[] = new Histogram[4];
        for (int i = 0; i < 4; i++) {
            InputStream stream = TestUtilities.
                doImageTranscodeTest(expectations,
                                     OutputImageRules.GRAYSCALEPNG8, "lena.tiff",
                                     new String[][]{
                                         {"v.width", params[1][i]},
                                         {"v.p", getProtectedArea(
                                             Integer.parseInt(params[1][i]),
                                             params[0][i])}},
                                     true);
            RenderedOp image = JAI.create("ImageRead", ImageIO.createImageInputStream(stream));
            // Create the parameter block.
            PlanarImage dst = null;
            ParameterBlock pb = new ParameterBlock();
            pb.addSource(image);               // Specify the source image
            pb.add(null);                      // No ROI
            pb.add(1);                         // Sampling
            pb.add(1);                         // periods
            // Perform the histogram operation.
            dst = JAI.create("histogram", pb, null);
           
            // Retrieve the histogram data.
            Histogram hist = (Histogram) dst.getProperty("histogram");
            histogram[i] = hist;
        }
        for (int i = 0; i < 256; i++) {
            assertEquals(histogram[0].getBinSize(0, i),
                         histogram[1].getBinSize(0, i) +
View Full Code Here

        if (numBins <= 0) {
            return;
        }

        Histogram histogram = _imageHistogram.getHistogram(_rescaledSourceImage, numBins, _minValue, _maxValue, _roi, _xPeriod, _yPeriod);

        // find out how many pixel we actually counted (may be significant numbers of blanks)
        int npixels = 0;
        int[] bins = histogram.getBins(0);
        double binWidth = (_maxValue - _minValue) / numBins;
        for (int i = 0; i < numBins; i++) {
            npixels += bins[i];
        }
View Full Code Here

        }
        colorCurveSelectionCombo.setSelectedIndex( chan );
        int[] histData = null;
        if ( previewImage != null ) {
            if ( channelHistType[chan] != null ) {
                Histogram h = previewImage.getHistogram( channelHistType[chan] );
                if ( h != null ) {
                    if ( channelHistBand[chan] == -1 ) {
                    /*
                     TODO: All histogram bands should be shown. Currently
                     this is not supported by ColorCurvePanel. If the image is
                     black and white, show jus thte value.
                     */
                        if ( h.getNumBands() < 3 ) {
                            histData = h.getBins( 0 );
                        }
                    } else if ( channelHistBand[chan] < h.getNumBands() ) {
                        histData = h.getBins( channelHistBand[chan] );
                    }
                }
            }
        }
        colorCurvePanel1.setHistogram( histData, Color.BLACK );
View Full Code Here

        RenderedOp histOp =
                HistogramDescriptor.create( rawImage, null,
                Integer.valueOf( 1 ), Integer.valueOf( 1 ),
                numBins, lowVal, highVal, null );
       
        Histogram hist = (Histogram) histOp.getProperty( "histogram" );
        histBins = hist.getBins();       
    }
View Full Code Here

        double highVal[] = {65535.};
        RenderedOp histOp = HistogramDescriptor.create( lumImg, null,
                Integer.valueOf( 1 ), Integer.valueOf( 1 ),
                numBins, lowVal, highVal, null );
       
        Histogram hist = (Histogram) histOp.getProperty( "histogram" );
        int[][] histBins = hist.getBins();
       
        double logSum = 0.0;
        int pixelCount = 0;
        for ( int n = 0; n < histBins[0].length; n++ ) {
            double l = Math.log1p( n );
View Full Code Here

     @return The histogram from last rendering. TODO: Currently returns
     <code>null</code> if no rendering has been made.
     */
   
    public Histogram getHistogram( String histType ) {
        Histogram ret = null;
        RenderedImage src = null;
        if ( histType.equals( HISTOGRAM_RGB_CHANNELS ) ) {
            // Calculate histogram from the image into which color correction was applied
            src = findNamedRendering( lastRendering, "cropped_image" );
        } else if ( histType.equals( HISTOGRAM_IHS_CHANNELS ) ) {
View Full Code Here

            yValues[i] = 0;
        }
        if (factor >= 0.0) {
            Rectangle2D.Double region = imageDisplay.getVisibleArea();
            ROI roi = new ROIShape(region);
            Histogram histogram = imageProcessor.getHistogram(numValues, roi);
            yValues = histogram.getBins(0);
            chart.getXYPlot().setDataset(new SimpleDataset(xValues, yValues));
        }
    }
View Full Code Here

        return names;
    }

    protected Object createStatistics(String name) {
        if (name.equalsIgnoreCase("histogram")) {
            return new Histogram(numBins, lowValueFP, highValueFP);
        } else {
            return java.awt.Image.UndefinedProperty;
        }
    }
View Full Code Here

    protected void accumulateStatistics(String name,
                                        Raster source,
                                        Object stats) {
        // Get the JAI histogram.
        Histogram histogram = (Histogram)stats;
        int numBands = histogram.getNumBands();
        int[][] histJAI = histogram.getBins();

        // Get the tile bounds.
        Rectangle tileRect = source.getBounds();

        // Get the tile bins.
        int[][] histo;
        if(!reorderBands && tileRect.equals(getBounds())) {
            // Entire image: use the global histogram bins directly.
            histo = histJAI;
        } else {
            // Sub-image: save results for this tile only.
            histo = new int[numBands][];
            for(int i = 0; i < numBands; i++) {
                histo[i] = new int[histogram.getNumBins(i)];
            }
        }

        // Get the mlib image.
        int formatTag = MediaLibAccessor.findCompatibleTag(null, source);
View Full Code Here

TOP

Related Classes of javax.media.jai.Histogram

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.