I've created a web version of this app using p5.js and React and am shifting focus to that version.
You can check it out here: cheezwhiz.biz
Or check out the repo here: https://github.com/connordelacruz/react-p5-channel-shift
This Processing sketch provides a GUI interface for datamoshing images by manipulating RGB color channels.
The basic features of this tool allow you to shift color channels vertically and horizontally, as well as swap color channels with each other:
It also includes experimental shift types that modify how pixels are shifted, which can be combined for interesting effects:
This sketch requires Processing 3+ (tested using Processing 3.5).
After installing Processing 3, clone the repo:
git clone https://github.com/connordelacruz/ChannelShiftGUI.git
This sketch uses the G4P GUI library, which is included in this repo, so no additional setup is required.
Swap the selected channel from the source image with the selected channel from the target image.
Shift the selected source image channel horizontally and/or vertically on the target image.
Use the target image as the source for subsequent iterations.
Target channel, source channel, horizontal shift, and vertical shift can all be randomized. You can select/deselect which options to randomize, as well as set a max threshold for vertical and horizontal shift amounts.
By default, horizontal and vertical shifts translate the color channel along the x and y axes, respectively. You can also select experimental shift types with their own advanced options that modify how each pixel is shifted based on a number of conditions in addition to the horizontal/vertical shift amounts.
For explanations and examples of each type, see Experimental Shift Types.
Selects the color channel from the source image to be shifted.
Selects the color channel from the result image to swap the source channel with. If you don't want to swap channels, set this to the same option as the source channel.
The horizontal and vertical shift sliders offset the selected source channel along the X and Y axis, respectively.
By default, both sliders use percentage values. If you want to set an exact pixel distance to shift by, select the Pixels option to the right of the slider.
You can also set the shift value manually using the text input to the left of the sliders.
The Randomize Options panel is used to randomize the current step.
By default, all options are randomized. You can uncheck the boxes of any options you do not want to randomize.
The Max Horizontal/Vertical Shift % inputs can be used to put a limit on the randomized shift values. For example, setting Max Horizontal Shift % to 10 will only result in random horizontal shift values of 10% of the image width or less.
Note: that neither of these inputs will have any effect if the corresponding Horizontal/Vertical Shift checkbox is unchecked.
To commit the current channel shift step, click the Confirm Step button. This will update the working image to match the preview and reset all configurations so you can apply another step.
If the Recursive checkbox is checked upon clicking the confirm button, the source image pixels will be updated to match the shifted image, so further channel shifts/swaps will be applied based on the shifted image instead of the original image. Otherwise, further channel shifts/swaps will be based on the original channels.
To revert the current step to the default, click the Reset Step button. Note that this will not affect any previously confirmed steps.
To save the current result shown in the preview window, click the Save Result button. This will bring up the system "Save As" dialog.
To load a source image, click the Load Image button and select the desired image file. Note that this will clear the current result, so be sure to save it before loading if you don't want to lose your work.
The advanced options panel allows you to select the shift type and has configurations specific to each one. The default shift type has no advanced options, but selecting an experimental shift type from the dropdown will show its specific settings in this panel. See the following section for details on each experimental shift type.
The following section describes the different experimental shift types in the Advanced Options panel, as well as the way each pixel's horizontal and vertical shift is calculated.
Scales the width and length of the channel by the specified multiplier. Multipliers greater than 1.0 shrink the image dimension and create a tiling effect. Multipliers less than 1.0 scale the image dimension up.
- Horizontal Shift Multiplier: Value to multiply the width by
- Vertical Shift Multiplier: Value to multiply the height by
(coordinate * multiplier) + shift
Where:
coordinate
: x if horizontal, y if verticalmultiplier
: the configured horizontal/vertical shift multipliershift
: the horizontal/vertical shift amount
Uses a linear equation to calculate shift offset.
- Equation Type: select whether the linear equation format is y=mx+b or x=my+b
- Slope (m): the slope of the linear equation
- Negative Slope: if checked, multiply slope (m) by -1
Calculations for x/y offset are determined by solving the equation for x/y, respectively.
Horizontal Offset:
x + (int)((y - shift) / (mSign * m))
Vertical Offset:
y + (int)((mSign * m) * x + shift)
Where:
x
andy
: the coordinates of the pixelshift
: the horizontal/vertical shift amountm
: the configured slopemSign
: 1 if positive slope, -1 if negative slope
Horizontal Offset:
x + (int)((mSign * m) * y + shift)
Vertical Offset:
y + (int)((x - shift) / (mSign * m))
Where:
x
andy
: the coordinates of the pixelshift
: the horizontal/vertical shift amountm
: the configured slopemSign
: 1 if positive slope, -1 if negative slope
Skew/shear the channel.
- Horizontal/Vertical Skew: the amount to skew along the x/y axis
- Negative X/Y Skew: if checked, invert the skew direction along the corresponding axis
Horizontal Offset:
x + shift + (int)(xSign * xSkew * y)
Vertical Offset:
y + shift + (int)(ySign * ySkew * x)
Where:
x
andy
: the coordinates of the pixelshift
: the horizontal/vertical shift amountxSkew
andySkew
: the horizontal and vertical skew amounts, respectivelyxSign
andySign
: 1 if positive skew, -1 if negative for the corresponding dimension
Multiply the x/y coordinates of a pixel and divide it by the corresponding dimension, so the shift modifier becomes more drastic for one dimension as the other dimension increases. (Kind of a weird one, leads to some cool results. Recommend playing around with different configurations)
- x shift + (x*y/height): if checked, add x*y/height to horizontal shift
- y shift + (y*x/width): if checked, add y*x/width to vertical shift
- Negative X/Y Coefficient: if checked, multiply the corresponding coordinate's shift modifier by -1
Horizontal Offset:
If x shift + (x*y/height): is checked:
x + shift + (int)(xSign*x*y / height)
(otherwise it's just x + shift
)
Vertical Offset:
If y shift + (y*x/width): is checked:
y + shift + (int)(ySign*y*x / width)
(otherwise it's just y + shift
)
Where:
x
andy
: the coordinates of the pixelshift
: the horizontal/vertical shift amountxSign
andySign
: 1 if positive coefficient, -1 if negative for the corresponding dimension
Apply Perlin noise to the shift amount.
- X Start: Starting value for x noise
- Y Start: Starting value for y noise
- X Step: Amount to increment x by each time
noise()
is called. Use a smaller number for smoother results - Y Step: Amount to increment y by each time
noise()
is called. Use a smaller number for smoother results - Noise Multiplier: Value to multiply result of
noise()
by. Higher values create more drastic effects
Horizontal Offset:
x + shift + (int)(noiseMultiplier * noise(xNoise, yNoise))
Vertical Offset:
y + shift + (int)(noiseMultiplier * noise(xNoise, yNoise))
Where:
x
andy
: the coordinates of the pixelshift
: the horizontal/vertical shift amountnoiseMultiplier
: the noise multiplier valuexNoise
andyNoise
: noise coordinates, calculated by adding offset to start value each time the corresponding coordinate (x
ory
) is incremented