How to apply thresholding at different parts of an image?

조회 수: 13 (최근 30일)
Krishna Chaitanya
Krishna Chaitanya 2020년 1월 9일
답변: Image Analyst 2020년 1월 18일
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?

채택된 답변

Image Analyst
Image Analyst 2020년 1월 18일
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);

추가 답변 (1개)

Rik
Rik 2020년 1월 9일
What you describe is a region growing algorithm, of which you can find an implementation here.
  댓글 수: 6
Rik
Rik 2020년 1월 18일
Did you already attempt to implement my suggestions?
Krishna Chaitanya
Krishna Chaitanya 2020년 1월 18일
I haven't yet.I will try now and keep you posted.
Thank you.

댓글을 달려면 로그인하십시오.

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by