Atitit 图像处理 公共模块 矩阵扫描器

时间:2022-06-16 00:47:22

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() {

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.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();

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

}

}

}

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

汉字名:艾提拉(艾龙),   EMAIL:1466519819@qq.com

转载请注明来源: http://www.cnblogs.com/attilax/

Atiend