I think I may have found a bug somewhere in rle_invert or in
rle_bounding_boxes (those are functions I used in the code below).
I've created a 400x300 image which has a square of pixels in the
range:

    x in [50, 52]
    y in [50, 52]

that should be segmented into a box (using rle_bounding_boxes).
However, the result I am getting is:

    boxes.length()=2
    boxes(0)=(0, 0, 400, 300)
    boxes(1)=(50, 50, 53, 54)

I don't know if these bounds are supposed to be closed invervals or
not, but I would assume they should at least be tight.  Having a bound
at 54 is definitely not tight.  53 might also not be tight if the
bounds are closed invervals.  Could someone clarify for me if these
bounds are open or closed intervals?

I can try to identify the source of the problem and write a patch if
no one else wants to tackle it.

Below is the code I used to get these results, based on iulib Revision 87:


#include <stdio.h>
#include <iulib/imgio.h>
#include <iulib/imgbits.h>
#include <iulib/imgrle.h>

int
main ()
{
    imgrle::RLEImage rle_image;
    imgbits::BitImage bit_image;
    colib::bytearray byte_image;

    {
        bit_image.resize (400, 300);
        bit_image.fill (1);
        //
        bit_image.set (50, 50, 0);
        bit_image.set (51, 50, 0);
        bit_image.set (52, 50, 0);
        //
        bit_image.set (50, 51, 0);
        bit_image.set (51, 51, 0);
        bit_image.set (52, 51, 0);
        //
        bit_image.set (50, 52, 0);
        bit_image.set (51, 52, 0);
        bit_image.set (52, 52, 0);

        imgbits::bits_convert (byte_image, bit_image);
        imgrle::rle_convert (rle_image, byte_image);

        imgrle::rle_invert (rle_image);

        colib::narray<colib::rectangle> boxes;
        imgrle::rle_bounding_boxes (boxes, rle_image);
        printf ("boxes.length()=%d\n", boxes.length ());
        for (int i = 0; i < boxes.length(); ++i)
          {
            printf ("boxes(%d)=(%d, %d, %d, %d)\n",
                    i,
                    boxes(i).x0,
                    boxes(i).y0,
                    boxes(i).x1,
                    boxes(i).y1
                   );
          }
    }

    return 0;
}

--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups 
"ocropus" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/ocropus?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to