本文介绍了Java中的图像分割库的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧! 问题描述 我正在开发一个项目,其中包括通过计算机阅读图表的程序。我需要进行图像分割,以便识别图像输入中的形状及其位置。我的教授说我可以使用任何公共图像分割库来做到这一点。 有没有可以达到此目的的好图像分割库? 非常感谢解决方案例如,在JAVA中,这些工具提供了许多图像分割算法: ImageJ 侵蚀后: 结果: 源代码: import static marvin.MarvinPluginCollection。 *; 公共类SegmentDiagram { public SegmentDiagram(){ MarvinImage originalImage = MarvinImageIO.loadImage(./ res / diagram.png); MarvinImage image = originalImage.clone(); MarvinImage binImage = MarvinColorModelConverter.rgbToBinary(image,250); morphologicalErosion(binImage.clone(),binImage,MarvinMath.getTrueMatrix(5,5)); image = MarvinColorModelConverter.binaryToRgb(binImage); MarvinSegment [] segments = floodfillSegmentation(image); for(int i = 1; i< segments.length; i ++){ MarvinSegment seg = segments [i]; originalImage.drawRect(seg.x1,seg.y1,seg.width,seg.height,Color.red); originalImage.drawRect(seg.x1 + 1,seg.y1 + 1,seg.width,seg.height,Color.red); } MarvinImageIO.saveImage(originalImage,./ are / diagram_segmented.png); } public static void main(String [] args){ new SegmentDiagram(); } } 形状识别是另一个话题,已在Stack上讨论过溢出: 2D形状识别算法 - 寻找指导 I am working on a project which consist of a procedure of "reading diagram by computer"I will need to do image segmentation in order to identify the shapes and their locations in the image input. My professor said that I can use any public image segmentation library to do it.Is there any good image segmentation library which can serve this purpose?thanks a lot 解决方案 In JAVA for example these tools provide many algorithms for image segmentation:ImageJhttp://rsbweb.nih.gov/ij/Fijihttp://fiji.sc/wiki/index.php/FijiRapidminer IMMIhttp://www.burgsys.com/image-miningMarvin Frameworkhttp://marvinproject.sourceforge.net/COMPLEMENTEven being generic, I think it is possible to answer this question in some sense. Since this question is closed, I gonna complement @radim-burget answer for those people that get here looking for a simple example of image segmentation in Java.Image Segmentation is an image processing task and is handled by most image processing frameworks. In the example below I'm using Marvin Framework.Algorithm to segment diagram elements:Load image and binarizeApply morphological erosion to remove lines, texts, etcApply floodfill segmentation to get segmentsDraw the segments in the original image.Input:After Erosion:Result:Source Code:import static marvin.MarvinPluginCollection.*;public class SegmentDiagram { public SegmentDiagram(){ MarvinImage originalImage = MarvinImageIO.loadImage("./res/diagram.png"); MarvinImage image = originalImage.clone(); MarvinImage binImage = MarvinColorModelConverter.rgbToBinary(image, 250); morphologicalErosion(binImage.clone(), binImage, MarvinMath.getTrueMatrix(5, 5)); image = MarvinColorModelConverter.binaryToRgb(binImage); MarvinSegment[] segments = floodfillSegmentation(image); for(int i=1; i<segments.length; i++){ MarvinSegment seg = segments[i]; originalImage.drawRect(seg.x1, seg.y1, seg.width, seg.height, Color.red); originalImage.drawRect(seg.x1+1, seg.y1+1, seg.width, seg.height, Color.red); } MarvinImageIO.saveImage(originalImage, "./res/diagram_segmented.png"); } public static void main(String[] args) { new SegmentDiagram(); }}The shape recognition is another topic, already discussed on Stack Overflow:2D Shape recognition algorithm - looking for guidance 这篇关于Java中的图像分割库的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!
09-14 15:22