How to find the intensity of those pixels of which I know the position without doing it once at a time

조회 수: 3 (최근 30일)
I need to find and print on my workspace the intensity values of those pixels which are greater than a certain value. I have already found a way to create an array indicating the position of these pixels(I have done a table in which are identified row and column of each pixel), but I can't use the function x = I(row, column). What I'm saying is that it works if I put 2 numbers relative to the position, but I was hoping to create a list of every intensity value with just a few commands, without doing everything once at a time by hand. Also because I have many images to process and values change every time Is there a way to do it?
Thanks in advance.

채택된 답변

Image Analyst
Image Analyst 2017년 3월 17일
Yes, simply threshold and use the resulting mask:
mask = grayImage > someValue; % A 2-D logical image.
imshow(mask); % Display what you're going to extract.
extractedIntensityValues = grayImage(mask); % A 1-D vector (list) of the intensity values in the mask.
  댓글 수: 2
EL
EL 2017년 3월 18일
I actually had to put mask = find (grayImage> someValue) , but for the rest it worked and you actually helped me find the solution to another question of mine.
Thank you very much sir/miss/mrs!
Image Analyst
Image Analyst 2017년 3월 18일
Actually you didn't need find(). As you can see from the small demo below, it will give the same values either way. Using find() just adds time because it has to do another operation to get the linear indexes, which aren't needed:
m = uint8(magic(15)) % Sample image
mask = m > 220 % Create mask
extracted1 = m(mask) % Extract values via logical mask
mask = find(m > 220) % Create mask
extracted2 = m(mask) % Extract values via linear indices

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

추가 답변 (0개)

Community Treasure Hunt

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

Start Hunting!

Translated by