フィルターのクリア

Entropy of subsections of an image

1 回表示 (過去 30 日間)
Simon
Simon 2013 年 7 月 30 日
I have a grayscale image, which I am trying to take 3x3 sections of and find the entropy, and based on the value, make the centre pixel white or black.
The problem I have is that the code I am using is unacceptably slow - running a single, low res image takes several seconds. the code looks something like this:
for j = 2:m-1
for i = 2:n-1
E = entropy(im(j-1:j+1, i-1:i+1));
if E < threshold
ime(j, i) = 1;
else
ime(j, i) = 0;
end
end
end
where the grayscale image im is of size [m, n], as is the binary image ime. Any suggestions on how to improve it? Arrayfun may help, but i have no idea how to use it properly

採用された回答

Iain
Iain 2013 年 7 月 30 日
Try
E = entropyfilt(im,ones(3,3));
ime = E < threshold;
  1 件のコメント
Simon
Simon 2013 年 7 月 30 日
That's exactly what I was looking for, thanks

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

その他の回答 (0 件)

カテゴリ

Help Center および File ExchangeImage Processing Toolbox についてさらに検索

Community Treasure Hunt

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

Start Hunting!

Translated by