difference between each pixel is computed along the
x and y direction. It is calculated by subtracting the
pixel value below from the pixel and above from the
pixel in both directions. Let’s say we need to find the
gradient difference in pixel p2, 2, the equations can
be given by 1 and 2
G(x) = p(2,3) − p(2,1) (1)
G(y) = p(3,2) − p(1,2) (2)
Where G(x) is the gradient change in the x-
direction and G(y) is the gradient change in the y-
direction. Finally, the magnitude and orientation of
the pixel are calculated using the formula 3 and 4
µ =
q
[(Gx)
2
+ (Gy)
2
] (3)
Θ = tan
−1
(Gy/Gx) (4)
Using the obtained values, the HOG is generated
by creating a magnitude bucket for each block of an
image. The bin size used for the buckets changes
depending on the complexity of the task. For this
project, each bucket has a bin size of 9 and a cell size
of (8,8). This ensures that the images are processed
as 8 ∗ 8 blocks and for each block, a magnitude ma-
trix is created of size 9 ∗ 1. Now that we have the
histogram for 8 ∗ 8 cells, the value is normalized to
obtain the histogram of the image in 16 ∗ 16 cells. It
is mainly done to overcome the imbalance in gradi-
ent difference. The values of all possible 8 ∗ 8 blocks
are combined into a single 16∗ 16 using the following
equations,
vector = [a1, a2,a3,...,a36], (5)
k =
q
(a1)
2
+ (a2)
2
+ (a3)
2
+ ... + (a36)
2
, (6)
normalized vector =
a
1
k
,
a
2
k
,...,
a
36
k
. (7)
Finally, the resulting matrix is used to generate the
energy image.
2.1.2 Seam Identification and Replacement
Using the energy image, the horizontal and vertical
seam is determined. It refers to the connected path of
pixels that identifies the features of an image. Usu-
ally, it is recognized as a connected path of low-
intensity pixels since it is primarily used for image
resizing. Here, it is identified as the high-intensity
path that represents the important features of the im-
age. The proposed model aims to iterate over all pos-
sible seams and identify the optimal seam using op-
timization techniques. Here, the optimal seam is the
one with high intensity or weight. After identification,
the values of the seam pixels are manually updated
to zero (min intensity value) to avoid identifying the
same seam during the next iterations. It is also saved
to restore back the original image.
After identifying the vertical and horizontal seam,
the seam’s pixel value is updated to produce a new
image. Two different approaches are tested to mod-
ify the original image. The first approach replaces
the pixel value with a solid color and the second ap-
proach replaces the pixel value by inverting it. Even
though both approaches showed similar results, the
former was technically complex. The seam informa-
tion and the original pixel value need to be stored to
restore the original image. Hence the seam is replaced
using the color inversion technique. The function in-
puts the seam array and the original image. The origi-
nal image is converted into an ImageDraw object to
enable modification. The input array is iterated to
access each seam index and the values are inverted.
This is done by subtracting 255 from the correspond-
ing pixel value. Here, 255 refers to the maximum in-
tensity value for an 8-bit image channel. Finally, the
modified image is returned in the form of a PIL in-
stance.
The process is repeated until the image is partially
modified. To iterate the process, the entire workflow
is repeated again including the generation of energy
images. The overall process of seam doppelganger is
explained in detail using 1
In addition to image modification by seam re-
placement, it is also distorted by replacing random
pixels. It is done to justify the use of a dedicated
technique for image modification. A random pixel
for the image is selected and replaced by a random
RGB value. Again, the process is repeated until the
similarity between the original and modified image is
less than 0.5. The classification results obtained using
both techniques are compared in later sections.
2.1.3 Image Restoration
In addition to image distortion, the original image
can also be restored by reversing the technique. The
same approach used for image modification is re-
peated to perform the restoration. The seams iden-
tified and stored during the replacement process are
modified back to the original pixel value. Since the
pixel values were inversed during replacement, re-
inversing them would generate the original image.
The proposed model not only provides a simple solu-
tion but also achieves 100% image restoration, unlike
the traditional seam doppelganger approach. The only
drawback of this approach is the additional memory
and computational time required to store the modified
seam during the image modification process.
VISAPP 2024 - 19th International Conference on Computer Vision Theory and Applications
344