Exemple #1
0
 def subtract(self, thres_chan):
     cv.RunningAvg(thres_chan, self.accumulator, self.adaptation_rate)
     cv.CvtScale(thres_chan, self.green32_img)
     cv.Sub(self.green32_img, self.accumulator, self.difference_img)
     cv.Threshold(self.difference_img, self.thresholded_img, self.threshold, 1, cv.CV_THRESH_BINARY)
     cv.Dilate(self.thresholded_img, self.thresholded_img, iterations=1)
     blob.remove_large_blobs(self.thresholded_img, max_area = self.max_area)
     return self.thresholded_img
Exemple #2
0
 def subtract(self, thres_chan):
     cv.RunningAvg(thres_chan, self.accumulator, self.adaptation_rate)
     cv.CvtScale(thres_chan, self.green32_img)
     cv.Sub(self.green32_img, self.accumulator, self.difference_img)
     cv.Threshold(self.difference_img, self.thresholded_img, self.threshold,
                  1, cv.CV_THRESH_BINARY)
     cv.Dilate(self.thresholded_img, self.thresholded_img, iterations=1)
     blob.remove_large_blobs(self.thresholded_img, max_area=self.max_area)
     return self.thresholded_img
Exemple #3
0
    def threshold(self, thres_low, thres_high, thres_chan):
        result_val = 1 #Change result_val to 255 if need to view image

        cv.Threshold(thres_chan, self.thresholded_low, thres_low, result_val, cv.CV_THRESH_BINARY)
        cv.Dilate(self.thresholded_low, self.thresholded_low) #thresholded_low thresholded image using threshold for dark regions
        blob.remove_large_blobs(self.thresholded_low, self.max_area)

        cv.Threshold(thres_chan, self.thresholded_high, thres_high, result_val, cv.CV_THRESH_BINARY)
        cv.Dilate(self.thresholded_high, self.thresholded_high) #thresholded_high thresholded image using threshold for bright regions
        blob.remove_large_blobs(self.thresholded_high, self.max_area)#, show=True)

        cv.Or(self.thresholded_low, self.thresholded_high, self.thresholded_combined)
        return self.thresholded_combined
Exemple #4
0
    def threshold(self, thres_low, thres_high, thres_chan):
        result_val = 1  #Change result_val to 255 if need to view image

        cv.Threshold(thres_chan, self.thresholded_low, thres_low, result_val,
                     cv.CV_THRESH_BINARY)
        cv.Dilate(
            self.thresholded_low, self.thresholded_low
        )  #thresholded_low thresholded image using threshold for dark regions
        blob.remove_large_blobs(self.thresholded_low, self.max_area)

        cv.Threshold(thres_chan, self.thresholded_high, thres_high, result_val,
                     cv.CV_THRESH_BINARY)
        cv.Dilate(
            self.thresholded_high, self.thresholded_high
        )  #thresholded_high thresholded image using threshold for bright regions
        blob.remove_large_blobs(self.thresholded_high,
                                self.max_area)  #, show=True)

        cv.Or(self.thresholded_low, self.thresholded_high,
              self.thresholded_combined)
        return self.thresholded_combined