-2

I am new to computer version, I am trying to remove the background of the image given and make it white background. I have tried most of the codes shared here but non is working on my image.

input:

Image to remove background

desired output:

After Removal of background (Reference Image)

6
  • I see no way to produce your desired result from the given input. there needs to be more data. Commented Dec 1, 2021 at 13:53
  • For this example: Invert the colors. Commented Dec 1, 2021 at 14:17
  • @ChristophRackwitz what do you mean by "needs to be more data"? thanks. Commented Dec 1, 2021 at 14:28
  • inverting doesn't quite do it, but looks close... @ChandaSteven explain how those pictures were made? don't keep secrets. Commented Dec 1, 2021 at 14:39
  • @ChristophRackwitz those images are collected from PET scan. I could change the contrast of the images but still didn't get the desired output. Commented Dec 1, 2021 at 15:00

2 Answers 2

0

Chanda Steven wrote:

I am new to computer version, I am trying to remove the background of the image given and make it white background.


If that is all you want to do, then the following is a simple way to do that in Python/OpenCV/Numpy.

(But your desired result looks like an inverted result. So I am not sure what you want.)

If making the background white is all you want. Then convert the input to gray. Copy the input and use Numpy to change the background to white where gray is close to black.

Input:

enter image description here

import cv2
import numpy as np

# read image
img = cv2.imread("a_blob.jpg")

# convert img to grayscale
gray = cv2.cvtColor(img, cv2.COLOR_BGR2GRAY)

# change black to white
result = img.copy()
result[gray<=2] = (255,255,255)

# write results to disk
cv2.imwrite("a_blob_white.jpg", result)

# show results
cv2.imshow("RESULT", result)
cv2.waitKey(0)

Result:

enter image description here

Sign up to request clarification or add additional context in comments.

Comments

-1

If you remove background you not have your desider output.

enter image description here

The object in the image have a different processing, similar negative, but isn't negative.

If it was negative you got this result :
negative_image

From output image it's very difficult understand what operations have been carried out.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.