Automatic face detection using Picasa API to extract individual images

前端 未结 7 1176
佛祖请我去吃肉
佛祖请我去吃肉 2020-12-13 01:15

(A similar question has been asked on superuser for answers related to applications. The question is posted here to gather programmable solutions for the same)

7条回答
  •  执念已碎
    2020-12-13 01:36

    You can simplify the problem even further :-) if the scanned images will always be in a 5x4 grid ... then you can easily just open the image in just about any programming language that offers bitmap manipulation, and save each square. Here's an example of how to do this with C#:

    private Image Crop(Image pics, Rectangle area)
    {
       var bitmap = new Bitmap(pics);
       return (Image)bitmap.Clone(area, bitmap.PixelFormat);
    }
    

    All you'd need to do is calculate each rectangle, and then call this method which returns just the area of the image defined by the rectangle. Something like (possibly pseudo code, haven't compiled the code below):

    // assuming that each sub image in the larger is 45x65
    int cellwidth=45, cellheight=65;
    
    for(int row=0;row<5;row++)
    {
      for(int col=0;col<4;col++)
      {
        var rect = new Rectangle(
          row * cellwidth,
          col * cellheight,
          cellwidth,
          cellheight);
        var picture = Crop(bigPicture, rect);
        // then save the sub image with whatever naming convention you need
      }
    }
    

提交回复
热议问题