How to extract intensity of pixels from an image that are equal 1 in a binary mask

6 views (last 30 days)
Hi can anyone help me? I need to extract the intensity of every pixels from imgf that equal to 1 in seg and assign the result in variable intensite_region.
Any idea how I can accomplish this?
img = imread('images\vertebre.png');
imshow(img);
[x, y] = ginput(1);
x = uint16(x);
y = uint16(y);
imgf = medfilt2(img, [7 7]);
imshow(imgf);
elemd2 = strel('disk', 2, 0);
seg = zeros(510,628,'logical');
seg(y,x)=1 ;
seg_precedent = zeros(510,628,'logical');
dispMat = zeros(size(img));
while (~isequal(seg, seg_precedent))
seg_precedent = seg;
intensite_region = ??????
end

Accepted Answer

Julien Roussel
Julien Roussel on 20 Oct 2021
Edited: Image Analyst on 20 Oct 2021
I was able to find the solution myself.
intensite_region = double(imgf(seg == 1));
  1 Comment
Image Analyst
Image Analyst on 20 Oct 2021
I'd do it like this instead
intensite_region = imgf(seg);
Also, you don't do this:
seg = zeros(510,628,'logical');
seg(y,x)=1 ;
seg_precedent = zeros(510,628,'logical');
you do this:
seg = false(510, 628);
seg(y, x) = true;
seg_precedent = false(510, 628);

Sign in to comment.

More Answers (0)

Categories

Find more on Images in Help Center and File Exchange

Products

Community Treasure Hunt

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

Start Hunting!