Remove icon from jpeg image

Viewed 145

Is there any way to remove icon from image that in original didn't had the icon.

Maybe with help of hexdump or something?

Here is an example of image.

enter image description here

is there a way to remove the heart icon from it?

*I don't really need this image it is just for example

1 Answers

One method is to use color thresholding to obtain a binary mask which can be used to isolate the desired regions to keep. Once we have this mask, we bitwise-and to effectively remove the heart


After color thresholding with a HSV lower and upper range, we obtain this mask

enter image description here

To remove the heart, we invert the mask which represents all regions in the image that we want to keep then bitwise-and with the input image. Since you didn't specify what you want to replace it with, I've just colored the removed region with white. Here's an implementation using Python and OpenCV

enter image description here

import numpy as np
import cv2

image = cv2.imread('1.jpg')
original = image.copy()
hsv = cv2.cvtColor(image, cv2.COLOR_BGR2HSV)
lower = np.array([0, 138, 155])
upper = np.array([179, 255, 255])
mask = cv2.inRange(hsv, lower, upper)
invert = 255 - mask
result = cv2.bitwise_and(original, original, mask=invert)
result[invert==0] = (255,255,255)

cv2.imshow('mask', mask)
cv2.imshow('result', result)
cv2.waitKey()
Related