Ask Your Question

avpai's profile - activity

2020-08-11 22:48:00 -0600 received badge  Famous Question (source)
2020-03-08 16:06:58 -0600 received badge  Notable Question (source)
2019-10-16 06:48:48 -0600 received badge  Notable Question (source)
2019-07-19 10:13:12 -0600 received badge  Notable Question (source)
2019-01-03 04:52:58 -0600 received badge  Popular Question (source)
2018-07-20 03:12:58 -0600 received badge  Popular Question (source)
2018-06-21 05:35:17 -0600 received badge  Popular Question (source)
2016-08-03 23:47:38 -0600 commented question counting the number of child contours inside a contour in opencv

I actually don't need to find the call a particular child contours . I just need to get their total count

2016-08-02 06:14:26 -0600 asked a question counting the number of child contours inside a contour in opencv

I have a source image

image description

and I have applied binary thresholding to get this,to get

image description

I used contours to differentiate between the ones having child contours and ones that don't.The resultant pic is

image description

But how do I count the number of child contours that each green contour contains (the red ones inside th green)?. This is code I have used:-

Mat binMask = lung;// the thresholded image
Mat lung_src = imread("source.tiff");// the source image
 //imshow("bin mask", binMask);
  vector<std::vector<cv::Point>> contours;
  vector<cv::Vec4i> hierarchy;
    int count = 0, j;

     double largest_area = 0;
        int largest_contour_index = 0;

  findContours(binMask, contours, hierarchy, CV_RETR_TREE, CV_CHAIN_APPROX_SIMPLE, cv::Point(0, 0));

       for (int i = 0; i < contours.size(); i++)
         {
double a = contourArea(contours[i], false);  //  Find the area of contour
if (a>largest_area)
{
    largest_area = a;
    largest_contour_index = i;
}
for (j = 0; j <= i; j++)
{
    if (hierarchy[j][2] != -1) // means it has child contour
    {

            drawContours(lung_src, contours, j, Scalar(0, 255, 0), 1, 8, hierarchy, 0, Point());

    }           
    else  // means it doesn't have any child contour
    {
        drawContours(lung_src, contours, j, Scalar(0, 0, 255), 1, 8, hierarchy, 0, Point());
    }
     }
  }
     drawContours(lung_src, contours, largest_contour_index, Scalar(255, 0, 0), 1, 8, hierarchy, 0, Point());
     imshow("lung-mapped", lung_src);
2016-03-16 16:40:35 -0600 received badge  Student (source)
2016-01-12 06:32:39 -0600 commented answer imwrite in opencv gives a black image

tried it..no luck..guess I have to look into filestorage..

2016-01-12 06:00:25 -0600 commented question imwrite in opencv gives a black image

no luck :(

2016-01-12 05:57:29 -0600 commented answer imwrite in opencv gives a black image

I want to save the image. is there no other way other than filestorage?

2016-01-12 05:23:19 -0600 asked a question imwrite in opencv gives a black image

I wrote a code for watershed segmentation in C API. Now I am converting all those into C++. so, cvsaveimage becomes imwrite. But when I use imwrite ,all i get is a black image.

this is the code:-

    Mat img8bit;
    Mat img0;
    img0 = imread("source.png", 1);           
    Mat wshed(img0.size(), CV_32F);
    wshed.setTo(cv::Scalar::all(0));
   ////after performing watershed segmentation and
            // displaying the watershed image from wshed//
    wshed.convertTo(img8bit, CV_32FC3, 255.0);
    imwrite("Watershed.png", img8bit);

The original image that I want to save is in wshed. I saw suggestions from the net that we need to convert it to 16 bit or higher so that the imwrite saves it right. Like you see,I tried that. But the wshed image is being displayed correctly when using imshow.The img0 is grey image/black and white while the wshed image is coloured. any help on this? I used wshed.type() to get what kind of image the output is,it was 16bit.

2016-01-07 22:53:00 -0600 received badge  Editor (source)
2016-01-07 04:02:02 -0600 asked a question how to find the centre of multiple objects in a image

I got this image

image description

I like to find the centre of each white area and mark it as red (also get their coordinates). I am looking into moments functions, is there a better way to get the centre point? do help or share ur codes/ideas.

UPDATE:- I tried to find the contour of this image using the below codes:-

    IplImage* mask1 = NULL;        
CvMemStorage * storage5 = cvCreateMemStorage(0);    
CvSeq * contour1 = 0;
mask1= cvCloneImage(mask);
cvShowImage("mask1", mask1);

cvFindContours(mask, storage5, &contour1, sizeof(CvContour), mode, CV_CHAIN_APPROX_SIMPLE, cvPoint(0, 0));
cvDrawContours(mask1, contour1, CV_RGB(0, 255, 255), CV_RGB(255, 0, 0), 2, 1, 8);   

cvShowImage("result1", mask);

The original Image I have shown is declared as mask and I used a clone image mask1 to find out contours. But after this what I get is the below shown image:-

image description

I used the same method in other sections of the program and got good results,but I dunno what happened in this case..

2015-12-21 01:11:45 -0600 asked a question need to find a way for polyp detection in a 2D image using OpenCV

I am currently learning OpenCV. I am using OpenCV to perform segmentation and object detection in 2D images. I need to find a way to detect polyps in the intestines.Refer the pic below:- image description

I used object detection but that would need a template and one the disadvantages is that the template wont be rotated or scaled to check whether there are any similar copies in the source image. So i'm trying to find a new way to detect these polyps.I would be grateful if anyone of you could help me with this.

2015-11-25 23:20:34 -0600 received badge  Enthusiast