MATLAB Answers

How to apply thresholding at different parts of an image?

조회 수: 21(최근 30일)
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

로그인 to comment.

채택된 답변

Image Analyst
Image Analyst 18 Jan 2020 15:09
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

로그인 to comment.

추가 답변(1개)

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

  댓글 수: 6

표시 이전 댓글 수: 3
Rik
Rik 17 Jan 2020 15:32
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 18 Jan 2020 13:57
Did you already attempt to implement my suggestions?
Krishna Chaitanya
Krishna Chaitanya 18 Jan 2020 14:32
I haven't yet.I will try now and keep you posted.
Thank you.

로그인 to comment.

이 질문에 답변하려면 로그인을(를) 수행하십시오.


Translated by