Reputation: 57
I have an image size (m x n x 4)
I want to make strip of 0
or NaN
on it. I want the strips to be 4 pixels wide and having a space of about 30 pixels between them. That is when I display the image in RGB
I have strips of NaN
. Can somebody help me out with this, please?
Upvotes: 1
Views: 71
Reputation: 16354
I interpreted you question as "how can I repeatedly draw black lines with a given width and a specified offset over an image".
img = imread('peppers.png');
height = size(img,1);
strip_width = 4;
strip_offset = 30;
line_start_idx = 0:(strip_width+strip_offset):height;
line_idx = ndgrid(line_start_idx,1:strip_width)';
line_idx = line_idx(:);
line_add = repmat(1:strip_width,1,length(line_start_idx))';
line_idx = line_idx + line_add;
img(line_idx,:,:) = 0;
imshow(img)
Upvotes: 1