亚洲欧美第一页_禁久久精品乱码_粉嫩av一区二区三区免费野_久草精品视频

? 歡迎來到蟲蟲下載站! | ?? 資源下載 ?? 資源專輯 ?? 關于我們
? 蟲蟲下載站

?? entry.java

?? VHDL制作的ann的code
?? JAVA
字號:
/**
 * Introduction to Neural Networks with Java, 2nd Edition
 * Copyright 2008 by Heaton Research, Inc. 
 * http://www.heatonresearch.com/books/java-neural-2/
 * 
 * ISBN13: 978-1-60439-008-7  	 
 * ISBN:   1-60439-008-5
 *   
 * This class is released under the:
 * GNU Lesser General Public License (LGPL)
 * http://www.gnu.org/copyleft/lesser.html
 */
package org.encog.examples.neural.gui.ocr;

import java.awt.AWTEvent;
import java.awt.Color;
import java.awt.Graphics;
import java.awt.Image;
import java.awt.event.MouseEvent;
import java.awt.image.PixelGrabber;

import javax.swing.JPanel;

/**
 * Chapter 12: OCR and the Self Organizing Map
 * 
 * Entry: GUI element to allow the user to enter a character by 
 * drawing it.
 * 
 * @author Jeff Heaton
 * @version 2.1
 */
public class Entry extends JPanel {

	/**
	 * 
	 */
	private static final long serialVersionUID = 656936515012546346L;

	/**
	 * The image that the user is drawing into.
	 */
	protected Image entryImage;

	/**
	 * A graphics handle to the image that the user is drawing into.
	 */
	protected Graphics entryGraphics;

	/**
	 * The last x that the user was drawing at.
	 */
	protected int lastX = -1;

	/**
	 * The last y that the user was drawing at.
	 */
	protected int lastY = -1;

	/**
	 * The down sample component used with this component.
	 */
	protected Sample sample;

	/**
	 * Specifies the left boundary of the cropping rectangle.
	 */
	protected int downSampleLeft;

	/**
	 * Specifies the right boundary of the cropping rectangle.
	 */
	protected int downSampleRight;

	/**
	 * Specifies the top boundary of the cropping rectangle.
	 */
	protected int downSampleTop;

	/**
	 * Specifies the bottom boundary of the cropping rectangle.
	 */
	protected int downSampleBottom;

	/**
	 * The downsample ratio for x.
	 */
	protected double ratioX;

	/**
	 * The downsample ratio for y
	 */
	protected double ratioY;

	/**
	 * The pixel map of what the user has drawn. Used to downsample it.
	 */
	protected int pixelMap[];

	/**
	 * The constructor.
	 */
	Entry() {
		enableEvents(AWTEvent.MOUSE_MOTION_EVENT_MASK
				| AWTEvent.MOUSE_EVENT_MASK | AWTEvent.COMPONENT_EVENT_MASK);
	}

	/**
	 * Called to clear the image.
	 */
	public void clear() {
		this.entryGraphics.setColor(Color.white);
		this.entryGraphics.fillRect(0, 0, getWidth(), getHeight());
		this.downSampleBottom = this.downSampleTop = this.downSampleLeft = this.downSampleRight = 0;
		repaint();
	}

	/**
	 * Called to downsample the image and store it in the down sample component.
	 */
	public void downSample() {
		final int w = this.entryImage.getWidth(this);
		final int h = this.entryImage.getHeight(this);

		final PixelGrabber grabber = new PixelGrabber(this.entryImage, 0, 0, w,
				h, true);
		try {

			grabber.grabPixels();
			this.pixelMap = (int[]) grabber.getPixels();
			findBounds(w, h);

			// now downsample
			final SampleData data = this.sample.getData();

			this.ratioX = (double) (this.downSampleRight - this.downSampleLeft)
					/ (double) data.getWidth();
			this.ratioY = (double) (this.downSampleBottom - this.downSampleTop)
					/ (double) data.getHeight();

			for (int y = 0; y < data.getHeight(); y++) {
				for (int x = 0; x < data.getWidth(); x++) {
					if (downSampleRegion(x, y)) {
						data.setData(x, y, true);
					} else {
						data.setData(x, y, false);
					}
				}
			}

			this.sample.repaint();
			repaint();
		} catch (final InterruptedException e) {
		}
	}

