BalaShiyamala / opencvdotnet

Automatically exported from code.google.com/p/opencvdotnet
0 stars 0 forks source link

An improvement needed !! #2

Open GoogleCodeExporter opened 8 years ago

GoogleCodeExporter commented 8 years ago
I'm very new on this, however, I have noticed that the class CVImage only
works with CVRgbPixel if we want to access it randomly (if I'm wrong,
please (please !!!), correct me).

The problem is that I must work with double precision matrices, and I need
to  resize them. So, the improvement that I propose is:

- Change CVImage class for double precision, making possible to initialize
it with a double precision .NET array.

The question are:

- How can I do easily that change?
- After that, resizing would be possible??

Sorry for my poor English.
Thank you!!!

Original issue reported on code.google.com by iza...@gmail.com on 7 Mar 2007 at 4:38

GoogleCodeExporter commented 8 years ago
I'm sorry, but you are correct :-)
The random-access access to a pixel of CVImage is currently only for 8-bit RGB
images. This sucks... I know. It's just want I needed up until now.
I am planning to revise this and find a nice way to allow access to all types 
of images.
I am not sure what would be the best tactic to do this... Perhaps subclass 
CVImage to
accommodate different types of images, such that the this[] operator will 
reflect the
type of image created... We need to figure out the nicest way to factory this 
image
object.
Ideas are most welcome!!!

Original comment by elad.ben...@gmail.com on 7 Mar 2007 at 5:11

GoogleCodeExporter commented 8 years ago
OK, perhaps I could solve all my problems if I just could initialize a CVImage 
from a
Bitmap :-)

Sorry

Original comment by iza...@gmail.com on 7 Mar 2007 at 5:15

GoogleCodeExporter commented 8 years ago
ALL WORKING !!

I have solved my problem !!!
I haven't modified the library, of course (I know very little about C++) :-)
I just initialized a CVImage like a Bitmap, and I have obtained the same result 
as it
was a gray-scale image. It's a quite stupid code, but it can be helpful for 
begginers:

static public CVImage matrix2CVImage(Matrix m)
{
   int fil = m.RowCount;
   int col = m.ColumnCount;
   int i, j;

   CVImage img = new CVImage(col, fil, CVDepth.Depth8U, 1);

   for (i = 0; i < fil; i++)
   {
      for (j = 0; j < col; j++)
      {
         int iR = (int) m[i, j];
         int iG = (int) m[i, j];
         int iB = (int) m[i, j];
         CVRgbPixel pix = new CVRgbPixel(Color.FromArgb(iR, iG, iB));
         img[i, j] = pix;
      }
   }
   return img;
}

If we want to create a CVImage from some gray-scale values, we can use that 
method.

Notice this:

CVImage img = new CVImage(col, fil, CVDepth.Depth8U, 1);

It's a gray-scale image.

If you are asking about the Matrix class, look at the MathNet project:

http://www.cdrnet.net/projects/nmath/

There we can find a lot of useful classes for mathematics, and easy Matrix
manipulation (all from .NET). If we combine it with OpenCVDotNet... x-)

Good work!

Original comment by iza...@gmail.com on 7 Mar 2007 at 5:53