How detect very small blobs

asked 2018-02-19 16:17:03 -0600

procton gravatar image

updated 2018-02-20 00:40:24 -0600

I need to find differences on the following two images. The first one has very small blobs (please look at the middle of first image) that I would like to detect. Also, the first one has been cropped from the second.

image description

image description

I converted images to grayscale and added a border to the first, to align them to same size.

image description. image description

and I tried

Core.absdiff(imgWithBlobs, imgRef, diff);
Mat threshold = new Mat();
Imgproc.threshold(diff, threshold, 45, 255, Imgproc.THRESH_BINARY);

Then I tried some erotion and dilation, but results are poor. Any suggestion? Maybe I should explore a different colorspace ?

edit retag flag offensive close merge delete

Comments

Why don't you post the color images, if they are a significantly different color, that would be useful.

Also try a local threshold, instead of a global one.

Tetragramm gravatar imageTetragramm ( 2018-02-19 23:02:03 -0600 )edit

I updated my post with color images

procton gravatar imageprocton ( 2018-02-20 00:33:15 -0600 )edit

@procton! It looks like the 1st Image is not a cropped version of the 2nd Image and there was some camera shift involved! Do you want to detect the small blobs or you want to find the difference from the 2nd Image and from that you want to filter out the blob?

Balaji R gravatar imageBalaji R ( 2018-02-20 11:18:32 -0600 )edit

Good catch @Balaji !!!, I also noticed the shift that you pointed out. My goal is to detect small blobs. Till now I was focused on working with difference image and from that to extract blobs, but if a different, more efficient method, exists, it's fine too.

procton gravatar imageprocton ( 2018-02-20 13:08:12 -0600 )edit

Have you got two images or only one ? With one image you can blur the image (size>11 and sigma>6) and calculate difference between original and blur image.

with two images matchtemplate and difference

LBerger gravatar imageLBerger ( 2018-02-20 14:05:11 -0600 )edit
1

For images like this, the Laplacian transform can be remarkably effective.

Other useful algorithms might be Spectral Saliency, though you'll need to tune the parameters internal to the code.

Tetragramm gravatar imageTetragramm ( 2018-02-20 17:03:30 -0600 )edit

@Telegramm I did some experiments with Laplacian, but I am not sure of what could be good parameters in my scenario. Moreover, Laplacian should be applied on single images and then make difference, or directly on difference image ?

procton gravatar imageprocton ( 2018-02-22 13:54:45 -0600 )edit