# Create black columns/rows in image.

2 visualizzazioni (ultimi 30 giorni)
Raldi il 26 Feb 2015
Commentato: Raldi il 26 Feb 2015
Hi everyone,
I have an image and I want to only keep visible small patches of lets say 8x8 alternatively.
So I start at the beginning keep the first 8x8 patch, move right, make black the next patch, and so on until the end.
After that I move to the next row and I make the first patch black since we kept the one above it.
Moving like this I create a sort of a check board where the white parts have my original image.
What I did till now is
for ii = 1:it
Image = Image(1:step:end, 1:step:end);
end
After that I create a matrix of zeros at the dimensions of my original image and paint my under-sampled image
imageNew(1:step:end, 1:step:end) = Image;
This does not create the check-board effect though and I don't even know if it is good enough regarding the time it needs to run.
Has anyone any idea of how to go on about doing this?
##### 0 CommentiMostra -2 commenti meno recentiNascondi -2 commenti meno recenti

Accedi per commentare.

### Risposta accettata

Guillaume il 26 Feb 2015
I would do it like this:
pattern = zeros(11, 10); %number of rows must be odd
pattern(1:2:end) = 1;
mycheckerboard = imresize(pattern, 30, 'nearest');
imshow(mycheckerboard)
##### 3 CommentiMostra 1 commento meno recenteNascondi 1 commento meno recente
Guillaume il 26 Feb 2015
Oh, sorry misunderstood. Just to this then:
mycheckerboard = imresize(pattern, size(myimage), 'nearest');
myimage = immultiply(myimage logical(mycheckerboard));
Raldi il 26 Feb 2015
I am accepting this answer since it will help whoever read this to acieve what he want faster.

Accedi per commentare.

### Più risposte (1)

Image Analyst il 26 Feb 2015
Why not simply use the checkerboard() function?????
##### 3 CommentiMostra 1 commento meno recenteNascondi 1 commento meno recente
Image Analyst il 26 Feb 2015
Then I'd just create one line then use repmat twice. I would not use Image as the name of a variable since image() is the name of a built-in function.
Raldi il 26 Feb 2015
I will try both suggestions and see how they work. Thanks for your time.

Accedi per commentare.

### Categorie

Scopri di più su Geometric Transformation and Image Registration in Help Center e File Exchange

### Community Treasure Hunt

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

Start Hunting!

Translated by