I'm trying to create an image of alternating black and white stripes. I have the size of the final image, and the size of each white strip (they are all the same width) I'm trying to find a way to do it without using loops.
any ideas?
Thanks

 採用された回答

Image Analyst
Image Analyst 2015 年 1 月 16 日

1 投票

You can create one cycle, then use repmat() to replicate it to build up the entire image:
stripeWidth = 10;
imageRows = 423; % Whatever...
imageColumns = 359; % Whatever...
oneCycle = [255*ones(1, stripeWidth), zeros(1, stripeWidth)];
oneLine = repmat(oneCycle, [1, ceil(imageColumns/stripeWidth)]);
wholeImage = repmat(oneLine, [imageRows, 1]);;
% Crop
wholeImage = wholeImage(1:imageRows, 1:imageColumns);
imshow(wholeImage);
axis on;

1 件のコメント

Carmel
Carmel 2015 年 1 月 16 日
Thanks! that's great

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

その他の回答 (0 件)

カテゴリ

ヘルプ センター および File ExchangeConvert Image Type についてさらに検索

質問済み:

2015 年 1 月 16 日

コメント済み:

2015 年 1 月 16 日

Community Treasure Hunt

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

Start Hunting!

Translated by