shimat / opencvsharp

OpenCV wrapper for .NET
Apache License 2.0
5.4k stars 1.15k forks source link

[Question] How to transform a mat into a mat with single row or column #1238

Closed themronion closed 3 years ago

themronion commented 3 years ago

Hey, @shimat. amazing work and library. I am trying currently to implement some deblurring mechanisms and currenlty working on this formula - image where B+ is the pseudo-inverse matrix of a blurred image, B - our image, v - any vector, and g - is a single vector composed of all the columns of B. I am struggling to get the g vector, didn't find how to do it in C# on the web. Can u give me a small tip? Thanks in advance!

shimat commented 3 years ago

How to transform a mat into a mat with single row or column

Sorry but I don't understand what you specifically want to do, but Mat.reshape will help you with the question of the issue title.

using var src = new Mat(20, 20, MatType.CV_8UC1);
using var dst = src.Reshape(0, 1);

Console.WriteLine("Rows={0}, Cols={1}", dst.Rows, dst.Cols); // Rows=1, Cols=400
themronion commented 3 years ago

Yeap. i guess thats exactly what i need, thanks. So simple though)