Repeat only selected region of an image jit.gl.pix

Noah Mitchell's icon

Hello,

I'm trying to figure out how to sample only select pixels within jit.gl.pix

Say I want to use an snorm scaled up to have a repeat effect, but I only want the to happen with a certain part of the image not to take the whole part of the image.

Can I repeat only a select part of the image using a sample parameter...or is there another simpler way to do this?

Matteo Marson's icon

Hey Noah,

something like this might work:

Max Patch
Copy patch and select New From Clipboard in Max.

Noah Mitchell's icon

that's a cool patch...not exactly what I'm looking for though.

Here's an easier way to explain. Say I'm using a mask on an image and only want the masked part of the image repeated. In your patch the entire image is still getting repeated

MakePatchesNotWar's icon

Like so?

Max Patch
Copy patch and select New From Clipboard in Max.

Rob Ramirez's icon

Matteo's example does exactly what you are describing, you just need to adjust the rsliders to define the masked part of the image.

dunk's icon

Hi there. These patches have been a real help. I'm keen to enact a mirror repeat on the cropped & zoomed area but I'm struggling with how the right inlet of 'sample' works. Any tips greatly appreciated.

Zoom_Crop_Repeat02.maxpat
Max Patch

Matteo Marson's icon

Hi Dunk,

the right inlet of [sample] takes a 2-component vector representing the normalized position (aka between 0 and 1) at which the image coming into the first inlet is sampled.
The attribute @boundmode affects the sampling coordinates ONLY when they exceed the range [0, 1].
Some examples:
given input sampling coordinates x = -0.1 and y = 1.3
@boundmode wrap (default) -> x = 0.9; y = 0.3
@boundmode clamp -> x = 0; y = 1
@boundmode mirror -> x = 0.1; y = 0.7

Since your patch samples a subregion of the original video, the sampling coordinates never exceed the range [0, 1].
If you want to have mirrored sampling, you must implement it manually. This could be a way to go:

Max Patch
Copy patch and select New From Clipboard in Max.

dunk's icon

Aha. This is starting to make much more sense. The second output is is a great help. Thanks so much for the response.