how can I create a monochrome image with a resolution of 128x128 pixels consisting of horizontal white and black stripes 2 pixels wide

2 ビュー (過去 30 日間)
I need to display an image with a resolution of 128x128 pixels consisting of horizontal white and black stripeswith 2 pixels wide.
How can I do it ?
I am new in matlab
please help!!
I am using this coded but it shows vertical lines
stripeWidth = 2;
imageRows = 256; % Whatever...
imageColumns = 256; % Whatever...
oneCycle = [128*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);

採用された回答

Matt J
Matt J 2021 年 3 月 25 日
stripeWidth = 2;
imageRows = 256; % Whatever...
imageColumns = 256; % Whatever...
oneLine=ones(stripeWidth,imageColumns);
wholeImage=repmat( [oneLine;0*oneLine], imageRows/(2*stripeWidth),1);
imshow(wholeImage)

その他の回答 (2 件)

Matt J
Matt J 2021 年 3 月 25 日
編集済み: Matt J 2021 年 3 月 25 日
stripeWidth = 2;
imageRows = 256; % Whatever...
imageColumns = 256; % Whatever...
wholeImage=true(imageRows,imageColumns);
for i=1:stripeWidth
wholeImage(stripeWidth+i:2*stripeWidth:end,:)=0;
end
imshow(wholeImage)

Matt J
Matt J 2021 年 3 月 25 日
stripeWidth = 2;
imageRows = 256; % Whatever...
imageColumns = 256; % Whatever...
wholeImage=true(imageRows/stripeWidth,imageColumns);
wholeImage(2:2:end)=0;
wholeImage=repelem(wholeImage,stripeWidth,1);
imshow(wholeImage)

カテゴリ

Help Center および File ExchangeDeep Learning Toolbox についてさらに検索

タグ

Community Treasure Hunt

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

Start Hunting!

Translated by