フィルターのクリア

Matlab code without for loop

1 回表示 (過去 30 日間)
Jab
Jab 2016 年 1 月 12 日
編集済み: jgg 2016 年 1 月 12 日
Image contains 4 pixels . 0-background, 1,2 and 3 freground pixels.Can anyone help me how to improve the following code for computational efficiency? Thanks
[m n]=size(image);
for p=1:m
for q=1:n
if image(p,q)==1
image(p,q)=255;
else
image(p,q)=0;
end
end
end

採用された回答

jgg
jgg 2016 年 1 月 12 日
編集済み: jgg 2016 年 1 月 12 日
I think this should work:
i = image('file.jpg')%load in whatever image it is
i(i == 1) = 255;
i(i ~= 255) = 0;

その他の回答 (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