Java Code Examples for com.juankysoriano.rainbow.core.graphics.RainbowImage#get()
The following examples show how to use
com.juankysoriano.rainbow.core.graphics.RainbowImage#get() .
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: EdgeDetector.java From rainbow with GNU Lesser General Public License v3.0 | 6 votes |
public List<RVector> extractPoints(RainbowImage img) { List<RVector> vertices = new ArrayList<>(); int col = 0, colSum = 0, W = img.width - 1, H = img.height - 1; // For any pixel in the image excepting borders for (int Y = 1; Y < H; Y += step) { for (int X = 1; X < W; X += step, colSum = 0) { // Convolute surrounding pixels with desired operator for (int y = -1; y <= 1; y++) { for (int x = -1; x <= 1; x++, col = img.get((X + x), (Y + y))) { colSum += OPERATOR[op][x + 1][y + 1] * ((col >> 16 & 0xFF) + (col >> 8 & 0xFF) + (col & 0xFF)); } } // And if the resulting sum is over the treshold add pixel // position to the list if (RainbowMath.abs(colSum) > treshold) { vertices.add(new RVector(X, Y)); } } } return vertices; }
Example 2
Source File: GameOfLifeDrawer.java From MaterialLife with GNU General Public License v2.0 | 5 votes |
int getCellStateFrom(RainbowImage image, int cellX, int cellY) { int color = image.get(cellX * SCALE_FACTOR, cellY * SCALE_FACTOR); int red = (int) rainbowDrawer.red(color); int green = (int) rainbowDrawer.green(color); int blue = (int) rainbowDrawer.blue(color); int grey = (red + green + blue) / THREE; return grey < ALIVE_CELL_THRESHOLD ? GameOfLife.DEAD : GameOfLife.ALIVE; }