Skip to content

Commit

Permalink
GMIC's "Huffman Glitches" filter (#342)
Browse files Browse the repository at this point in the history
  • Loading branch information
LinuxBeaver authored Jan 7, 2024
1 parent 777dd99 commit 33865d0
Show file tree
Hide file tree
Showing 2 changed files with 68 additions and 0 deletions.
66 changes: 66 additions & 0 deletions src/main/java/pixelitor/filters/gmic/HuffmanGlitches.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,66 @@
package pixelitor.filters.gmic;

import java.io.Serial;
import java.util.List;
import pixelitor.filters.gui.BooleanParam;
import pixelitor.filters.gui.ColorParam;
import pixelitor.filters.gui.IntChoiceParam;
import pixelitor.filters.gui.IntChoiceParam.Item;
import pixelitor.filters.gui.RangeParam;

public class HuffmanGlitches extends GMICFilter {
@Serial
private static final long serialVersionUID = 1L;

public static final String NAME = "Huffman Glitches";

private final RangeParam noiseLevel = new RangeParam("Noise Level", 0, 30, 100);
private final IntChoiceParam splitMode = new IntChoiceParam("Split Mode", new Item[] {
new Item("None", 0),
new Item("Horizontal Blocs", 1),
new Item("Vertical Blocs", 2),
new Item("Patches", 3)
});
private final RangeParam blocSize = new RangeParam("Bloc Size", 0, 25, 100);
private final RangeParam patchOverlap = new RangeParam("Patch Overlap", 0, 0, 50);
private final IntChoiceParam colorSpace = new IntChoiceParam("Color Space", new Item[] {
new Item("RGB", 0),
new Item("CMYK", 1),
new Item("HCY", 2),
new Item("HSI", 3),
new Item("HSL", 4),
new Item("HSV", 5),
new Item("Jzazbz", 6),
new Item("Lab", 7),
new Item("Lch", 8),
new Item("OKLab", 9),
new Item("YCbCr", 10),
new Item("YIQ", 11)
});
private final RangeParam quantization = new RangeParam("Quantization", 0, 0, 64);
private final RangeParam randomSeed = new RangeParam("Random Seed", 0, 0, 65536);

public HuffmanGlitches() {
setParams(
noiseLevel,
splitMode,
blocSize,
patchOverlap,
colorSpace,
quantization
).withReseedGmicAction(this);
}

@Override
public List<String> getArgs() {
return List.of("fx_huffman_glitches",
noiseLevel.getValue() + "," +
splitMode.getValue() + "," +
blocSize.getValue() + "," +
patchOverlap.getValue() + "," +
colorSpace.getValue() + "," +
quantization.getValue() + "," +
seed
);
}
}
2 changes: 2 additions & 0 deletions src/main/java/pixelitor/menus/MenuBar.java
Original file line number Diff line number Diff line change
Expand Up @@ -979,6 +979,8 @@ private static JMenu createGMICArtistictSubmenu() {
sub.addFilter(Brushify.NAME, Brushify::new);
sub.addFilter(Cubism.NAME, Cubism::new);
sub.addFilter(Rodilius.NAME, Rodilius::new);
sub.addFilter(HuffmanGlitches.NAME, HuffmanGlitches::new);


return sub;
}
Expand Down

0 comments on commit 33865d0

Please sign in to comment.