Skip to content
Snippets Groups Projects
Commit 67d8db11 authored by Thomas Oster's avatar Thomas Oster
Browse files

New Commons.net and Grid Dithering

parent f2336ad7
No related branches found
No related tags found
No related merge requests found
No preview for this file type
......@@ -18,11 +18,7 @@
**/
package com.t_oster.liblasercut;
import com.t_oster.liblasercut.dithering.Average;
import com.t_oster.liblasercut.dithering.DitheringAlgorithm;
import com.t_oster.liblasercut.dithering.FloydSteinberg;
import com.t_oster.liblasercut.dithering.Ordered;
import com.t_oster.liblasercut.dithering.Random;
import com.t_oster.liblasercut.dithering.*;
/**
*
......@@ -37,6 +33,7 @@ public class BlackWhiteRaster extends TimeIntensiveOperation
AVERAGE,
RANDOM,
ORDERED,
GRID,
}
private int width;
private int height;
......@@ -54,6 +51,8 @@ public class BlackWhiteRaster extends TimeIntensiveOperation
return new Random();
case ORDERED:
return new Ordered();
case GRID:
return new Grid();
default:
throw new IllegalArgumentException("Desired Dithering Algorithm ("+alg+") does not exist");
}
......
......@@ -29,7 +29,7 @@ import com.t_oster.liblasercut.drivers.LaosCutter;
*/
public class LibInfo
{
private static String VERSION = "1.4";
private static String VERSION = "1.5";
public static String getVersion()
{
......
/**
* This file is part of VisiCut. Copyright (C) 2011 Thomas Oster
* <thomas.oster@rwth-aachen.de> RWTH Aachen University - 52062 Aachen, Germany
*
* VisiCut is free software: you can redistribute it and/or modify it under the
* terms of the GNU Lesser General Public License as published by the Free
* Software Foundation, either version 3 of the License, or (at your option) any
* later version.
*
* VisiCut is distributed in the hope that it will be useful, but WITHOUT ANY
* WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR
* A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more
* details.
*
* You should have received a copy of the GNU Lesser General Public License
* along with VisiCut. If not, see <http://www.gnu.org/licenses/>.
*
*/
package com.t_oster.liblasercut.dithering;
/**
*
* @author Thomas Oster <thomas.oster@rwth-aachen.de>
*/
public class Grid extends DitheringAlgorithm
{
protected int blocksize = 10;
protected int blockdistance = 5;
protected void doDithering()
{
long lumTotal = 0;
int pixelcount = 0;
int width = src.getWidth();
int height = src.getHeight();
for (int y = 0; y < height; y++)
{
for (int x = 0; x < width; x++)
{
lumTotal += src.getGreyScale(x, y);
}
setProgress((100 * pixelcount++) / (2 * height));
}
int thresh = (int) (lumTotal / height / width);
for (int y = 0; y < height; y++)
{
for (int x = 0; x < width; x++)
{
if (y % (blocksize + blockdistance) <= blocksize
&& x % (blocksize + blockdistance) <= blocksize
&& src.getGreyScale(x, y) < thresh)
{
this.setBlack(x, y, true);
}
else
{
this.setBlack(x, y, false);
}
}
setProgress((100 * pixelcount++) / (2 * height));
}
}
}
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment