# extract pixels where value is greater or less than a specified value

1 view (last 30 days)
Julien Roussel on 20 Oct 2021
Edited: Julien Roussel on 20 Oct 2021
Hi how can i extract the list of pixels from imgf that are less than 93?
i have to only check the pixels that are in the ind variable.....
imgf = medfilt2(img, [7 7]);
binf = 93;
bsup = 117;
ind = ([154718;155227;155228;155229;155736;155737;155739;155740;156247;156248;156249;156758]);
inf_seg = 93 < imgf; %%%%how do i make this line only check pixels that are in the ind variable....

Image Analyst on 20 Oct 2021
Use ismember() to determine if one set of values is contained within another set of values.
Not sure what ind represents. Linear indexes?
[ia, ib] = ismember(ind, find(inf_seg));
Julien Roussel on 20 Oct 2021
actually here's my full code....
my main issue is that in these 2 lines Im affecting every pixels not only the ones i extracted in the variable ind
inf_seg = binf < imgf;
sup_seg = imgf < bsup;
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 = false(510, 628);
seg(y, x) = true;
seg_precedent = false(510, 628);
dispMat = zeros(size(img));
while (~isequal(seg, seg_precedent))
seg_precedent = seg;
intensite_region = double(imgf(seg));
m_region = mean(intensite_region);
std_region = std(intensite_region);
seg_dilate = imdilate(seg, elemd2);
contour = seg_dilate - seg;
ind = find(contour==1);
delta = 12;
binf = m_region - (std_region + delta);
bsup = m_region + (std_region + delta);
inf_seg = binf < imgf;
sup_seg = imgf < bsup;
candidats = inf_seg & sup_seg ;
seg = candidats;
dispMat = img;
dispMat(seg) = 0;
RGB = cat(3,uint8(seg)*255+dispMat,dispMat,dispMat);
imshow(RGB, [])
drawnow
end