In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-01-16 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Development >
Share
Shulou(Shulou.com)06/02 Report--
This article mainly explains the "JAVA graying and binary picture method is what", the article explains the content is simple and clear, easy to learn and understand, the following please follow the editor's ideas slowly in-depth, together to study and learn "JAVA graying and binary picture method is what" it!
Package image; import java.awt.image.BufferedImage; import java.io.File; import java.io.IOException; import javax.imageio.ImageIO; public class ImageDemo {public void binaryImage () throws IOException {File file = new File (System.getProperty ("user.dir") + "/ src/2722425974762424026.jpg"); BufferedImage image = ImageIO.read (file); int width = image.getWidth (); int height = image.getHeight () BufferedImage grayImage = new BufferedImage (width, height, BufferedImage.TYPE_BYTE_BINARY); for (int I = 0; I
< width ; i++){ for(int j = 0 ; j < height; j++){ int rgb = image.getRGB(i, j); grayImage.setRGB(i, j, rgb); } } File newFile = new File(System.getProperty("user.dir")+"/src/2722425974762424028.jpg"); ImageIO.write(grayImage, "jpg", newFile); } public void grayImage() throws IOException{ File file = new File(System.getProperty("user.dir")+"/src/2722425974762424026.jpg"); BufferedImage image = ImageIO.read(file); int width = image.getWidth(); int height = image.getHeight(); BufferedImage grayImage = new BufferedImage(width, height, BufferedImage.TYPE_BYTE_GRAY); for(int i= 0 ; i < width ; i++){ for(int j = 0 ; j < height; j++){ int rgb = image.getRGB(i, j); grayImage.setRGB(i, j, rgb); } } File newFile = new File(System.getProperty("user.dir")+"/src/2722425974762424027.jpg"); ImageIO.write(grayImage, "jpg", newFile); } public static void main(String[] args) throws IOException { ImageDemo demo = new ImageDemo(); demo.binaryImage(); demo.grayImage(); } } 主要就是BufferedImage.TYPE.BYTE.GRAY灰度化,BufferedImage.TYPE.BYTE.BINARY二值化 原图:Grayed out picture:
Image after binarization:
Thank you for your reading, the above is the "JAVA graying and binary picture method is what" the content, after the study of this article, I believe you on the JAVA graying and binary picture method is what this problem has a deeper understanding, the specific use of the situation also needs to be verified in practice. Here is, the editor will push for you more related knowledge points of the article, welcome to follow!
Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.
Views: 0
*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.
Continue with the installation of the previous hadoop.First, install zookooper1. Decompress zookoope
"Every 5-10 years, there's a rare product, a really special, very unusual product that's the most un
© 2024 shulou.com SLNews company. All rights reserved.