-2

Following function solves the problem, but I don't understand how to call it, especially "out List ImgLetters" part.

  public static bool ApplyBlobExtractor (Bitmap SourceImg, int LettersCount, out List<Bitmap> ImgLetters)
    {
        ImgLetters = null;
        ImgLetters = new List<Bitmap> ();

        BlobCounter blobCounter  = new BlobCounter ();

        // Sort order
        blobCounter.ObjectsOrder = ObjectsOrder.XY;            
        blobCounter.ProcessImage (SourceImg);
        Blob[] blobs             = blobCounter.GetObjects (SourceImg, false);            

        // Adding images into the image list            
        UnmanagedImage currentImg;            
        foreach (Blob blob in blobs)
        {
            currentImg = blob.Image;
            ImgLetters.Add (currentImg.ToManagedImage ());
        }            

        return ImgLetters.Count == LettersCount;
    }

Now lets look at this:

public static bool ApplyBlobExtractor (Bitmap SourceImg, int LettersCount, out List<Bitmap> ImgLetters)

Bitmap SourceImg - picture, where blobs will be found

int LettersCount - blob that we are going to extract (number)

out List ImgLetters - ???

What does 3rd parameter do (how to call this function)?

Bitmap image1 = new Bitmap(@"C:\1.png");    
..
ApplyBlobExtractor (image1, 1, ??? )
..
image2.save(@"C:\2.png")
Alex
  • 4,607
  • 9
  • 61
  • 99
  • but I already did all the work finding the code.. all that's left is calling the function.. could you at least explain what 3rd parameter does because I've spent few hours trying to solve this problem. – Alex Feb 18 '12 at 17:12
  • P.S. I edited the question because of misunderstanding – Alex Feb 18 '12 at 17:17

1 Answers1

1

an out parameter allows you to get results back from a method call other than through the return parameter. http://msdn.microsoft.com/en-us/library/t3c3bfhx(v=vs.80).aspx

In your example the method ApplyBlobExtractor it appears to take a source Bitmap, and a LetterCount (presumably the number of letters you expect to find) it then uses this Blobcounter object to chop it up. It will return true if it finds the same number of letter you expect to find. It will also provide you the output images as a list back through the out parameter.

to call it would would do something like...

Bitmap img1 = new Bitmap(@"C:\1.png");

List<Bitmap> foundImages;

bool result = ApplyBlobExtractor(img1, 1, out foundImages);
Eoin Campbell
  • 43,500
  • 17
  • 101
  • 157
  • Niiiiice!! What I couldn't understand is HOW Boolean function (true or false) could returm images!! Thanks to you I now know what OUT means.. For anyone who seeks image output - just write: pictureBox1.Image = foundImages[1]; Eoin Campbell you are my hero.. 3 hours of googling and experimenting finally end ;) – Alex Feb 18 '12 at 18:04