2

Suppose I want to select every 10th pixel in an image, both vertically and horizontally, remove everything else, then collapse those selected pixels so they're all together.

If that's not entirely clear, here's a quick video showing it being done on physical media:

https://gfycat.com/brokencircularbeardeddragon-kensuke-koike-xiao-chi-jian-fu-george-washington

I've figured out how to do this manually by repeatedly cutting and pasting single black pixels to assemble a grid, selecting them all, returning to the image with just the selection, then copying pasting the results. But then removing the "dead" space takes a while, it's tedious, and it's error prone.

Is there a better way?

5
  • Hi. Welcome to GDSE. There's nothing in Photoshop's standard toolset that will do that automatically as far as I know. If you are a programmer, then perhaps you could write a script for it?
    – Billy Kerr
    Commented Sep 25, 2020 at 15:56
  • There are some ways, I've done this once. I think I made it in InDesign ... have to think. In the example you link to it's not just every 10th pixel, it's small squares of the image put together. Is that what you are after or the simpler pixelated approach?
    – Wolff
    Commented Sep 25, 2020 at 16:03
  • You could create a pattern layer, pattern consisting of a the squares to be removed, then easily select the pattern pixel to mask/remove them from another layer. Closing the empty space is another matter.
    – Scott
    Commented Sep 25, 2020 at 16:12
  • I just did a little experimenting and come back to see @Yorik answered what I found out. So the result is a little boring. You probably need a way to get squares of pixels.
    – Wolff
    Commented Sep 25, 2020 at 16:18
  • Affinity Photo has distortion filter which allows custom formulas which tell from which pixel the content is taken to a pixel of the filtered image. There you would write X=10*X and Y=10*Y.
    – user82991
    Commented Sep 25, 2020 at 19:05

2 Answers 2

3

As already mentioned in another answer, the method you are describing in words is just the Nearest Neighbor scaling method.

But the link you post shows another method where squares of the original image are cut out and moved together. This is a much more interesting effect.

I'll show you an example of how this can be achieved using Displace filter. In the following I'll be using a 1024 × 1024 px image. 1024 is a power of two and dividable by 128 which will show to be helpful. Actually the math is a little quirky. Everything has to be pixel-perfect and this method won't be possible with all dimensions.

Method using Displace filter

We'll use the following image by Piotr Siedlecki (CC0 Public Domain):

Original image

To make it easier to see what's going on I'll visualize the tiles. We'll divide the image in 64 × 64 px tiles:

Tiles visualized

In this example I'll show how to make an image consisting of every fourth tile:

Every second tile

The Displace filter (located at Filters > Distort > Displace) looks through each pixel in your image and moves them according to a displacement map in the form of a external PSD file.

In the Displace filter you can set a Horizontal Scale and a Vertical Scale:

Displace filter

Having the scales set to 100 means that a pixel can be moved maximally 128 px. In the displacement map, black RGB(0,0,0) will move a pixel 128 px to the right, middle gray RGB(128,128,128) will leave a pixel unaltered and white RGB(255,255,255) will move a pixel 127 px to the left (no it's not a typo).

In this example we will need to set the scales to 800 which will allow us to move pixels 8 × 128 = 1024 px. So a change of 1 in the color of a pixel on the displacement map will result in the pixel in the original moving 8 px.

First we will create a displacement map which will move the tiles horizontally.

We'll create a new image with the same dimensions as the original image and manually construct a coarse gradient with 64 px wide columns (sadly just making an automatic gradient isn't precise enough).

Horizontal displacement map

The leftmost column is RGB(0,0,0). It moves the pixels in that column the maximum amount of 8 × 128 = 1024 px. All the way across the image an back to the initial position. To the right of that we have RGB(8,8,8) which will move this column 8 × 8 = 64 px less. And so it continues.

The horizontal displacement map is applied to the original image by using Displace filter with the following settings:

Horizontal Displace filter settings

After pressing OK I'm prompted to select the PSD of the horizontal displacement map and get this result:

Horizontal displacement map applied

Vertically we do exactly the same. The vertical displacement map is just rotated 90 degrees:

Vertical displacement map

The vertical displacement map is applied to the result from before by using Displace filter with the following settings:

Vertical Displace filter settings

And now we have managed to achieve our goal:

Horizontal and vertical displacement map applied

I recommend turning the original image into a Smart Object before applying the Displace filters:

Smart Object

This enables you to quickly apply the same effect to other images (with the same dimensions) simply by entering the Smart Object and paste in another image.

Offsetting the tiles

The result we achieved only uses uneven numbered tiles. If you want to use even numbered tiles instead you can simply add an Filter > Other > Offset filter which moves the image before applying the effect:

Offset filter

This will give you an alternative result:

Offset applied

Further displacement

It's actually possible to duplicate the two Displace filters to reduce the number of tiles once more:

Duplicated Displace filters

But sadly it comes with an unpleasing pixel shift I don't quite understand:

Duplicated Displace filters applied

It can easily be countered by inserting an Offset filter between the two sets of Displace filters:

Offset filter

Offset applied

Limitations

The image we produced here isn't very large. The scale of the Displace filter could be increased to 975. Additionally we could let the displacement map continue past middle gray an into the lighter shades so we instead of just moving pixels in one direction moved them in both directions towards the middle. In that case we would be able to process an 2496 × 2496 px image and the result would be an 1248 × 1248 px image. That is about the largest we can ever get using this method.

1
  • I haven't tried it yet but that sure looks like what I'm trying to accomplish. Thanks! Commented Sep 28, 2020 at 11:58
0

This is "nearest neighbor". Just reduce the size to 10% of original with "nearest neighbor" resampling.

Note that the example shown is not the equivalent of every 10th pixel, but more like a block of 10x10 pixels every 50th.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.