	/**
	 * Called to downsample a quadrant of the image.
	 * 
	 * @param x
	 *            The x coordinate of the resulting downsample.
	 * @param y
	 *            The y coordinate of the resulting downsample.
	 * @return Returns true if there were ANY pixels in the specified quadrant.
	 */
	protected boolean downSampleRegion(final int x, final int y) {
		final int w = this.entryImage.getWidth(this);
		final int startX = (int) (this.downSampleLeft + (x * this.ratioX));
		final int startY = (int) (this.downSampleTop + (y * this.ratioY));
		final int endX = (int) (startX + this.ratioX);
		final int endY = (int) (startY + this.ratioY);

		for (int yy = startY; yy <= endY; yy++) {
			for (int xx = startX; xx <= endX; xx++) {
				final int loc = xx + (yy * w);

				if (this.pixelMap[loc] != -1) {
					return true;
				}
			}
		}

		return false;
	}

	/**
	 * This method is called to automatically crop the image so that whitespace
	 * is removed.
	 * 
	 * @param w
	 *            The width of the image.
	 * @param h
	 *            The height of the image
	 */
	protected void findBounds(final int w, final int h) {
		// top line
		for (int y = 0; y < h; y++) {
			if (!hLineClear(y)) {
				this.downSampleTop = y;
				break;
			}

		}
		// bottom line
		for (int y = h - 1; y >= 0; y--) {
			if (!hLineClear(y)) {
				this.downSampleBottom = y;
				break;
			}
		}
		// left line
		for (int x = 0; x < w; x++) {
			if (!vLineClear(x)) {
				this.downSampleLeft = x;
				break;
			}
		}

		// right line
		for (int x = w - 1; x >= 0; x--) {
			if (!vLineClear(x)) {
				this.downSampleRight = x;
				break;
			}
		}
	}

	/**
	 * Get the down sample component to be used with this component.
	 * 
	 * @return The down sample component.
	 */
	public Sample getSample() {
		return this.sample;
	}

	/**
	 * This method is called internally to see if there are any pixels in the
	 * given scan line. This method is used to perform autocropping.
	 * 
	 * @param y
	 *            The horizontal line to scan.
	 * @return True if there were any pixels in this horizontal line.
	 */
	protected boolean hLineClear(final int y) {
		final int w = this.entryImage.getWidth(this);
		for (int i = 0; i < w; i++) {
			if (this.pixelMap[(y * w) + i] != -1) {
				return false;
			}
		}
		return true;
	}

	/**
	 * Setup the internal image that the user draws onto.
	 */
	protected void initImage() {
		this.entryImage = createImage(getWidth(), getHeight());
		this.entryGraphics = this.entryImage.getGraphics();
		this.entryGraphics.setColor(Color.white);
		this.entryGraphics.fillRect(0, 0, getWidth(), getHeight());
	}

	/**
	 * Paint the drawn image and cropping box (if active).
	 * 
	 * @param g
	 *            The graphics context
	 */
	@Override
	public void paint(final Graphics g) {
		if (this.entryImage == null) {
			initImage();
		}
		g.drawImage(this.entryImage, 0, 0, this);
		g.setColor(Color.black);
		g.drawRect(0, 0, getWidth(), getHeight());
		g.setColor(Color.red);
		g.drawRect(this.downSampleLeft, this.downSampleTop,
				this.downSampleRight - this.downSampleLeft,
				this.downSampleBottom - this.downSampleTop);

	}

	/**
	 * Process messages.
	 * 
	 * @param e
	 *            The event.
	 */
	@Override
	protected void processMouseEvent(final MouseEvent e) {
		if (e.getID() != MouseEvent.MOUSE_PRESSED) {
			return;
		}
		this.lastX = e.getX();
		this.lastY = e.getY();
	}

