/** * Runs a canny edge detector on the input image given the provided thresholds. If configured to * save a list of trace points then the output image is optional. * * <p>NOTE: Input and output can be the same instance, if the image type allows it. * * @param input Input image. Not modified. * @param threshLow Lower threshold. >= 0. * @param threshHigh Upper threshold. >= 0. * @param output (Might be option) Output binary image. Edge pixels are marked with 1 and * everything else 0. */ public void process(T input, float threshLow, float threshHigh, ImageUInt8 output) { if (threshLow < 0 || threshHigh < 0) throw new IllegalArgumentException("Threshold must be >= zero!"); if (hysteresisMark != null) { if (output == null) throw new IllegalArgumentException( "An output image must be specified when configured to mark edge points"); } // setup internal data structures blurred.reshape(input.width, input.height); derivX.reshape(input.width, input.height); derivY.reshape(input.width, input.height); intensity.reshape(input.width, input.height); suppressed.reshape(input.width, input.height); angle.reshape(input.width, input.height); direction.reshape(input.width, input.height); work.reshape(input.width, input.height); // run canny edge detector blur.process(input, blurred); gradient.process(blurred, derivX, derivY); GGradientToEdgeFeatures.intensityAbs(derivX, derivY, intensity); GGradientToEdgeFeatures.direction(derivX, derivY, angle); GradientToEdgeFeatures.discretizeDirection4(angle, direction); GradientToEdgeFeatures.nonMaxSuppression4(intensity, direction, suppressed); performThresholding(threshLow, threshHigh, output); }
public boolean estimateCameraPose(BufferedImage leftEye) { if (!hasIntrinsic) return false; gray.reshape(leftEye.getWidth(), leftEye.getHeight()); ConvertBufferedImage.convertFrom(leftEye, gray); if (!target.process(gray)) return false; if (!computeH.computeHomography(target.getDetectedPoints())) return false; DenseMatrix64F H = computeH.getHomography(); targetToOrigin.set(decomposeH.decompose(H)); return true; }
public synchronized void process(final BufferedImage input) { this.input = input; workImage = new BufferedImage(input.getWidth(), input.getHeight(), BufferedImage.TYPE_INT_RGB); gray.reshape(input.getWidth(), input.getHeight()); ConvertBufferedImage.convertFrom(input, gray, true); detectTarget(); SwingUtilities.invokeLater( new Runnable() { public void run() { gui.setPreferredSize(new Dimension(input.getWidth(), input.getHeight())); renderOutput(); } }); }