天天看點

Atitit 圖像處理 公共子產品 矩陣掃描器

Atitit 圖像處理 公共子產品 矩陣掃描器

​​1.1. 調用說明對矩陣像素周遊處理調用1​​

​​2. 矩陣掃描器主題結構1​​

​​2.1. 主要說明 從像素點開始填充矩陣1​​

​​2.2. 得到模闆中心點所對應的圖像坐标2​​

​​2.3. 主題源碼2​​

1.1. 調用說明對矩陣像素周遊處理調用

List<Optional<Color>> li = mtrx.li_clr;

for(int i=0;i<li.size();i++)

{

int clrPointIdx=i;

Optional<Color> clr =li.get(i);

clr.ifPresent((p) -> {

//Integer color = clr.get();

int gray = ColorUtil.gray(p);

assignToBukeByGray(gray, p,clrPointIdx);

});

}

2. 矩陣掃描器主題結構

2.1. 主要說明 從像素點開始填充矩陣

public void fill_and_setMtrx_leftTop_XY_AllMode(int x, int y) {

this.leftTop_point=new Point(x, y);

colorLi_clrIntMod = Lists.newArrayList();

colorLi_grbInt_noOP = Lists.newArrayList();

li_clr = Lists.newArrayList();

li_hsv = Lists.newArrayList();

 li_pts= Lists.newArrayList();

this.startPos_left_x = x;

this.start_top_y = y;

for (int i = x; i < w + x; i++)

for (int j = y; j < h + y; j++) {

Point pt=new Point(i,j);

try {

int rgb = img.getRGB(i, j);

Color c=new  Color(rgb);

HSV h=ColorUtil.rgb2hsv(c);

h.x=x;h.y=y;

li_hsv.add(Optional.of(h));

li_clr.add(Optional.of(c));

//chMap.put(c, h);

} catch (ArrayIndexOutOfBoundsException e) {

li_clr.add(Optional.empty());

li_hsv.add(Optional.empty());

li_pts.add(pt);

2.2. 得到模闆中心點所對應的圖像坐标

public Point getCenterPoint() {

int x = this.startPos_left_x + w - 2;

int y = this.start_top_y + h - 2;

return new Point(x, y);

2.3. 主題源碼

/**

 *

 */

package com.attilax.img;

import java.awt.Color;

import java.awt.Point;

import java.awt.image.BufferedImage;

import java.util.List;

import java.util.Map;

import java.util.Optional;

import java.util.function.Function;

import com.attilax.ex.CantFindForgeColorEx;

import com.attilax.img.other.ColorUtil;

import com.google.common.collect.Lists;

import com.google.common.collect.Maps;

 * @author attilax 2016年11月8日 下午6:15:13

public class Matrix {

public int w;

public int h;

BufferedImage img;

List<Integer> colorLi_grbInt_noOP = Lists.newArrayList();

List<Optional<Integer>> colorLi_clrIntMod = Lists.newArrayList();

public List<Optional<Color>> li_clr = Lists.newArrayList();

public List<Optional<HSV>> li_hsv = Lists.newArrayList();

private int startPos_left_x;

private int start_top_y;

private com.attilax.lang.Function<Integer, Object> checkForgeColorFun;

private Point leftTop_point;

private int radis;

 public Matrix(int i, int j) {

w = i;

h = j;

public Matrix() {

// TODO Auto-generated constructor stub

 /**

 * attilax 2016年11月8日 下午6:41:22

 * @return

public Map getCenterXy() {

Map m = Maps.newConcurrentMap();

int x = this.startPos_left_x + w - 2;

int y = this.start_top_y + h - 2;

m.put("x", x);

m.put("y", y);

return m;

 public Point getCenterPoint() {

return new Point(x, y);

public Matrix setRadis(int i) {

 this.radis=i;

 this.w=2*i+1;

 this.h=this.w;

return this;

publicMap<Color,HSV> chMap=Maps.newConcurrentMap();

     List<Point>  li_pts= Lists.newArrayList();

作者:: 綽号:老哇的爪子 ( 全名::Attilax Akbar Al Rapanui 阿提拉克斯 阿克巴 阿爾 拉帕努伊 )