View Single Post
  #2   Spotlight this post!  
Unread 10-10-2012, 22:29
Ginto8's Avatar
Ginto8 Ginto8 is offline
Programming Lead
AKA: Joe Doyle
FRC #2729 (Storm)
Team Role: Programmer
 
Join Date: Oct 2010
Rookie Year: 2010
Location: Marlton, NJ
Posts: 174
Ginto8 is a glorious beacon of lightGinto8 is a glorious beacon of lightGinto8 is a glorious beacon of lightGinto8 is a glorious beacon of lightGinto8 is a glorious beacon of light
Re: Using thresholds on WPICameraExtension classes

from WPIGrayscaleImage.java (from the WPIJavaCV project):
Code:
    /**
     * Returns a black and white image where every pixel that is higher (in the 0-255 scale) than the given threshold is <bold>white</bold>,
     * and everything below is <bold>black</bold>.
     * @param threshold a value 0-255. if a pixel has a value below the theshold, it becomes black
     * if the pixel value is above or equal to the threshold, the pixel becomes white
     * @return a new {@link WPIBinaryImage} that represents the threshold
     */
    public WPIBinaryImage getThreshold(int threshold) {
        validateDisposed();

        IplImage bin = IplImage.create(image.cvSize(), 8, 1);
        cvThreshold(image, bin, threshold, 255, CV_THRESH_BINARY);
        return new WPIBinaryImage(bin);
    }
It says that getThreshold() is black for [0,threshold) and white for [threshold, 255] - though, if you look at the OpenCV documentation for cvThreshold, it says that it's black for [0,threshold] and white for (threshold,255]. Either way, white is somewhere above, black is somewhere below.
The companion function getThresholdInverted() simply reverses the ranges, and if you compare getThreshold() and getThresholdInverted() from the same image with the same threshold, they should be perfect negatives.
Reply With Quote