JavaScript, Consider the following code fragment, that is supposed to compute the pixel value
let c = image.getPixel(x, y); const m1 = (c[0] + c[1] + c[2]) / 3; c = image.getPixel(x + 1, y); const m2 = (c[0] + c[1] + c[2]) / 3; image.setPixel(x, y, [m1 - m2, m1 - m2, m1 - m2]); Give three pairs of pixel values (x, y) = [?, ?, ?] and (x+1, y) = [?, ?, ?] in the input image, for which this code does not produce the correct result.
Pair 1.)
(x, y) =
(x+1, y) =
Pair 2.)
(x, y) =
(x+1, y)=
Pair 3.)
(x, y) =
(x+1, y)=
In this code, the RGB index of pixel (x,y) is set to the the average RGB of (x,y) - (x+1, y)
Also, we know that each colour index is a 8 bits value between 0 to 255 in decimals.
So, any value out of this range will produce error, such as:
Pair 1 :
(x, y) = [ 51, 51, 51] and (x+1, y) = [255, 255, 255]
Hence, m1 - m2 = 51 - 255 = -201 ( not acceptable)
Pair 2 :
(X,y) = [21, 43, 56] and (x+1,y) = [255, 124, 200]
M1 - m2 = 40 - 193 = - 153 (not acceptable)
Pair 3:
(x,y) = [0, 0, 0] and (X+1, y) = [ 51,51,51]
m1 - m2 = 0 - 51 = -51 ( not acceptable)
Get Answers For Free
Most questions answered within 1 hours.