Computes the histogram inside the specified region.  Results are returned by calling {@link #getHistogram()}.

@param image Input image
@param region Region which is to be sampled
9638
public void computeHistogram( T image , RectangleRotate_F32 region ) {

		interpolate.setImage(image);

		c = (float)Math.cos( region.theta );
		s = (float)Math.sin( region.theta );

		for( int i = 0; i < histogram.length; i++ ) {
			histogram[i] = 0;
		}

		// if it is entirely inside the image, interpolate using a faster technique
		if( isInFastBounds(region) ) {
			computeHistogramInside( region);
		} else {
			computeHistogramBorder(image, region);
		}

		normalizeHistogram();
	}
1152214
public static void localHistogram( GrayU16 input , int x0 , int y0 , int x1, int y1 , int histogram[] ) {
		for( int i = 0; i < histogram.length; i++ )
			histogram[i] = 0;

		for( int i = y0; i < y1; i++ ) {
			int index = input.startIndex + i*input.stride + x0;
			int end = index + x1-x0;
			for( ; index < end; index++ ) {
				histogram[input.data[index] & 0xFFFF]++;
			}
		}
	}
879975
public void setImage(T image) {
		blur.reshape(image.width,image.height);
		filterBlur.process(image,blur);
		describe.setImage(image);
	}
880941
public void setImage(final Image image) {
		LinkModel model = getOrCreateComponentModel();
		model.image = image;
		model.imageUrl = null;
	}
783042
private void createCascadeRegion( int imageWidth , int imageHeight ) {

		cascadeRegions.reset();

		int rectWidth = (int)(targetRegion.getWidth()+0.5);
		int rectHeight = (int)(targetRegion.getHeight()+0.5);

		for( int scaleInt = -config.scaleSpread; scaleInt <= config.scaleSpread; scaleInt++ ) {
			// try several scales as specified in the paper
			double scale = Math.pow(1.2,scaleInt);

			// the actual rectangular region being tested at this scale
			int actualWidth = (int)(rectWidth*scale);
			int actualHeight = (int)(rectHeight*scale);

			// see if the region is too small or too large
			if( actualWidth < config.detectMinimumSide || actualHeight < config.detectMinimumSide )
				continue;

			if( actualWidth >= imageWidth || actualHeight >= imageHeight )
				continue;

			// step size at this scale
			int stepWidth = (int)(rectWidth*scale*0.1);
			int stepHeight = (int)(rectHeight*scale*0.1);

			if( stepWidth < 1 ) stepWidth = 1;
			if( stepHeight < 1 ) stepHeight = 1;

			// maximum allowed values
			int maxX = imageWidth-actualWidth;
			int maxY = imageHeight-actualHeight;

			// start at (1,1).  Otherwise a more complex algorithm needs to be used for integral images
			for( int y0 = 1; y0 < maxY; y0 += stepHeight ) {
				for( int x0 = 1; x0 < maxX; x0 += stepWidth) {
					ImageRectangle r = cascadeRegions.grow();

					r.x0 = x0;
					r.y0 = y0;
					r.x1 = x0 + actualWidth;
					r.y1 = y0 + actualHeight;
				}
			}
		}
	}
700962
private void createSections(final BufferedImage IMAGE) {
        if (bImage != null) {
            final double ORIGIN_CORRECTION;
            switch (getOrientation()) {
                case NORTH:
                    ORIGIN_CORRECTION = 135;
                    break;
                case EAST:
                    ORIGIN_CORRECTION = 135;
                    break;
                case SOUTH:
                    ORIGIN_CORRECTION = 135;
                    break;
                case WEST:
                    ORIGIN_CORRECTION = 225;
                    break;
                default:
                    ORIGIN_CORRECTION = 135;
                    break;
            }

            final double ANGLE_STEP;
            if (!isLogScale()) {
                ANGLE_STEP = getModel().getApexAngle() / (getMaxValue() - getMinValue());
            } else {
                ANGLE_STEP = getModel().getApexAngle() / UTIL.logOfBase(BASE, getMaxValue() - getMinValue());
            }

            final double OUTER_RADIUS = bImage.getWidth() * 0.44f;
            final double INNER_RADIUS = isExpandedSectionsEnabled() ? OUTER_RADIUS - bImage.getWidth() * 0.12f : OUTER_RADIUS - bImage.getWidth() * 0.04f;

            final double FREE_AREA_OUTER_RADIUS = bImage.getWidth() / 2.0 - OUTER_RADIUS;
            final double FREE_AREA_INNER_RADIUS = bImage.getWidth() / 2.0 - INNER_RADIUS;
            final Ellipse2D INNER = new Ellipse2D.Double(bImage.getMinX() + FREE_AREA_INNER_RADIUS, bImage.getMinY() + FREE_AREA_INNER_RADIUS, 2 * INNER_RADIUS, 2 * INNER_RADIUS);


            for (Section section : getSections()) {
                final double ANGLE_START;
                final double ANGLE_EXTEND;

                if (!isLogScale()) {
                    ANGLE_START = ORIGIN_CORRECTION - (section.getStart() * ANGLE_STEP) + (getMinValue() * ANGLE_STEP);
                    ANGLE_EXTEND = -(section.getStop() - section.getStart()) * ANGLE_STEP;
                } else {
                    ANGLE_START = ORIGIN_CORRECTION - UTIL.logOfBase(BASE, section.getStart()) * ANGLE_STEP + (UTIL.logOfBase(BASE, getMinValue()) * ANGLE_STEP);
                    ANGLE_EXTEND = -(section.getStop() - section.getStart()) * ANGLE_STEP;
                }

                final java.awt.geom.Arc2D OUTER_ARC = new java.awt.geom.Arc2D.Double(java.awt.geom.Arc2D.PIE);
                OUTER_ARC.setFrame(bImage.getMinX() + FREE_AREA_OUTER_RADIUS, bImage.getMinY() + FREE_AREA_OUTER_RADIUS, 2 * OUTER_RADIUS, 2 * OUTER_RADIUS);
                OUTER_ARC.setAngleStart(ANGLE_START);
                OUTER_ARC.setAngleExtent(ANGLE_EXTEND);
                final java.awt.geom.Area SECTION = new java.awt.geom.Area(OUTER_ARC);

                SECTION.subtract(new java.awt.geom.Area(INNER));

                section.setSectionArea(SECTION);
            }

            // Draw the sections
            if (isSectionsVisible() && IMAGE != null) {
                final Graphics2D G2 = IMAGE.createGraphics();
                G2.setRenderingHint(RenderingHints.KEY_ANTIALIASING, RenderingHints.VALUE_ANTIALIAS_ON);

                switch (getOrientation()) {
                    case EAST:
                        break;
                    case SOUTH:
                        break;
                    case WEST:
                        G2.translate(CENTER.getX() / 2.2, 0);
                        break;
                    case NORTH:

                    default:
                        G2.translate(0, CENTER.getY() / 2.2);
                        break;
                }

                for (Section section : getSections()) {
                    G2.setColor(isTransparentAreasEnabled() ? section.getTransparentColor() : section.getColor());
                    G2.fill(section.getSectionArea());
//                    if (section3DEffectVisible)
//                    {
//                        G2.setPaint(section3DEffect);
//                        G2.fill(section.getSectionArea());
//                    }
                }
                G2.dispose();
            }
        }
    }
912601
public static void regionsColor( GrayS32 pixelToRegion ,
									 FastQueue<float[]> segmentColor ,
									 Bitmap output , byte[] storage ) {
		if( storage == null )
			storage = declareStorage(output,null);

		int indexOut = 0;
		for( int y = 0; y < pixelToRegion.height; y++ ) {
			for( int x = 0; x < pixelToRegion.width; x++ ) {
				int index = pixelToRegion.unsafe_get(x,y);
				float []cv = segmentColor.get(index);

				int r,g,b;

				if( cv.length == 3 ) {
					r = (int)cv[0];
					g = (int)cv[1];
					b = (int)cv[2];
				} else {
					r = g = b = (int)cv[0];
				}

				storage[indexOut++] = (byte)r;
				storage[indexOut++] = (byte)g;
				storage[indexOut++] = (byte)b;
				storage[indexOut++] = (byte)0xFF;
			}
		}

		output.copyPixelsFromBuffer(ByteBuffer.wrap(storage));
	}
204684
public static void printClickedColor( final BufferedImage image ) {
		ImagePanel gui = new ImagePanel(image);
		gui.addMouseListener(new MouseAdapter() {
			@Override
			public void mouseClicked(MouseEvent e) {
				float[] color = new float[3];
				int rgb = image.getRGB(e.getX(),e.getY());
				ColorHsv.rgbToHsv((rgb >> 16) & 0xFF, (rgb >> 8) & 0xFF, rgb & 0xFF, color);
				System.out.println("H = " + color[0]+" S = "+color[1]+" V = "+color[2]);

				showSelectedColor("Selected",image,color[0],color[1]);
			}
		});

		ShowImages.showWindow(gui,"Color Selector");
	}
1027541
private BufferedImage convertImage(BufferedImage image)
    {
        if (image.getType() == BufferedImage.TYPE_INT_RGB)
        {
            return image;
        }
        else
        {
            BufferedImage newImage = new BufferedImage(image.getWidth(),
                                                       image.getHeight(),
                                                       BufferedImage.TYPE_INT_RGB);
            newImage.getGraphics().drawImage(image, 0, 0, null);
            return newImage;
        }
    }
393070
private void initPixelsArray(BufferedImage image) {
        int width = image.getWidth();
        int height = image.getHeight();
        pixels = new int[width * height];
        image.getRGB(0, 0, width, height, pixels, 0, width);

    }
747630
public void process(GrayF32 intensityImage, @Nullable QueueCorner localMin, @Nullable QueueCorner localMax) {

		if( localMin != null )
			localMin.reset();
		if( localMax != null )
			localMax.reset();

		// the defines the region that can be processed
		int endX = intensityImage.width - border;
		int endY = intensityImage.height - border;

		int step = configuration.radius+1;

		search.initialize(configuration,intensityImage,localMin,localMax);

		for(int y = border; y < endY; y += step ) {
			int y1 = y + step;
			if( y1 > endY) y1 = endY;

			for(int x = border; x < endX; x += step ) {
				int x1 = x + step;
				if( x1 > endX) x1 = endX;
				search.searchBlock(x,y,x1,y1);
			}
		}
	}
825635
public static RegionMap getRegionParamsFromImageMosaicReader( ImageMosaicReader reader ) throws IOException {
        RegionMap envelopeParams = new RegionMap();

        Envelope envelope = reader.getOriginalEnvelope();

        DirectPosition lowerCorner = envelope.getLowerCorner();
        double[] westSouth = lowerCorner.getCoordinate();
        DirectPosition upperCorner = envelope.getUpperCorner();
        double[] eastNorth = upperCorner.getCoordinate();

        GridEnvelope2D gridRange = (GridEnvelope2D) reader.getOriginalGridRange();
        int height = gridRange.height;
        int width = gridRange.width;
        double[][] resolutionLevels = reader.getResolutionLevels();
        double xRes = resolutionLevels[0][0];
        double yRes = resolutionLevels[0][1];

        envelopeParams.put(NORTH, eastNorth[1]);
        envelopeParams.put(SOUTH, westSouth[1]);
        envelopeParams.put(WEST, westSouth[0]);
        envelopeParams.put(EAST, eastNorth[0]);
        envelopeParams.put(XRES, xRes);
        envelopeParams.put(YRES, yRes);
        envelopeParams.put(ROWS, (double) height);
        envelopeParams.put(COLS, (double) width);

        return envelopeParams;
    }
386014
private Histogram getHistogram(String entity, String watermarkColumn, SourceState state,
      Partition partition) {
    SalesforceConnector connector = getConnector(state);

    try {
      if (!connector.connect()) {
        throw new RuntimeException("Failed to connect.");
      }
    } catch (RestApiConnectionException e) {
      throw new RuntimeException("Failed to connect.", e);
    }

    Histogram histogram = getHistogramByDayBucketing(connector, entity, watermarkColumn, partition);

    // exchange the first histogram group key with the global low watermark to ensure that the low watermark is captured
    // in the range of generated partitions
    HistogramGroup firstGroup = histogram.get(0);
    Date lwmDate = Utils.toDate(partition.getLowWatermark(), Partitioner.WATERMARKTIMEFORMAT);
    histogram.getGroups().set(0, new HistogramGroup(Utils.epochToDate(lwmDate.getTime(), SECONDS_FORMAT),
        firstGroup.getCount()));

    // refine the histogram
    if (state.getPropAsBoolean(ENABLE_DYNAMIC_PROBING)) {
      histogram = getRefinedHistogram(connector, entity, watermarkColumn, state, partition, histogram);
    }

    return histogram;
  }
23007
public static BufferedImage convertImageToGrayscale(BufferedImage image) {
        BufferedImage tmp = new BufferedImage(image.getWidth(), image.getHeight(), BufferedImage.TYPE_BYTE_GRAY);
        Graphics2D g2 = tmp.createGraphics();
        g2.drawImage(image, 0, 0, null);
        g2.dispose();
        return tmp;
    }
1160002
public static void histogram( GrayS64 input , long minValue , int histogram[] ) {
		if( BoofConcurrency.USE_CONCURRENT ) {
			ImplImageStatistics_MT.histogram(input,minValue,histogram);
		} else {
			ImplImageStatistics.histogram(input,minValue,histogram);
		}
	}
1176951
protected Graphics2D getGraphics(BufferedImage image) {
		Graphics2D graphics = image.createGraphics();
		graphics.setRenderingHint(RenderingHints.KEY_ANTIALIASING,
				RenderingHints.VALUE_ANTIALIAS_ON);
		return graphics;
	}
1332033
public void setImage(T image ) {
		match.setInputImage(image);
		this.imageWidth = image.width;
		this.imageHeight = image.height;
	}