本文整理汇总了Java中ij.process.ByteProcessor.putPixel方法的典型用法代码示例。如果您正苦于以下问题:Java ByteProcessor.putPixel方法的具体用法?Java ByteProcessor.putPixel怎么用?Java ByteProcessor.putPixel使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类ij.process.ByteProcessor
的用法示例。
在下文中一共展示了ByteProcessor.putPixel方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: process
import ij.process.ByteProcessor; //导入方法依赖的package包/类
private void process(ImageProcessor ip) {
ByteProcessor check = new ByteProcessor(M, N);
if (params.showProgress) IJ.showStatus("filling accumulator ...");
for (int v = 0; v < N; v++) {
if (params.showProgress) IJ.showProgress(v, N);
for (int u = 0; u < M; u++) {
if ((0xFFFFFF & ip.get(u, v)) != 0) { // this is a foreground (edge) pixel - use ImageAccessor??
doOnePoint(u, v);
check.putPixel(u, v, 128);
}
}
}
if (params.showProgress)
IJ.showProgress(1, 1);
if (params.showCheckImage)
(new ImagePlus("Check", check)).show();
}
示例2: trin
import ij.process.ByteProcessor; //导入方法依赖的package包/类
/**
* Double thresholding
*
* @param ima original image
* @param T1 high threshold
* @param T2 low threshold
* @return "trinarised" image
*/
ImageProcessor trin(ImageProcessor ima, float T1, float T2) {
int la = ima.getWidth();
int ha = ima.getHeight();
ByteProcessor res = new ByteProcessor(la, ha);
float pix;
for (int x = 0; x < la; x++) {
for (int y = 0; y < ha; y++) {
pix = ima.getPixelValue(x, y);
if (pix >= T1) {
res.putPixel(x, y, 255);
} else if (pix >= T2) {
res.putPixel(x, y, 128);
}
}
}
return res;
}
示例3: run
import ij.process.ByteProcessor; //导入方法依赖的package包/类
public void run(final ByteProcessor ip) {
final int[][] pixels = {
{19, 15, 22, 1, 5, 7},
{24, 31, 28, 9, 11, 23},
{21, 24, 24, 21, 23, 14},
{23, 25, 14, 23, 8, 8},
{22, 24, 6, 15, 16, 7},
{23, 25, 5, 13, 17, 3}
};
for (int y = 0; y < M; ++y) {
System.arraycopy(pixels[y], 0, ix[y], 0, N);
}
fast_median();
for (int y = 0; y < 1; ++y) {
for (int x = 0; x < 1; ++x) {
ip.putPixel(x, y, iout[y][x]);
}
}
}
示例4: deleteMarked
import ij.process.ByteProcessor; //导入方法依赖的package包/类
private void deleteMarked (ByteProcessor ip, byte[][] D) {
int w = ip.getWidth();
int h = ip.getHeight();
for (int u = 0; u < w; u++) {
for (int v = 0; v < h; v++) {
if (D[u][v] > 0) {
ip.putPixel(u, v, 0);
}
}
}
}
示例5: encodeSegmentedImage
import ij.process.ByteProcessor; //导入方法依赖的package包/类
static ByteProcessor encodeSegmentedImage(final VectorProcessor vp, final float[][] clusterCenters) {
// Encode output image
final ByteProcessor dest = new ByteProcessor(vp.getWidth(), vp.getHeight());
final VectorProcessor.PixelIterator iterator = vp.pixelIterator();
while (iterator.hasNext()) {
final float[] v = iterator.next();
final int c = KMeansUtils.closestCluster(v, clusterCenters);
dest.putPixel(iterator.getX(), iterator.getY(), c);
}
return dest;
}
示例6: getThreshold
import ij.process.ByteProcessor; //导入方法依赖的package包/类
@Override
public ByteProcessor getThreshold(ByteProcessor ip) {
final int W = ip.getWidth();
final int H = ip.getHeight();
final int tileSize = params.tileSize;
// determine number of tiles
int nW = (W % tileSize == 0) ? (W / tileSize + 1) : (W / tileSize + 2);
int nH = (H % tileSize == 0) ? (H / tileSize + 1) : (H / tileSize + 2);
int[][] tiles = new int[nW][nH];
int s0 = tileSize / 2; // center of title (s0 + s1 = tileSize)
// int s1 = tileSize - s0;
// compute threshold for each tile
int[] h = new int[256];
OtsuThresholder thr = new OtsuThresholder();
int q_ = (params.bgMode == BackgroundMode.DARK) ? 256 : 0;
for (int j = 0, v0 = 0; j < nH; j++, v0 += tileSize) {
for (int i = 0, u0 = 0; i < nW; i++, u0 += tileSize) {
getSubimageHistogram(ip, u0 - s0, v0 - s0, tileSize, h);
int q = thr.getThreshold(h);
if (q < 0) q = q_; // no threshold found in this tile
tiles[i][j] = q;
//IJ.log(i + "/" + j + ": " + q);
}
}
ByteProcessor thrIp = new ByteProcessor(W, H);
for (int j = 0, v0 = 0; j < nH; j++, v0 += tileSize) {
for (int i = 0, u0 = 0; i < nW; i++, u0 += tileSize) {
// Rectangle re = new Rectangle(u0-s0, v0-s0, u0-s0+tileSize, v0-s0+tileSize);
for (int v = v0 - s0; v < v0 - s0 + tileSize; v++) {
for (int u = u0 - s0; u < u0 - s0 + tileSize; u++) {
thrIp.putPixel(u, v, tiles[i][j]);
}
}
}
}
// linearly interpolate
for (int j = 0, v0 = 0; j < nH - 1; j++, v0 += tileSize) {
for (int i = 0, u0 = 0; i < nW - 1; i++, u0 += tileSize) {
int A = tiles[i][j];
int B = tiles[i + 1][j];
int C = tiles[i][j + 1];
int D = tiles[i + 1][j + 1];
// interpolate within [u0, v0, u0 + tileSize, v0 + tileSize]
for (int v = v0; v < v0 + tileSize; v++) {
double dy = (double) (v - v0) / tileSize;
double AC = A + dy * (C - A);
double BD = B + dy * (D - B);
for (int u = u0; u < u0 + tileSize; u++) {
double dx = (double) (u - u0) / tileSize;
double ABCD = AC + dx * (BD - AC);
// thrIp.putPixel(u,v,tiles[i][j]);
thrIp.putPixel(u, v, (int) Math.rint(ABCD));
}
}
}
}
return thrIp;
}