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

6 ビュー (過去 30 日間)
Julien Roussel
Julien Roussel 2021 年 10 月 20 日
編集済み: Julien Roussel 2021 年 10 月 20 日
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.....
img = imread('images\vertebre.png');
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....

回答 (1 件)

Image Analyst
Image Analyst 2021 年 10 月 20 日
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));
  1 件のコメント
Julien Roussel
Julien Roussel 2021 年 10 月 20 日
編集済み: Julien Roussel 2021 年 10 月 20 日
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;
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 = 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

サインインしてコメントする。

カテゴリ

Help Center および File ExchangeDetection についてさらに検索

Community Treasure Hunt

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

Start Hunting!

Translated by