When to use `image` and when to use `Matrix` in Emgu CV? - c#

in openCV I regularly use cv::Mat for almost everything. Now, I need to use emgu CV and use the Matrix-object in stat, but some functions are not supported?!... may I use the image-class instead?
When to use image and when to use matrix in emgu CV?
P.S.: Currently I'm looking for a way to define a ROI on a matrix but didn't find a way without copying the data.
Version: Emgu.CV-2.4.2

As of OpenCV 3.0, OpenCV is phasing out IplImage. EmguCV's Image<,> is a wrapper around IplImage, so Image<,> is being phased out of EmguCV.
Use Mat and CvInvoke wherever possible. Avoid Image<,> and its methods.

I know that in the latest version of OpenCV, the Mat object is prefered to iplImage for a lot of reasons.
In EmguCV, things are different. I think that the rule of thumbs is to use Image<> when the data itself is supposed to be an image and Mat<> when you need to work with a matrix. Work with what you need and the emguCV object should have the right contructor/function for your needs.
For the ROI, the comment by sumeet is very good.
Hope it helps!

Related

How to use the exact Opencv C++ functions in EMGU?

As mentioned in the EMGU documentations ".Net wrapper to the OpenCV image processing library"
We depended on the functions we could find online but we really didn't figure out how to use those exact OPENCV C++ functions in the opencv documentations like blob?
How to use them in the EMGU platform?
I would suggest looking in the EmguCV source code for the OpenCV functions you are looking for and see how they are wrapped. It is all there.
There is also the need to move data between the managed side and the unmanaged side.
Doug
EmguCV provides a class called CvInvoke which wraps a lot of the basic opencv functionality. The previous link goes for the EmguCV 3.4.3 documentation. Maybe you need another version. Anyway I recommend to also check other classes aside from CvInvoke. The API documentation should be a good starting point.

Matrix class C#

I'm trying to make some geometric transformations (e.g. scale,shear) on an image already loaded in a bitmap object
I then found a Built-in Matrix class in C# , I used it but I'm not sure on how to initialize a 2x2 matrix or a column vector etc.
The 4th overloaded constructor forces me to enter 6 values representing 3x2 ,but that I don't want!
I used this reference but couldn't find an answer
https://msdn.microsoft.com/en-us/library/system.drawing.drawing2d.matrix(v=vs.110).aspx
As #Daniel pointed out, System.Drawing.Drawing2D.Matrix is for visual geometrical transformations only, not mathematical.
If you'd like mathematical transformations I'd recommend you take a look at Math.NET or what I'd recommend, OpenCV library. OpenCV is written in C++, but has an excellent C# wrappers. It can be easily installed via Nuget.

C# image recognition

I'm currently searching for a C# image recognition library.
What I want to do:
I want to write a function that scans an image and returns if another image is part of it. Or at least something that looks familiar in case that the angles of the two objects are different.
The link to a possible library and a short code example would be great!
Thank you in advance!
Since you didn't mention that you are only looking for free libraries, here are some paid ones:
MVTech HALCON
Cognex VisionPro
Both have demo versions and quite good .Net wrappers bundled to the SDK, and I think both have the functionality you need. In Halcon, you might want to try different matching algorightms (gray value based, descriptor based, etc.), while in VisionPro PatMax or PatQuick might suit your needs. But obviously you have to try which one is the best for your specific problem.
EmguCV (http://www.emgu.com/wiki/index.php/Main_Page) is a good .NET OpenCV wrapper. It has a bunch of sample projects bundled. Run samples and you will get the idea of what can be done and how.
The Accord.NET library is not actually an image recognition tool set, however it provides the base for what you are aiming for. It contains many Imaging classes required for building an image recognition system. Accord.NET is LGPL licensed, except for some parts of it (e.g. its FFmpeg wrapper project).

compare two images and extract the difference using emgu cv library

i want to compare two images like image1.png and image2.png.both the images look pretty same with some difference. so i want to get the difference and want to apply the difference on first image image1.png. i searched lot to get similar kind of code of this library but found none.
after lots of search i got bit similar kind of things which i am looking for in java code. here is the url http://mindmeat.blogspot.in/2008/07/java-image-comparison.html
please go to the url and there you can see the code generate 3rd image with difference but my requirement is bit different. i do not want to generate 3rd image rather i want to apply the difference on the 1st image image1.png. some one told me it can be done very easily with emgu cv library. so i search for similar code based on emgu cv library but found no. it will be great help me anyone can guide me with sample code using emgu cv library.
thanks
I think what you require is:
image1 = image2 - image1;
Due to operator overloading, this is possible directly in Emgu CV

High speed matrix manipulation in c#?

I'm working on some image manipulation code in c# and need to do some matrix operations (specifically 2D convolution). I have the code written in matlab which uses the conv2 function ... is there a library for C# / .NET that does good high-speed matrix manipulations? I'd be fine if it requires some specific GPU and does the matrix math on-GPU if that's what it takes.
Emgu is a nice C# port of OpenCV. I'm not sure about your convolution speicifically, but from this link it appears likely.
Another idea would be to create a dll with your routines that you link to with C#. I think Matlab has export/compile to C file functionality..
http://www.mathworks.com/products/netbuilder/
For GPU based work have a look at CUDA :
http://www.nvidia.com/object/what_is_cuda_new.html
.Net with CUDA :
http://www.hoopoe-cloud.com/Solutions/CUDA.NET/Default.aspx

Categories