Skip to content
Back to blog

Photo

Background replacement and object removal with AI: the basics

Replacing a background and erasing an object can be done in a few rounds with the right prompt. We cover prompts, edge and light matching, common mistakes and the ethical limit of altering photos.

Zling AI Team7 min read

A man on a sofa editing a beach photo on a tablet with a stylus

Short answer: replacing a background or erasing an object with AI is done with a short, clear prompt that tells the model what to change and what stays exactly the same. The hard part is not making the change but making the result convincing: clean edges, matching light direction, shadows in place. This article covers the two basic jobs, prompts for each, consistency rules and where altering a photo can become an ethical problem.

What do background replacement and object removal mean?

Background replacement means keeping the subject in front (a person, a product, an animal) and swapping the scene behind it for another. Object removal means taking out something unwanted in the frame (a sign, a bin, a cable, someone who wandered into the shot) and filling the spot with a fill that suits its surroundings. Google's Gemini documentation explicitly describes adding, removing or modifying elements in a provided image and adjusting style or colour grading; both jobs are kinds of these edits.

We did not see a description of drawing a mask to select a region (inpainting) in the documentation; the method in this article is entirely text-guided, conversational editing. If the tool you use has a mask or brush, it can help you select the region more precisely.

How do you replace a background?

Say three things: that the subject stays exactly the same, a description of the new background and that the light matches. If the light part is skipped, the subject looks pasted into the new scene.

Keep the person exactly as they are: face, hair, clothing and pose unchanged. Replace the background with a quiet beach at golden hour. Match the lighting on the person to the warm low sun coming from the left, and keep the edges of the hair natural.

If you want a simple, single-colour background, say so clearly; plain surfaces reduce edge problems.

Keep the product exactly the same. Place it on a plain off-white background with a soft shadow beneath it. Keep sharp, clean edges.

How do you remove an object?

Describe exactly what is to be removed and say what the removed area should be filled with. Saying "remove something" makes the model guess what to remove.

Remove the red trash bin on the right side of the sidewalk. Fill the area with the same paving stones and wall texture around it. Keep everything else exactly the same.

If there are several objects, remove one per round. BFL's guide also recommends fixing one detail at a time; the Gemini documentation recommends iterating with multi-turn conversation.

What should you keep fixed while editing?

In the editing examples in the Gemini documentation, the elements that must not change are stated explicitly. Carry the same pattern into your own work:

  • Subject: face, hair, clothing, pose.
  • Framing: the cropping and proportions of the image.
  • Sharpness and colour: "image sharpness and colour tones stay the same".
  • Objects that must not change: list what stays one by one.

Change only the background. Keep the subject, framing, image sharpness and color tones exactly the same.

How do edges and light stay consistent?

A convincing edit depends on two things: edges and light.

Edges

  • Hair and fine detail are the hardest places: individual strands, fur and sheer fabric. If needed, choose a background in colours close to the subject.
  • Bright edge (halo): A light line around the subject is a remnant of the old background; in a separate round say "clean up the light halo around the edges".
  • Feet or product sitting on the ground: Without a shadow the subject looks as if it is floating.

Light

  • Direction: If the sun comes from the left in the new scene, the shadow on the subject should fall to the right too.
  • Colour temperature: A portrait with cool white light does not suit a golden-hour scene.
  • Hardness: Expect hard shadows in a sunny scene and soft shadows in an overcast one.

If you use several images, as BFL recommends, refer to each in order ("image 1", "image 2") and state its role: "place the person from image 1 into the scene from image 2, keeping the lighting of image 2."

When does it not work well?

  • Subject the same colour as the background: The boundary becomes hard to pick out.
  • Complex, crowded scenes: The model guesses the detail behind the removed object.
  • Removing over text or patterns: When you remove an object over lettering, letters may be invented.
  • A very small or blurry source: The model cannot make the fill consistent.
  • Near hands and thin objects: Fingers and thin rods can drift.

Always zoom in and inspect the result: edges, shadows and the surroundings of the removed area.

