简体   繁体   English

如何在javacv或opencv中开始图像处理之前提高图像质量?

[英]How to improve the image quality before the image processing start in javacv or opencv?

I have an image with 400x400 image to identify different components from it. 我有一个400x400图像的图像,以识别它的不同组件。 But when I try to identify components using that most of time it doesn't provide correct answers. 但是,当我尝试使用大多数时间来识别组件时,它无法提供正确的答案。 So I need to know whether there are some kind of methods in javacv or opencv to improve the quality of the image or increase the size of the image without effecting to its quality ? 所以我需要知道javacv或opencv中是否有某种方法可以提高图像质量或增加图像大小而不影响图像质量?

This is the sample image that I use. 这是我使用的示例图像。 (This is the maximum size that I can get and I can't use any photo editing softwares in the project, because it's dynamically generated image.) (这是我可以获得的最大尺寸,我不能在项目中使用任何照片编辑软件,因为它是动态生成的图像。)

在此输入图像描述

In my image processing I need to identify squares and rectangles that connects those squares. 在我的图像处理中,我需要识别连接这些方块的正方形和矩形。 And specially I need to get the width and height of those using pixel values. 特别是我需要获得那些使用像素值的宽度和高度。

You can scale it to any size, if you can vectorize it... and in your case vestorization is quite simple as you have some simple geometrical objects in image. 你可以将它缩放到任何尺寸,如果你可以对它进行矢量化......在你的情况下,由于你在图像中有一些简单的几何对象,背心很简单。

So, in my view your approach should be like this: 所以,在我看来,你的方法应该是这样的:

  1. detect edges in the image with a high threshold (as you have very distinct objects) 使用高阈值检测图像中的边缘(因为您有非常不同的对象)
  2. vectorize them 矢量化它们
  3. scale them to any size 将它们缩放到任何尺寸

You should also look at the following link: Increasing camera capture resolution in OpenCV . 您还应该查看以下链接: 在OpenCV中提高相机捕获分辨率

If you stick to image processing the easiest way to do it is to apply an equalizeHist(). 如果坚持图像处理,最简单的方法是应用equalizeHist()。 This will increase contrast and will improve subsequent steps. 这将增加对比度并改善后续步骤。

But , and this is a biiiig 'but', why are you doing it? 但是 ,这是一个biiiig'但',你为什么要这样做? Just reading this post, I saw another solution, and a quick google proved me I am right: 刚看完这篇文章,我看到了另一个解决方案,快速谷歌证明我是对的:

Kabeja is a Java library for parsing, processing and converting Autodesk's DXF format. Kabeja是一个用于解析,处理和转换Autodesk DXF格式的Java库。 You can use Kabeja from the CommandLine or embed into your application. 您可以使用CommandLine中的Kabeja或嵌入到您的应用程序中。 All parsed data are accessible with the DOM-like API. 可以使用类似DOM的API访问所有已解析的数据。

That means you can extract directly all the data you want from that image in a text format. 这意味着您可以以文本格式直接从该图像中提取所需的所有数据。 Probably something like "at position x, y there is a transistor, or whatever." 可能就像“在x位置,有晶体管,或其他什么”。 So why would you render that file into an image, then analyse that image to extract the components? 那么为什么要将该文件渲染成图像,然后分析该图像以提取组件?

If you do it for school (I know that many school projects are like this) I would recommend you to find a real problem to solve, and propose it to your teacher. 如果你是为学校做的(我知道很多学校项目是这样的)我会建议你找到一个真正的问题来解决,并提出给你的老师。 You will be happier to do something that is not complete nonsense. 你会更乐意做一些不完全废话的事情。

vectorizing the image is best option I guess as suggested by mocap . 矢量化图像是我猜的最佳选择,正如mocap所建议的那样。
you can also use enhancement tools like sharpening, saturating etc. 您还可以使用锐化,饱和等增强工具。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM