problem in writing a function
1 回表示 (過去 30 日間)
古いコメントを表示
What is the problem with this code?
function Y = BWMfn(B)
[m,n]=size(B);
Y=zeros(2*m,2*n);
for i=1:m;
for j=1:n;
if B(i,j)<128
Y(2*i-1,2*j-1)=0;
else
Y(2*i-1,2*j-1)=1;
end
end
end
BWM is a matrix. Please reply asap
採用された回答
Image Analyst
2013 年 6 月 16 日
Why do you even want this anyway? It's kind of like simple thresholding
Y = B >= 128;
except that it has rows and columns of zeros interleaved. Why would you want that? By the way, you could vectorize it by doing:
Y = zeros(2*size(B));
Y(1:2:end, 1:2:end) = B >= 128;
その他の回答 (1 件)
Walter Roberson
2013 年 6 月 16 日
You need to start the function from the command line, not by clicking on "Run" or pressing F5. For example at the command line command
BWMfn(rand(3,4))
0 件のコメント
参考
カテゴリ
Help Center および File Exchange で Calculus についてさらに検索
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!