When does altering a photo become an ethical problem?

Not every edit weighs the same. Removing a crowd from a holiday shot is not the same as removing a person from a photograph with news value. A simple test: does the edit change what someone looking at the image believes about reality?

  • Generally not a problem: Removing a bin, a cable or a dust spot; improving the background in your own holiday photo, as long as you do not present it as a real document.
  • Needs care: Hiding the condition of a product or a place (a listing photo, a product photo); removing a person from the scene of an event; showing a place as different from what it is.
  • To be avoided: Showing a real person in a scene they were not in or doing something they did not say or do; silently altering an image that serves as news, evidence or an official document.

Platforms draw the same line. YouTube's help page asks for disclosure of content that looks realistic and alters footage of a real event or place, while exempting minor aesthetic edits such as colour and lighting adjustments and background blur. The Gemini documentation also says images produced with these models carry a SynthID watermark. Stating the edit openly instead of hiding it is the safest approach.

A real example: the beach shot

In a beach photo you took on holiday there is a bin in the background and a cable in front; the sky is also dull. Do the job in three separate rounds:

  1. Round 1, object removal: "Remove the bin on the right, fill it with the surrounding sand; everything else stays the same."
  2. Round 2, second object: "Remove the cable in front, continue the sand; the person and framing stay the same."
  3. Round 3, sky: "Change only the sky to a warm sunset; do not change the person, the sand or the sea."

After the three rounds put the result next to the source and look closely at the person's face, the hair edge and the shadows on the sand. If one has drifted, undo that round and write the sentence more narrowly. This order is both more controlled than one giant prompt and makes it easier to find the error.

Step-by-step workflow

  1. Choose a sharp, well-lit source.
  2. Remove objects first; one object per round.
  3. Then replace the background; write the subject and light matching in the prompt.
  4. Zoom in and inspect edges and shadows.
  5. If needed, fix the edge halo or the shadow in a separate round.
  6. Compare the result with the source; did the subject change?
  7. Before publishing, decide whether the edit needs to be disclosed.

Common mistakes

  • Skipping the light: The subject looks pasted into the new scene.
  • Not saying what stays: The face or clothing may drift.
  • A vague removal request: Instead of "clean this up", describe the object to remove and its place.
  • Too much in one round: Removal, background and colour should be separate rounds.
  • Forgetting the shadow: A subject without a shadow floats.
  • Hiding the edit: An altered image presented as a real event misleads.

Summary

  • When replacing a background, write that the subject stays exactly the same and that the light matches.
  • When removing an object, describe the thing and what the area is filled with.
  • Do one job per round; zoom in and inspect edges and shadows.
  • Ask whether the edit changes the impression of reality.
  • Do not alter a real event or person in a misleading way; do not hide the edit.

Frequently asked questions

How does the subject stay the same when replacing a background with AI?

Write in the prompt that the subject's face, hair, clothing and pose stay exactly the same and only the background changes. The editing examples in Google's Gemini documentation also state explicitly what must not change.

Why does the spot of the removed object look odd?

The model does not know what was behind the removed thing; it guesses. Describe the object to remove and what texture should fill the spot, remove one object per round and zoom in to inspect the result.

What if the subject looks pasted onto the new background?

Most likely the light and shadow do not match. Ask for the new scene's light direction and colour temperature on the subject too, and ask for a shadow so that the feet or product sit on the ground.

Is altering a photo always unethical?

No. Removing a bin or improving the background of your own holiday photo is different from changing an event or a person in a way that alters the impression of reality. Platforms such as YouTube ask for disclosure of realistic content that alters footage of a real event or place.

Do I need to draw a mask?

The method in the Gemini documentation is text-guided conversational editing; the documentation does not describe drawing a mask. If your tool has a mask or brush, it can help you select the region more precisely.

Sources

  1. Google AI for Developers: Image generation with Gemini (Nano Banana)
  2. Black Forest Labs documentation: Prompting basics
  3. YouTube Help: Disclosing use of altered or synthetic content