Farah Nazifa
Farah Nazifa

Reputation: 921

Crop portion of image and replace with another using Java

I was trying to use Java to take an image as an input of a person and the output be the same person with different face but the background and everything same except for the face. I know how to filter an image but not understanding where to begin this work from. Its more like editing a celebrity's picture and just the change the face and place my face instead to be more detailed.

Upvotes: 0

Views: 252

Answers (1)

Harald K
Harald K

Reputation: 27113

As your tags suggests, you are familiar with some of the concepts. All you need to do, is to link them together.

Your question is quite vague, however, so I'll just give a brief outline:

  1. Read the image(s) using ImageIO. This will give you one or more BufferedImages.
  2. Use bufferedImage.getSubImage(...) to crop.
  3. Use bufferedImage.createGraphics() to create a graphics context, use g.drawImage(...) to draw your face onto the background. And any other painting you like to do. Don't forget to dispose() the graphics context.

Upvotes: 1

Related Questions