This project is a Java Maven application built using NetBeans IDE and Swing that applies the effect of halftone to an image, with dots, lines or sine waves as the pattern. This code uses a codebase from my other project to separate the CMYK/RGB colors.
|
|
- Apply Halftone Effect
- Patterns:
Dots,Polygons,Triangles,Stippling,Lines,Sine Waves.
- Patterns:
- Full CMYK/RGB Processing
- Separates image into CMYK/RGB channels, applies halftone at predetermined angles, and merges using multiply/screen blend.
- Drag & Drop Support
- Simply drag images into the interface to process them.
- Interactive Controls
- Adjust halftone scale (0–100) and angle (0°–360°) via sliders for live preview.
- Batch Processing
- Drop multiple images at once; each will be processed and automatically saved.
-
Open the Application
- Double-click
Halftone.jar, or run:java -jar Halftone.jar
- Double-click
-
Configure Settings
- Pattern: Choose between Dots, Squares, Triangles, Lines or Sine Waves.
- Scale Slider: Adjust the size of the halftone elements (0 = minimum, 100 = maximum).
- Angle Slider: Define the angle of the halftone pattern (0°–360°).
- Color Mode: Choose between Default, CMYK or RGB for color processing.
-
Drag & Drop
- Drag one or more images (JPEG, PNG, JPG) directly into the window.
-
Preview and Save
- A live preview will display the result.
- To save, click Save or close the window. Processed images are saved in the same folder as the originals with this pattern:
originalname_Halftone[type;scale;angle].png - Example:
cameraman_Halftone[Lines;50;45.0].png
Below is a high-level overview of the halftone algorithm (example based on line/sine patterns):
-
Kernel Generation
- Divide the image into square blocks (“kernels”), each rotated by the chosen angle.
- For each kernel, sum up the RGB values and compute the average.
To better understand the logic behind the kernels try out my kernel simulator!
-
Luminance Calculation
- Within each kernel, convert the average color to luminance.
- Determine a center point and compute two offset points based on luminance, constrained to half the kernel size.
-
Polygon Filling
- Negative offsets define the top of a polygon, positive offsets define the bottom.
- Connect these points along each row to create a complex shape that follows the image’s contours at the given angle.
-
CMYK/RGB Processing (Optional)
- When CMYK/RGB mode is enabled, repeat steps 1–3 for each channel using fixed angles (e.g., CMYK(15°, 75°, 0°, 45°) or RGB(0º, 60º, 120º).
- Finally, blend all channels using a multiply/screen operation to obtain the full-color halftone result.
Angles:
Wave crosshatching:
Stippling:
Overlaying halftones at opposing angles to create a cross-hatching effect, by adding some rotation and spacing error we can mimic a hand made pattern. This effect can be further enhanced by generating an outline (e.g., with Extended Difference of Gaussians).
|
|

















