Example usage for org.opencv.imgproc Imgproc equalizeHist

List of usage examples for org.opencv.imgproc Imgproc equalizeHist

Introduction

In this page you can find the example usage for org.opencv.imgproc Imgproc equalizeHist.

Prototype

public static void equalizeHist(Mat src, Mat dst) 

Source Link

Usage

From source file:OCV_EqualizeHist.java

License:Open Source License

@Override
public void run(ImageProcessor ip) {
    // srcdst//from w  w w .  j a  v  a 2s.com
    int imw = ip.getWidth();
    int imh = ip.getHeight();
    byte[] srcdst_bytes = (byte[]) ip.getPixels();

    // mat
    Mat src_mat = new Mat(imh, imw, CvType.CV_8UC1);
    Mat dst_mat = new Mat(imh, imw, CvType.CV_8UC1);

    // run
    src_mat.put(0, 0, srcdst_bytes);
    Imgproc.equalizeHist(src_mat, dst_mat);
    dst_mat.get(0, 0, srcdst_bytes);
}

From source file:by.zuyeu.deyestracker.core.detection.detector.BaseDetector.java

protected Rect[] detectWithClassifier(final Mat inputframe, final CascadeClassifier classifier) {
    LOG.debug("detectWithClassifier - start;");

    final Mat mRgba = new Mat();
    final Mat mGrey = new Mat();
    final MatOfRect detectedObjects = new MatOfRect();
    inputframe.copyTo(mRgba);/*from www  .j a  v  a  2 s  .co  m*/
    inputframe.copyTo(mGrey);
    Imgproc.cvtColor(mRgba, mGrey, Imgproc.COLOR_BGR2GRAY);
    Imgproc.equalizeHist(mGrey, mGrey);
    classifier.detectMultiScale(mGrey, detectedObjects);

    LOG.debug("detectWithClassifier - end;");
    return detectedObjects.toArray();
}

From source file:ch.zhaw.facerecognitionlibrary.PreProcessor.ContrastAdjustment.HistogrammEqualization.java

License:Open Source License

public PreProcessor preprocessImage(PreProcessor preProcessor) {
    List<Mat> images = preProcessor.getImages();
    List<Mat> processed = new ArrayList<Mat>();
    for (Mat img : images) {
        img.convertTo(img, CvType.CV_8U);
        Imgproc.equalizeHist(img, img);
        processed.add(img);// w  w  w .  ja v a2s .c  om
    }
    preProcessor.setImages(processed);
    return preProcessor;
}

From source file:classes.TextRecognitionPreparer.java

public static Mat equalizeIntensity(Mat inputImage) {

    if (inputImage.channels() >= 3) {

        Mat ycrcb = new Mat();

        Imgproc.cvtColor(inputImage, ycrcb, Imgproc.COLOR_BGR2YUV);

        ArrayList<Mat> channels = new ArrayList<Mat>();

        Core.split(ycrcb, channels);//w  w  w.  j  a  va  2  s . c  o  m

        Mat equalized = new Mat();

        Imgproc.equalizeHist(channels.get(0), equalized);

        channels.set(0, equalized);
        Core.merge(channels, ycrcb);

        Mat result = new Mat();
        Imgproc.cvtColor(ycrcb, result, Imgproc.COLOR_YUV2BGR);

        return result;
    }

    return null;
}

From source file:com.astrocytes.core.operationsengine.CoreOperations.java

License:Open Source License

/**
 * Equalizes a histogram for the image (color).
 *
 * @param src - color image to be applyed auto contrast.
 * @return the source image with equalized histogram.
 *///w ww.ja  va 2  s.c  o m
public static Mat equalize(Mat src) {
    Mat dest = new Mat();
    Imgproc.equalizeHist(grayscale(src), dest);
    return dest;
}

From source file:com.ibm.streamsx.edgevideo.device.FaceDetector.java

License:Open Source License

public Mat toGrayscale(Mat rgbFrame) {
    Mat grayFrame = new Mat();
    Imgproc.cvtColor(rgbFrame, grayFrame, Imgproc.COLOR_BGRA2GRAY);
    Imgproc.equalizeHist(grayFrame, grayFrame);
    return grayFrame;
}

From source file:com.Linguist.model.sharpeningClass.java

public File imagePreprocessing(String imgeNme, String extnsn) {
    File sharpen = null;/*from  w  w w .j  a  v  a 2s . com*/
    try {
        // System.loadLibrary(Core.NATIVE_LIBRARY_NAME);
        Mat source = Imgcodecs.imread(
                "C:\\Users\\User\\Documents\\GitHub\\Linguist\\web\\uploadedImage\\" + imgeNme,
                Imgcodecs.CV_LOAD_IMAGE_GRAYSCALE);
        Mat destination = new Mat(source.rows(), source.cols(), source.type());

        Imgproc.equalizeHist(source, destination);
        Imgcodecs.imwrite("C:\\Users\\User\\Documents\\GitHub\\Linguist\\web\\uploadedImage\\contrast.jpg",
                destination);
        sharpen = new File("C:\\Users\\User\\Documents\\GitHub\\Linguist\\web\\uploadedImage\\contrast.jpg");
    } catch (Exception e) {
        System.out.println("error: " + e.getMessage());
    }
    return sharpen;
}

From source file:com.oetermann.imageclassifier.ImageClassifier.java

License:Open Source License

public int match(String matcherName, Mat queryImage, int minMatches) {
    if (!flannMatchers.containsKey(matcherName)) {
        return UNKOWN_MATCHER;
    }/*from   w ww.ja va 2  s  .co  m*/
    Imgproc.equalizeHist(queryImage, queryImage);
    //        long t = System.currentTimeMillis();
    Mat queryDescriptors = descriptorExtractorWrapper.detectAndCompute(queryImage);
    //        System.out.println("SURF: "+(System.currentTimeMillis()-t));
    //        t = System.currentTimeMillis();
    int match = flannMatchers.get(matcherName).bestMatch(queryDescriptors, minMatches);
    queryDescriptors.release();
    //        System.out.println("FLANN: "+(System.currentTimeMillis()-t));
    return match;
}

From source file:cpsd.ImageGUI.java

private void enhanceContrast() {
    System.loadLibrary(Core.NATIVE_LIBRARY_NAME);
    //System.load("/usr/local/share/OpenCV/java/libopencv_java249.so");
    // rgb2Gray();
    Mat source = ImageClass.getInstance().getImage();
    Mat destination = new Mat(source.rows(), source.cols(), source.type());
    Imgproc.equalizeHist(source, destination);
    image.getInstance().setImage(destination);
}

From source file:ctPrincipal.Filtros.java

public String Contraste() {
    /// Converte para escala cinza
    Imgproc.cvtColor(image, image, Imgproc.COLOR_RGB2GRAY);
    /// Aplica equalizacao de histograma.
    Imgproc.equalizeHist(image, output);
    Imgcodecs.imwrite("OutputImg/contraste.jpg", output);
    return "OutputImg/contraste.jpg";
}