MATLAB Answers

How to apply thresholding at different parts of an image?

13 views (last 30 days)
I have a grayscale image and location of some pixels from where i have to check whether the pixels connected to it have intensity greater than the given threshold .
There is a seperate threshold for every given starting pixel.
For example,
for a given pixel location p[i j] wih a threshold value 't' , I have to start at the pixel location [i j] in the grayscale image and check if the pixels connected to it (in 8 directions) have intensity greater than threshold 't'.If yes,then the process needs to be continued with that pixels too until no more pixels with intensity greater than threshold are found.
The process should start simultaneously from all given pixel locations in the image.
I need a logical array of 0s and 1s as result,the ones whose intensity are greater than t will be marked as 1 and the process will be continued till connected pixels don't have intensity greater than 't'.
Can somebody help me how to do this?

  0 Comments

Sign in to comment.

Accepted Answer

Image Analyst
Image Analyst on 18 Jan 2020
I think this is simply a labeling problem so you can use the built-in function bwlabel().
You said you have a threshold for every single pixel in the image. OK that means you have another image where the values are the thresholds. You said you then want to threshold (binarize) all the pixels according to the threshold you have for each pixel location, so you're seeing if your image values are more than your threshold image values. And then you simply want to find all pixels above the threshold that are connected to the one at row i, column j. So you can just do
binaryImage = grayImage >= thresholdImage; % Binarize the image.
% Now identify connected components
[labeledImage, numberOfRegions] = bwlabel(binaryImage);
subplot(1, 2, 1);
imshow(labeledImage, []);
% Now determine the label at row i, column j, where i and j are known, specifed coordinate values.
ijLabel = labeledImage(i, j);
% Extract only the region with that label and display it.
ijBlob = ismember(labeledImage, ijLabel);
subplot(1, 2, 2);
imshow(ijBlob);

  0 Comments

Sign in to comment.

More Answers (1)

Rik
Rik on 9 Jan 2020
What you describe is a region growing algorithm, of which you can find an implementation here.

  6 Comments

Show 3 older comments
Rik
Rik on 17 Jan 2020
The first block is simply input checking, so you could replace it with options.seed=item; if you don't care about input validation.
The second part should be easy to do on your own. The result variable should be marked with true for each seed location.
As a general remark: everyone starts being new at Matlab and you will only learn it by putting in the time. Start with simple loops and optimize when that appears to be too slow.
Rik
Rik on 18 Jan 2020
Did you already attempt to implement my suggestions?
Krishna Chaitanya
Krishna Chaitanya on 18 Jan 2020
I haven't yet.I will try now and keep you posted.
Thank you.

Sign in to comment.

Sign in to answer this question.