Ask Your Question

Tru's profile - activity

2020-02-26 09:21:07 -0600 received badge  Famous Question (source)
2018-09-11 11:01:36 -0600 received badge  Famous Question (source)
2018-03-13 01:49:12 -0600 received badge  Notable Question (source)
2017-03-29 15:26:13 -0600 received badge  Popular Question (source)
2014-01-12 14:46:11 -0600 received badge  Taxonomist
2012-08-02 12:40:32 -0600 commented question How to extract only top-level contours?

Gave somewhat of a better answer (RETR_EXTERNAL). Was wondering whether it could be more refined...

2012-08-02 10:06:33 -0600 asked a question How to extract only top-level contours?

When using findContours to identify blobs, is there a way to ignore any contours present within another contour. I only need to count the number of contours that are the outermost using contours.size();

I looked into this and found the RETR_EXTERNAL parameter instead of the RETR_LIST, is this enough? Or do I have to do anything with the hierarchy Mat object (third parameter)?

2012-07-15 20:43:46 -0600 received badge  Famous Question (source)
2012-07-14 15:51:36 -0600 commented question What's the best way to segment different coloured blobs?

It's actually real coloured pellets on a black background.

2012-07-13 11:02:26 -0600 received badge  Nice Question (source)
2012-07-12 20:13:58 -0600 received badge  Notable Question (source)
2012-07-12 05:13:27 -0600 received badge  Popular Question (source)
2012-07-12 02:31:22 -0600 commented answer What's the best way to segment different coloured blobs?

I have a requirement to figure out how many blobs of each colour are present, hence the use of HSV. Is there any way I can extract colour details for an area inside a detected contour, so that I can get an output such as 2 red blobs and 1 blue blob?

2012-07-11 17:44:43 -0600 asked a question What's the best way to segment different coloured blobs?

I have a requirement to segment an image like this into blobs of each colour. The goal is to find out how many blobs of each colour are present. That can be handled using findContours if I can create a binary image each for each coloured blobs. In the image below it would be - 3 blobs for red image, 1 green, 1 blue, 2 white/grey.

I've tried converting to the HSV color space and I can use the Hue channel to threshold whatever colour I want using cvInRange. But the problem is since the black background and white blobs also have an Hue value, I keep getting them in the results for other colours. Ideally, I need to eliminate the whites first and ignore the black background. Then get each of the other colours.

I tried splitting channels to extract specific channels too, before using cvInRange on it. - Core.extractChannel(mIn, v, 2);

Is there a better approach?

Image

2012-07-07 08:36:59 -0600 received badge  Scholar (source)
2012-07-05 04:37:13 -0600 received badge  Supporter (source)
2012-07-05 03:53:54 -0600 received badge  Student (source)
2012-07-05 03:53:08 -0600 received badge  Notable Question (source)
2012-07-04 14:37:16 -0600 received badge  Popular Question (source)
2012-07-04 11:22:37 -0600 asked a question How to convert Floating point image to 32-bit single-channel?

I'm doing a watershed segmentation and the marker image is derived from the source image put through a distance transform. The distance transform returns a floating point image (I have no idea about the bit-depth) and I have trouble putting it through the watershed method since it requires a 32 bit single channel image.

Can I use the mat's convertTo method to set the bit depth to 32? I also have trouble trying to display the floating point image since the matToBitmap() method doesn't seem to accept them.

    Mat mImg = new Mat();
    Mat mThresh = new Mat();
    Mat mDist = new Mat();

    ImageView imgView = (ImageView) findViewById(R.id.imageView);
    Bitmap bmpIn = BitmapFactory.decodeResource(getResources(),
            R.drawable.w1);

    Utils.bitmapToMat(bmpIn, mImg);

    Imgproc.cvtColor(mImg, mImg, Imgproc.COLOR_BGR2GRAY);
    Imgproc.threshold(mImg, mThresh, 0, 255, Imgproc.THRESH_BINARY
            | Imgproc.THRESH_OTSU); 

    //Marker image for watershed
    Imgproc.distanceTransform(mThresh, mDist, Imgproc.CV_DIST_L2, Imgproc.CV_DIST_MASK_PRECISE);

    //Conversions for watershed
    Imgproc.cvtColor(mThresh, mThresh, Imgproc.COLOR_GRAY2BGR, 3);

    //Floating-point image -> 32-bit single-channel
    mDist.convertTo(...);

    Imgproc.watershed(mThresh, mDist); //

    Bitmap bmpOut = Bitmap.createBitmap(mThresh.cols(), mThresh.rows(),
            Bitmap.Config.ARGB_8888);       


    Utils.matToBitmap(mThresh, bmpOut);
    imgView.setImageBitmap(bmpOut);