use of ij.process.ByteProcessor in project imagingbook-common by imagingbook.
the class KMeansClusteringQuantizer method main.
// ----------------------------------------------------------------------
public static void main(String[] args) {
// String path = "D:/svn-book/Book/img/ch-color-images/alps-01s.png";
// String path = "D:/svn-book/Book/img/ch-color-images/desaturation-hsv/balls.jpg";
String path = "C:/_SVN/svn-book/Book/img/ch-color-images/desaturation-hsv/balls.jpg";
// String path = "D:/svn-book/Book/img/ch-color-images/single-color.png";
// String path = "D:/svn-book/Book/img/ch-color-images/two-colors.png";
// String path = "D:/svn-book/Book/img/ch-color-images/random-colors.png";
// String path = "D:/svn-book/Book/img/ch-color-images/ramp-fire.png";
int K = 16;
System.out.println("image = " + path);
System.out.println("K = " + K);
ImagePlus im = IJ.openImage(path);
if (im == null) {
System.out.println("could not open: " + path);
return;
}
ImageProcessor ip = im.getProcessor();
ColorProcessor cp = ip.convertToColorProcessor();
Parameters params = new Parameters();
params.maxColors = K;
ColorQuantizer quantizer = new KMeansClusteringQuantizer(cp, params);
quantizer.listColorMap();
System.out.println("quantizing image");
ByteProcessor qi = quantizer.quantize(cp);
System.out.println("showing image");
(new ImagePlus("quantizez", qi)).show();
}
use of ij.process.ByteProcessor in project imagingbook-common by imagingbook.
the class MedianCutQuantizer method main.
// ----------------------------------------------------------------------
public static void main(String[] args) {
// String path = "D:/svn-book/Book/img/ch-color-images/alps-01s.png";
String path = "D:/svn-book/Book/img/ch-color-images/desaturation-hsv/balls.jpg";
// String path = "D:/svn-book/Book/img/ch-color-images/single-color.png";
// String path = "D:/svn-book/Book/img/ch-color-images/two-colors.png";
// String path = "D:/svn-book/Book/img/ch-color-images/random-colors.png";
// String path = "D:/svn-book/Book/img/ch-color-images/ramp-fire.png";
int K = 16;
System.out.println("image = " + path);
System.out.println("K = " + K);
ImagePlus im = IJ.openImage(path);
if (im == null) {
System.out.println("could not open: " + path);
return;
}
ImageProcessor ip = im.getProcessor();
ColorProcessor cp = ip.convertToColorProcessor();
MedianCutQuantizer quantizer = new MedianCutQuantizer(cp, K);
quantizer.listColorMap();
System.out.println("quantizing image");
ByteProcessor qi = quantizer.quantize(cp);
System.out.println("showing image");
(new ImagePlus("quantizez", qi)).show();
}
use of ij.process.ByteProcessor in project imagingbook-common by imagingbook.
the class Dft2d method makePowerImage.
public ByteProcessor makePowerImage() {
ByteProcessor ip = new ByteProcessor(width, height);
byte[] pixels = (byte[]) ip.getPixels();
// PowerMax must be set
double max = Math.log(PowerMax + 1.0);
double scale = 1.0;
if (scaleValue > 0)
scale = scaleValue / max;
for (int i = 0; i < pixels.length; i++) {
double p = Power[i];
if (p < 0)
p = -p;
double plog = Math.log(p + 1.0);
int pint = (int) (plog * scale);
pixels[i] = (byte) (0xFF & pint);
}
if (swapQu)
swapQuadrants(ip);
return ip;
}
use of ij.process.ByteProcessor in project imagingbook-common by imagingbook.
the class IjUtilsTest method testByteArrayReadWrite.
@Test
public void testByteArrayReadWrite() {
ByteProcessor bp1 = makeRandomByteProcessor(W, H);
byte[][] A = IjUtils.toByteArray(bp1);
ByteProcessor bp2 = IjUtils.toByteProcessor(A);
assertTrue(ImageTests.match(bp1, bp2));
}
use of ij.process.ByteProcessor in project imagingbook-common by imagingbook.
the class ColorEdgeDetector method getRgbFloatChannel.
FloatProcessor getRgbFloatChannel(ColorProcessor cp, int c) {
// c = 0,1,2
int w = cp.getWidth();
int h = cp.getHeight();
// numbered from 1,...,3!
ByteProcessor bp = new ByteProcessor(w, h, cp.getChannel(c + 1));
return bp.convertToFloatProcessor();
}
Aggregations