ZHANG快速并行细化算法JAVA实现

上传人:我*** 文档编号:133117272 上传时间:2020-05-24 格式:PDF 页数:6 大小:64.40KB
返回 下载 相关 举报
ZHANG快速并行细化算法JAVA实现_第1页
第1页 / 共6页
ZHANG快速并行细化算法JAVA实现_第2页
第2页 / 共6页
ZHANG快速并行细化算法JAVA实现_第3页
第3页 / 共6页
ZHANG快速并行细化算法JAVA实现_第4页
第4页 / 共6页
ZHANG快速并行细化算法JAVA实现_第5页
第5页 / 共6页
点击查看更多>>
资源描述

《ZHANG快速并行细化算法JAVA实现》由会员分享,可在线阅读,更多相关《ZHANG快速并行细化算法JAVA实现(6页珍藏版)》请在金锄头文库上搜索。

1、import java awt image BufferedImage import java io BufferedWriter import java io File import java io FileWriter import java io IOException import javax imageio ImageIO import javax swing ImageIcon import javax swing JFrame import javax swing JLabel import javax swing JPanel import javax swing SwingC

2、onstants public class Image int pixel 像素 File fin new File E img before png BufferedImage bi File fout new File E img after png int width int height int minx int miny void init throws IOException bi ImageIO read fin width bi getWidth height bi getHeight minx bi getMinX miny bi getMinY System out pri

3、ntln width width height height System out println minx minx miniy miny pixel new int width height for int i minx i width i for int j miny j height j pixel i j bi getRGB i j 1 1 0 1 为白色 void ZhangThinning throws IOException init int neighbor new int 8 8 领域 int markNum 0 int mark new int width height

4、boolean loop true while loop loop false markNum 0 for int y miny 1 y 1 height y for int x minx 1 x 1 width x if pixel x y 0 continue neighbor 0 pixel x 1 y neighbor 1 pixel x 1 y 1 neighbor 2 pixel x y 1 neighbor 3 pixel x 1 y 1 neighbor 4 pixel x 1 y neighbor 5 pixel x 1 y 1 neighbor 6 pixel x y 1

5、neighbor 7 pixel x 1 y 1 条件 2 2 N p 6 int np neighbor 0 neighbor 1 neighbor 2 neighbor 3 neighbor 4 neighbor 5 neighbor 6 neighbor 7 if np 6 continue 条件 3 S p 1 int sp 0 for int i 1 i 0 for int y miny y 1 height y for int x minx x 1 width x 删除标记点 if mark x y 1 pixel x y 0 mark x y 0 bi setRGB x y 0

6、markNum 0 for int y miny 1 y 1 height y for int x minx 1 x 1 width x if pixel x y 0 continue neighbor 0 pixel x 1 y neighbor 1 pixel x 1 y 1 neighbor 2 pixel x y 1 neighbor 3 pixel x 1 y 1 neighbor 4 pixel x 1 y neighbor 5 pixel x 1 y 1 neighbor 6 pixel x y 1 neighbor 7 pixel x 1 y 1 条件 2 2 N p 6 in

7、t np neighbor 0 neighbor 1 neighbor 2 neighbor 3 neighbor 4 neighbor 5 neighbor 6 neighbor 7 if np 6 continue 条件 3 S p 1 int sp 0 for int i 1 i 0 for int y miny y height y for int x minx x width x 删除标记点 if mark x y 1 pixel x y 0 bi setRGB x y 0 ImageIO write bi png fout void show JFrame frame new JF

8、rame 细化 JPanel panel new JPanel ImageIcon img1 new ImageIcon E img before png JLabel label1 new JLabel 细化前 img1 SwingConstants LEFT panel add label1 ImageIcon img2 new ImageIcon E img after png JLabel label2 new JLabel 细化后 img2 SwingConstants LEFT panel add label2 frame setSize 700 700 frame add panel frame setVisible true param args throws IOException public static void main String args throws IOException TODO Auto generated method stub Image temp new Image temp ZhangThinning temp show

展开阅读全文
相关资源
正为您匹配相似的精品文档
相关搜索

最新文档


当前位置:首页 > 办公文档 > 教学/培训

电脑版 |金锄头文库版权所有
经营许可证:蜀ICP备13022795号 | 川公网安备 51140202000112号