0

As a hobby I'm trying to study a scene text detection method.

I wish to do something like the following:

           struct pixel1
                    {
                        public int y1;            
                        public int x1;
                        public Color color1;
                    };

           List<pixel1> blob1 = new List<pixel1>();//I failed to create blob1 list with variables.

           List<blob1> listofblob1 = new List<blob1>();//declair list of blob which I failed to do.

    private void runMethod1()
        {
    //I want to use it like it shows in below.
    foreach (var blob1 in listofblob1)
        {
    blob1.DistanceToClosestBlob=getDistanceToNextblob(blob1, listofblob1);
    blob1.size=blob1.Count;
    blob1.centerxy=getcenterXY(blob1);
    if(blob1.center.x<0||blob1.center.y<0){return;}
        }
}

Is it possible to do it?

Dale K
  • 25,246
  • 15
  • 42
  • 71
NubyShark
  • 143
  • 2
  • 11

2 Answers2

2

If you change it to a class, then you can do and more things else need to create an immutable struct.

Immutable struct reference is here: How do I make a struct immutable?

Need to do it like this:

struct Pixel1
{
    public int X1 { get; }
    public int Y1 { get; }            
    public Color Color1 { get; }

    public Pixel1(int x, int y, Color c)
    {
       X1 = x;
       Y1 = y;
       Color1 = c;
    }            
};

But make it a class.

Gauravsa
  • 6,330
  • 2
  • 21
  • 30
0
struct pixel1
        {
            public int y1;            
            public int x1;
            public Color color1;
        };

        struct Blob1//pixel list=blob
        {
            public List<pixel1> blob1;
            public int size;            
        };

        List<Blob1> bloblist = new List<Blob1>();  

void runMethod1()
        {

            Blob1 b1 = new Blob1();
            b1.size = 1;
            pixel1 p1 = new pixel1();
            b1.blob1.Add(p1);

        }
NubyShark
  • 143
  • 2
  • 11
  • It seems I can do it like this. I can use floodfill and lockbits.getpixels method and get each pixel info into the pixel1 then put them into the Blob1 then all into the bloblist. Then loop through the bloblist and analyse information about Blob1s and input information in the Blob1 variables to study and process them later. – NubyShark Dec 17 '18 at 02:11