MATLAB Answers

Isolating specific dots in an image.

2 views (last 30 days)
Kimo Kalip
Kimo Kalip on 21 Jun 2018
Commented: Kimo Kalip on 27 Jun 2018
Hello, I'm trying to get my image to the point where only the dots inside the black squares remain.
So far, all I've done with this code is use inmextendedmin on the original grayscale image, and then masked it ontop of the grayscale image to produce this result.
mask = imextendedmin(grayImage,2);
Before, I had been trying to use watershedding, dividing the background, and a lot of other neat tricks to try and single out the black dots, but it seems that this simple bit of code alone gets me half way to what I want (As each black square has a dot already in it, all i want are those dots). Is there a way to get rid of everything else in this image besides the gray dots inside the black dots?
The problem I often had with watershedding and whatnot is I needed a variable threshold, as well as watershedding was rather time and processes intensive, so I'm trying to find more efficient ways of doing it.

  1 Comment

Kimo Kalip
Kimo Kalip on 21 Jun 2018
Notice also how there is a lot of different levels of darkness in the background, wondering if that too may be an issue.

Sign in to comment.

Accepted Answer

Anton Semechko
Anton Semechko on 21 Jun 2018
bw=im>50 & bw_bkg;
figure, imshow(bw)


Sign in to comment.

More Answers (1)

Kimo Kalip
Kimo Kalip on 22 Jun 2018
Oh man, thats perfect, thanks!


Kimo Kalip
Kimo Kalip on 26 Jun 2018
Oh, you answered it, don't worry - thanks! I had hoped to use this method in order to get around using thresholds to isolate those black blobs (As thresholds need to be tweaked on a per-picture basis, so I was trying to find some robust way of automating the isolation without needing the human touch). Work in progress, but I don't think i can get around thresholding.
Anton Semechko
Anton Semechko on 26 Jun 2018
For your type of image data, you can try to automate threshold selection as follows:
(1) Initialize threshold (e.g., thr=10)
(2) Apply threshold to image and count the number of connected components (representing the "wells" in which the white dots are embedded) above some a priori defined area
(3) Increment threshold: thr_new <-- thr + 1
(4) Repeat (2) using thr_new and compare number of connected components obtained with thr, if the number of "wells" decreases, accept thr as best value of intensity threshold and terminate search, otherwise set thr <-- thr_new and go to step (2)
Kimo Kalip
Kimo Kalip on 27 Jun 2018
I hadn't thought of that, its actually a really good idea - thanks! Where does it stop though? Wouldn't I want to keep going until all of the wells disappear? But by the same token, I imagine I'd start losing dots I actually want to keep before I got rid of all the large wells, no?
Thanks again for all the help so far!

Sign in to comment.