简体   繁体   English

C语言中图像卷积(图像处理)的实现

[英]Implementation of Image Convolution (Image Processing) in C

I am testing some convolution algorithms i found in some sites but none of them apply the matrix filters as it should. 我正在测试我在某些站点中发现的一些卷积算法,但是没有一个像应有的那样应用矩阵滤波器。

I am writing a very simple 24 bits bmp library on my own, but now i need a little help with the convolution, i don't need FFT or complex algorithm, running time is not important at this time. 我自己编写了一个非常简单的24位bmp库,但是现在我需要卷积方面的帮助,我不需要FFT或复杂的算法,此时的运行时间并不重要。

The last code i was testing was this: http://lodev.org/cgtutor/filtering.html But i didn't work fine. 我测试的最后一个代码是: http : //lodev.org/cgtutor/filtering.html但是我工作不正常。

Could some one indicate me a code or algorithm in C?. 有人可以告诉我C语言中的代码或算法吗?

Thank you very much. 非常感谢你。

You can have a look at this algorithm - this is the closest which i can find: 您可以看一下这种算法-这是我能找到的最接近的算法:

Convolution to blur the image 卷积模糊图像

Know that the basic convolution algorithm is more or less the same, the affect changes only by the kernel values. 知道基本的卷积算法或多或少都是相同的,其影响只取决于内核值。

There is an open source C# library which provides methods to perform image convolution of simple filters. 有一个开放源代码的C#库 ,它提供了执行简单过滤器图像卷积的方法。 It would be an easy port to C. 到C站很容易。

The actual methods to perform convolution can be found here . 进行卷积的实际方法可以在这里找到 The BitmapContext class is used to just wrap a pointer to bitmap. BitmapContext类用于仅包装指向位图的指针。 I believe in C# this is treated as int*, so this code is operating on 4 bytes at a time. 我相信在C#中将其视为int *,因此此代码一次在4个字节上运行。

I created Image Convolution library for simple cases - https://github.com/RoyiAvital/Projects/tree/master/ImageConvolution . 我为简单情况创建了图像卷积库-https: //github.com/RoyiAvital/Projects/tree/master/ImageConvolution

It is pretty fast (OpenMP + SIMD). 它非常快(OpenMP + SIMD)。
Though I'm not an advanced programmer of something, just tried doing it to do first steps in utilizing SIMD. 尽管我不是某个东西的高级程序员,但尝试将其用作使用SIMD的第一步。 Still, from what can be seen in VS 2015, the CPU utilization is pretty good. 不过,从VS 2015中可以看出,CPU利用率非常好。

If you have ideas to make it even faster, I will be happy. 如果您有更快的想法,我会很高兴的。

Feel free to use it in any manner you'd like. 随时以您想要的任何方式使用它。

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

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