How detect very small blobs
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.
I converted images to grayscale and added a border to the first, to align them to same size.
.
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 ?
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.
I updated my post with color images
@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?
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.
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
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.
@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 ?