	/**
	 * Process messages.
	 * 
	 * @param e
	 *            The event.
	 */
	@Override
	protected void processMouseMotionEvent(final MouseEvent e) {
		if (e.getID() != MouseEvent.MOUSE_DRAGGED) {
			return;
		}

		this.entryGraphics.setColor(Color.black);
		this.entryGraphics.drawLine(this.lastX, this.lastY, e.getX(), e.getY());
		getGraphics().drawImage(this.entryImage, 0, 0, this);
		this.lastX = e.getX();
		this.lastY = e.getY();
	}

	/**
	 * Set the sample control to use. The sample control displays a downsampled
	 * version of the character.
	 * 
	 * @param s
	 */
	public void setSample(final Sample s) {
		this.sample = s;
	}

	/**
	 * This method is called to determine ....
	 * 
	 * @param x
	 *            The vertical line to scan.
	 * @return True if there are any pixels in the specified vertical line.
	 */
	protected boolean vLineClear(final int x) {
		final int w = this.entryImage.getWidth(this);
		final int h = this.entryImage.getHeight(this);
		for (int i = 0; i < h; i++) {
			if (this.pixelMap[(i * w) + x] != -1) {
				return false;
			}
		}
		return true;
	}
}

?? 快捷鍵說明

復制代碼 Ctrl + C
搜索代碼 Ctrl + F
全屏模式 F11
切換主題 Ctrl + Shift + D
顯示快捷鍵 ?
增大字號 Ctrl + =
減小字號 Ctrl + -
亚洲欧美第一页_禁久久精品乱码_粉嫩av一区二区三区免费野_久草精品视频
jlzzjlzz欧美大全| 国产成人精品免费| 亚洲女爱视频在线| 亚洲欧洲日韩女同| 亚洲男人天堂av| 亚洲精品国产视频| 亚洲国产精品久久艾草纯爱| 亚洲免费观看高清| 亚洲制服丝袜av| 日韩专区欧美专区| 蜜臀av性久久久久蜜臀av麻豆| 日韩中文字幕亚洲一区二区va在线 | 日韩精品中文字幕一区 | 首页综合国产亚洲丝袜| 一区二区三区精品视频在线| 亚洲狠狠爱一区二区三区| 亚洲国产综合91精品麻豆| 日一区二区三区| 国产乱人伦偷精品视频不卡| 成人精品在线视频观看| 91国在线观看| 日韩亚洲电影在线| 日本一区二区三区四区| 亚洲精品国产精品乱码不99| 日韩高清不卡在线| 成人午夜激情视频| 欧美性极品少妇| 欧美成人a∨高清免费观看| 久久久91精品国产一区二区三区| 亚洲欧美一区二区三区孕妇| 日本视频一区二区三区| 高清成人免费视频| 欧美日本精品一区二区三区| 久久精品夜色噜噜亚洲a∨| 亚洲精品视频在线| 狠狠色伊人亚洲综合成人| 99精品视频一区| 日韩精品综合一本久道在线视频| 国产精品灌醉下药二区| 日韩av成人高清| 97久久人人超碰| 精品国一区二区三区| 亚洲精品乱码久久久久久久久| 玖玖九九国产精品| 色综合天天在线| 精品国产伦一区二区三区免费| 亚洲激情图片qvod| 国产精选一区二区三区| 91精品久久久久久久99蜜桃| 亚洲特级片在线| 国产一区二区久久| 91精品国产乱码久久蜜臀| 亚洲欧美日韩久久精品| 国产成人av影院| 精品国产乱码久久久久久久久| 亚洲黄色尤物视频| 成人动漫视频在线| 国产亚洲va综合人人澡精品| 免费观看在线综合色| 在线观看一区不卡| 中文字幕一区二区三区不卡在线| 国产一区欧美二区| 日韩一区二区麻豆国产| 视频一区二区欧美| 欧美日韩情趣电影| 亚洲一二三四区| 欧洲视频一区二区| 亚洲男人电影天堂| 欧洲精品视频在线观看| 一区二区三区在线播放| 99re在线精品| 亚洲男帅同性gay1069| 91丨九色丨蝌蚪丨老版| 国产精品美女久久久久久久久久久| 九九精品视频在线看| 欧美不卡激情三级在线观看| 美女国产一区二区三区| 日韩亚洲欧美在线| 久久精品国产澳门| 日韩免费视频线观看| 精品一区二区三区蜜桃| 精品电影一区二区三区| 精品亚洲国产成人av制服丝袜 | 捆绑调教一区二区三区| 日韩色在线观看| 九一九一国产精品| 国产三级精品三级| www.99精品| 一级特黄大欧美久久久| 精品视频全国免费看| 日韩精品福利网| 亚洲精品一区二区精华| 国产精品18久久久久久久久久久久| 久久久影视传媒| 成人h动漫精品一区二区| 亚洲婷婷在线视频| 欧美精品日日鲁夜夜添| 久久99久久精品欧美| 国产欧美va欧美不卡在线| eeuss鲁片一区二区三区在线看| 亚洲激情网站免费观看| 日韩免费观看高清完整版| 国产精品1区二区.| 一区二区不卡在线视频 午夜欧美不卡在 | 一区二区三区加勒比av| 欧美日韩国产乱码电影| 国产一区二区三区免费观看| 成人免费一区二区三区视频 | 色综合 综合色| 免费日韩伦理电影| 国产精品美日韩| 日韩欧美中文字幕一区| www.亚洲激情.com| 日本欧美一区二区| 综合av第一页| 精品日产卡一卡二卡麻豆| 色中色一区二区| 国产成人综合自拍| 亚洲高清在线精品| 国产精品久久久久久久久搜平片 | 91免费国产在线| 九色综合狠狠综合久久| 亚洲午夜av在线| 成人免费小视频| 2023国产精品| 欧美人体做爰大胆视频| 波多野结衣中文一区| 欧美aaaaaa午夜精品| 亚洲日本青草视频在线怡红院 | 日韩一区二区影院| 色婷婷av一区二区三区gif| 国产一区二区日韩精品| 亚洲福利国产精品| 亚洲日本va在线观看| 国产精品久线观看视频| 久久久五月婷婷| 日韩亚洲欧美高清| 91精品国产综合久久香蕉麻豆| 色先锋资源久久综合| www.亚洲色图.com| 成人一区二区三区中文字幕| 国产一区在线观看视频| 九九热在线视频观看这里只有精品| 亚洲国产成人av网| 亚洲一区在线视频| 亚洲激情图片qvod| 一区二区三区在线免费| 亚洲图片另类小说| 日韩一区在线播放| 亚洲男人都懂的| 一区二区在线观看不卡| 亚洲乱码中文字幕综合| 亚洲女与黑人做爰| 亚洲综合激情网| 亚洲成人777| 日韩精品久久久久久| 老司机午夜精品| 国产一区二区三区日韩| 国产91丝袜在线观看| 99re热这里只有精品视频| 97精品久久久午夜一区二区三区| www.日本不卡| 精品婷婷伊人一区三区三| 在线播放中文一区| 日韩欧美二区三区| 久久久久88色偷偷免费| 国产精品第13页| 亚洲福利视频一区| 精品一区二区综合| 成人午夜电影小说| 欧美性猛交xxxx黑人交| 日韩一区二区麻豆国产| 久久精品视频网| 亚洲综合激情另类小说区| 免费精品视频最新在线| 丁香激情综合国产| 91久久精品网| 欧美精品一区二| 亚洲色欲色欲www在线观看| 亚洲1区2区3区视频| 激情综合一区二区三区| 99久久精品久久久久久清纯| 日本高清无吗v一区| 日韩免费视频一区| 亚洲视频综合在线| 奇米综合一区二区三区精品视频| 国产电影精品久久禁18| 91久久久免费一区二区| 亚洲精品一区二区三区香蕉| 一区二区三区四区乱视频| 精品一二三四区| 欧美性猛交xxxx黑人交| 欧美国产精品v| 久久精品国产成人一区二区三区| 99精品热视频| 国产视频亚洲色图| 天天色图综合网| 色婷婷亚洲精品| 国产精品人人做人人爽人人添 | 中文字幕一区二区三区精华液|