I am developing an app that searches for contours within a region of interest. I only want to display the top and bottom contours. I have managed to find the contours but i only want to display the highest and lowest contours. I have made a for loop that loops through the contours but i am unsure how to progress.. anyone got any ideas?
Thankyou in advance
RoiMat= image.submat(rect.y, rect.y + rect.height, rect.x, rect.x + rect.width);
Imgproc.cvtColor(RoiMat, RoiMat, Imgproc.COLOR_RGB2GRAY);
equalizeHist(RoiMat, RoiMat);
Imgproc.GaussianBlur(RoiMat, RoiMat, new Size(5, 5), 0);
Imgproc.threshold(RoiMat, RoiMat, 100, 255, Imgproc.THRESH_BINARY_INV);
List contours = new ArrayList();
Mat hierarchy = new Mat();
Imgproc.findContours(RoiMat, contours, hierarchy, Imgproc.RETR_EXTERNAL, Imgproc.CHAIN_APPROX_SIMPLE);
for (int contourIdx = 0; contourIdx < contours.size(); contourIdx++) {
//search for the highest and lowest contours here and output as points.
Mat contour = contours.get(idx);
}
↧