# 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;

//chMap.put(c, h);

} catch (ArrayIndexOutOfBoundsException e) {

}

}

}

## 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;

/**

* @author attilax 2016118日 下午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;

public Matrix(int i, int j) {

w = i;

h = j;

}

public Matrix() {

// TODO Auto-generated constructor stub

}

/**

* attilax 2016118日 下午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() {

int x = this.startPos_left_x + w - 2;

int y = this.start_top_y + h - 2;

return new Point(x, y);

}

public Matrix setRadis(int i) {

this.w=2*i+1;

this.h=this.w;

return this;

}

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

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

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;

//chMap.put(c, h);

} catch (ArrayIndexOutOfBoundsException e) {

}

}

}

}

Atiend

posted @ 2016-11-12 18:27  attilaxAti  阅读(5)  评论(0编辑  收藏  举报