locked
Lumia Imaging SDK (RedEye)

    Question

  • Trying to use the Lumia Imaging SDK to remove redeye from images. I have been successful in removing redeye from one eye in an image using the code in the examples:

                        List<Rect> eyes = new List<Rect>();
                        eyes.Add(new Rect(0,0,1,1));
                        filterlist.Add(new Lumia.Imaging.Adjustments.RedEyeRemovalFilter(eyes, Lumia.Imaging.Adjustments.RedEyeRemovalMode.Normal));
                        effect.Filters = filterlist;
                        await writableBitmapRenderer.RenderAsync();

    Can anyone help me in understanding how you get the rect for each eye, I thought I could use a drawn rectangle on the eye then use this to feed the eyes collection but the values range between 0 and 1.

    I would appreciate some pointers as to how I should proceed with detecting where the eyes are red or transferring the values from the rectangle drawn around the eyes to the Rect structure.


    Mal

    Tuesday, February 24, 2015 3:52 PM

All replies

  • Mal, let user select the eyes position otherwise you have to calcuate the position by yourself, will you want to do this?

    Wednesday, February 25, 2015 9:29 AM
  • Yes that's exactly what I want to do, I have code that lets the user draw a rectangle around the eye(s) but I don't know how to put the rectangle figures into the RedEyeFilter parameter, I tried using the left, top, width, height of the rectangle but that does not work.

    The Lumia SDK help says that the rectangles should have values expressed in the unit coordinate space of the image, i.e., the top left corner of the image is at (0, 0), and the bottom right corner is at (1, 1).

    That's what I don't understand


    Mal

    Wednesday, February 25, 2015 9:45 AM
  • Hi,

    The coordinates are fractions of the image size, so if your image size is (100, 200) and your eye rect in pixels is at position (50, 50) with size (10, 10), the input to the filter should be (0.5, 0.25, 0.1, 0.05).

    Regards,

    Jonas

    • Marked as answer by MalBall Thursday, February 26, 2015 9:31 AM
    • Unmarked as answer by MalBall Friday, March 13, 2015 2:19 PM
    Thursday, February 26, 2015 8:04 AM
  • Looks like that's sorted it thanks, just to confirm I have now done this and it works a treat

                        double left = vm.selectedRegion.SelectedRect.Left / writableBitmap.PixelWidth;
                        double top = vm.selectedRegion.SelectedRect.Top / writableBitmap.PixelHeight;
                        double width = vm.selectedRegion.SelectedRect.Width / writableBitmap.PixelWidth;
                        double height = vm.selectedRegion.SelectedRect.Height / writableBitmap.PixelHeight;
                        Rect rec = new Rect(left, top, width, height);


    Mal

    Thursday, February 26, 2015 9:31 AM
  • My previous algorithm now does not work so I obviously had it wrong in the first place. Could you suggest an algorithm to use please?


    Mal

    Friday, March 13, 2015 2:20 PM
  • Hi,

    The coordinates are fractions of the image size, so if your image size is (100, 200) and your eye rect in pixels is at position (50, 50) with size (10, 10), the input to the filter should be (0.5, 0.25, 0.1, 0.05).

    Regards,

    Jonas

    Jonas

    I am very close to sorting this, using the code I posted I can now sort redeye but if I make a rectangle around two eyes it only does one of them, if I make a rectangle around the one that's left and try again, it does that one but undo's the other.

    Any ideas as to why this would happen?


    Mal

    Saturday, March 14, 2015 9:39 AM