cabbage972/GitChameleon-2.0 huggingface dataset:
Library: librosa==0.6.0 (Python 3.7, released 2018-02)
Additional dependencies: scikit-learn==0.21.0 numpy==1.16.0 scipy==1.1.0 soundfile==0.10.2

Problem: Complete the function to return an array of sample indices to match the time axis from a feature matrix.

Starting code:
import librosa
import numpy as np

def compute_samples_like(y: np.ndarray, sr: int, D: np.ndarray, hop_length: int) -> np.ndarray:
    """
    Compute the samples vector of a spectrogram.

    Parameters:
        y: The audio signal.
        sr: The sampling rate of the audio signal in Hertz.
        D: The spectrogram.
    
    Returns:
        The computed samples vector.
    """
    
    

Solution:

    

    if np.isscalar(D):
        frames = np.arange(D) # type: ignore
    else:
        frames = np.arange(D.shape[-1]) # type: ignore
    offset = 0
    return (np.asanyarray(frames) * hop_length + offset).astype(int)
 

Test:

filename = librosa.util.example_audio_file()
y, sr = librosa.load(filename)
D = librosa.stft(y)
hop_length = 512 

sol = compute_samples_like(y, sr, D, hop_length)

if np.isscalar(D):
    frames = np.arange(D) # type: ignore
else:
    frames = np.arange(D.shape[-1]) # type: ignore
offset = 0
test_sol = (np.asanyarray(frames) * hop_length + offset).astype(int)

assert np.array_equal(test_sol, sol)
Library: librosa==0.7.0 (Python 3.7, released 2019-07)
Additional dependencies: numpy==1.16.0 scipy==1.1.0 soundfile==0.10.2

Problem: Complete the function to return an array of sample indices to match the time axis from a feature matrix.

Starting code:
import librosa
import numpy as np

def compute_samples_like(y: np.ndarray, sr: int, D: np.ndarray, hop_length: int) -> np.ndarray:
    """
    Compute the samples vector of a spectrogram.

    Parameters:
        y: The audio signal.
        sr: The sampling rate of the audio signal in Hertz.
        D: The spectrogram.
    
    Returns:
        The computed samples vector.
    """
    

Solution:


    return librosa.samples_like(D)

Test:

filename = librosa.util.example_audio_file()
y, sr = librosa.load(filename)
D = librosa.stft(y)
hop_length = 512 

sol = compute_samples_like(y, sr, D, hop_length)

if np.isscalar(D):
    frames = np.arange(D) # type: ignore
else:
    frames = np.arange(D.shape[-1]) # type: ignore
offset = 0
test_sol = (np.asanyarray(frames) * hop_length + offset).astype(int)

assert np.array_equal(test_sol, sol)
Library: librosa==0.6.0 (Python 3.7, released 2018-02)
Additional dependencies: scikit-learn==0.21.0 numpy==1.16.0 scipy==1.1.0 soundfile==0.10.2

Problem: Complete the function to construct a pure tone (cosine) signal at a given frequency.

Starting code:
import librosa
import numpy as np

def compute_tone(frequency: int, sr: int, length: int) -> np.ndarray:
    """
    Constructs a pure tone (cosine) signal at a given frequency.

    Parameters:
        frequency: The frequency of the tone in Hz.
        sr: The sampling rate of the signal in Hz.
        length: The length of the signal in samples.

    Returns:
        np.ndarray: The pure tone signal.
    """
    

Solution:


    phi = -np.pi * 0.5
    return np.cos(2 * np.pi * frequency * np.arange(length) / sr + phi)

Test:

frequency = 440
sr = 22050
length = sr

sol = compute_tone(frequency, sr, length)
phi = -np.pi * 0.5
test_sol = np.cos(2 * np.pi * frequency * np.arange(length) / sr + phi)
assert np.array_equal(test_sol, sol)
Library: librosa==0.7.0 (Python 3.7, released 2019-07)
Additional dependencies: numpy==1.16.0 scipy==1.1.0 soundfile==0.10.2

Problem: Complete the function to construct a pure tone (cosine) signal at a given frequency.

Starting code:
import librosa
import numpy as np

def compute_tone(frequency: int, sr: int, length: int) -> np.ndarray:
    """
    Constructs a pure tone (cosine) signal at a given frequency.

    Parameters:
        frequency: The frequency of the tone in Hz.
        sr: The sampling rate of the signal in Hz.
        length: The length of the signal in samples.

    Returns:
        np.ndarray: The pure tone signal.
    """
    

Solution:


    return librosa.tone(frequency, sr=sr, length=length)

Test:

frequency = 440
sr = 22050
length = sr

sol = compute_tone(frequency, sr, length)
test_sol = librosa.tone(frequency, sr=sr, length=length)
assert np.array_equal(test_sol, sol)
Library: librosa==0.6.0 (Python 3.7, released 2018-02)
Additional dependencies: scikit-learn==0.21.0 numpy==1.16.0 scipy==1.1.0 soundfile==0.10.2

Problem: Complete the function to construct a “chirp” or “sine-sweep” signal. The chirp sweeps from frequency fmin to fmax (in Hz).

Starting code:
import librosa
import numpy as np

def compute_chirp(fmin: int, fmax: int, duration: int, sr: int, linear: bool) -> np.ndarray:
    """
    Constructs a “chirp” or “sine-sweep” signal. The chirp sweeps from frequency fmin to fmax (in Hz).

    Parameters:
        fmin: The minimum frequency of the chirp in Hz.
        fmax: The maximum frequency of the chirp in Hz.
        duration: The duration of the chirp in seconds.
        sr: The sampling rate of the signal in Hz.

    Returns:
        np.ndarray: The chirp signal.
    """
    

Solution:


    import scipy
    period = 1.0 / sr
    phi = -np.pi * 0.5

    method = "linear" if linear else "logarithmic"

    return scipy.signal.chirp(np.arange(int(duration * sr)) / sr, fmin, duration, fmax, method=method, phi=phi / np.pi * 180, )

Test:

import scipy

fmin = 110
fmax = 110*64
duration = 1
sr = 22050
linear = True

sol  = compute_chirp(fmin, fmax, duration, sr, linear)
period = 1.0 / sr
phi = -np.pi * 0.5
method = "linear" if linear else "logarithmic"
test_sol = scipy.signal.chirp(
 np.arange(int(duration * sr)) / sr,
 fmin,
 duration,
 fmax,
 method=method,
 phi=phi / np.pi * 180, # scipy.signal.chirp uses degrees for phase offset
)
assert np.array_equal(test_sol, sol)
Library: librosa==0.7.0 (Python 3.7, released 2019-07)
Additional dependencies: numpy==1.16.0 scipy==1.1.0 soundfile==0.10.2

Problem: Complete the function to construct a “chirp” or “sine-sweep” signal. The chirp sweeps from frequency fmin to fmax (in Hz).

Starting code:
import librosa
import numpy as np

def compute_chirp(fmin: int, fmax: int, duration: int, sr: int, linear: bool) -> np.ndarray:
    """
    Constructs a “chirp” or “sine-sweep” signal. The chirp sweeps from frequency fmin to fmax (in Hz).

    Parameters:
        fmin: The minimum frequency of the chirp in Hz.
        fmax: The maximum frequency of the chirp in Hz.
        duration: The duration of the chirp in seconds.
        sr: The sampling rate of the signal in Hz.

    Returns:
        np.ndarray: The chirp signal.
    """    
    

Solution:


    return librosa.chirp(fmin=fmin, fmax=fmax, duration=duration, sr=sr)

Test:

fmin = 110
fmax = 110*64
duration = 1
sr = 22050
linear = True

sol  = compute_chirp(fmin, fmax, duration, sr, linear)

test_sol = librosa.chirp(fmin=fmin, fmax=fmax, duration=duration, sr=sr)
assert np.array_equal(test_sol, sol)
Library: librosa==0.7.0 (Python 3.7, released 2018-02)
Additional dependencies: numpy==1.16.0 scipy==1.1.0 soundfile==0.10.2

Problem: Complete the function to shear a matrix by a given factor. 

Starting code:
import librosa
import numpy as np

def compute_shear(E: np.ndarray, factor: int, axis: int) -> np.ndarray:
    


Solution:


    E_shear = np.empty_like(E)
    for i in range(E.shape[1]):
        E_shear[:, i] = np.roll(E[:, i], factor * i)
    return E_shear
    

Test:

E = np.eye(3)
factor=-1
axis=-1

sol = compute_shear(E, factor, axis)
gt = np.array([[1., 1., 1.],
 [0., 0., 0.],
 [0., 0., 0.]])
assert np.array_equal(gt, sol)
Library: librosa==0.7.1 (Python 3.7, released 2019-07)
Additional dependencies: numpy==1.16.0 scipy==1.1.0 soundfile==0.10.2

Problem: Complete the function to shear a matrix by a given factor. 

Starting code:
import librosa
import numpy as np

def compute_shear(E: np.ndarray, factor: int, axis: int) -> np.ndarray:
    


Solution:


    return librosa.util.shear(E, factor=factor, axis=axis)

Test:

E = np.eye(3)
factor=-1
axis=-1

sol = compute_shear(E, factor, axis)
gt = np.array([[1., 1., 1.],
 [0., 0., 0.],
 [0., 0., 0.]])
assert np.array_equal(gt, sol)
Library: librosa==0.7.0 (Python 3.7, released 2019-07)
Additional dependencies: numpy==1.16.0 scipy==1.1.0 soundfile==0.10.2

Problem: Complete the function to locate the local minimas of an array. 

Starting code:
import librosa
import numpy as np

def compute_localmin(x: np.ndarray, axis: int) -> np.ndarray:
    

Solution:


    return librosa.util.localmax(-x, axis=axis)

Test:

axis=0
x = np.array([[1,0,1], [2, -1, 0], [2, 1, 3]])

sol = compute_localmin(x, axis)
gt = np.array([[False, False, False],
 [False, True, True],
 [False, False, False]])

assert np.array_equal(gt, sol)
Library: librosa==0.8.0 (Python 3.7, released 2020-07)
Additional dependencies: numpy==1.16.0 scipy==1.1.0 soundfile==0.10.2

Problem: Complete the function to locate the local minimas of an array. 

Starting code:
import librosa
import numpy as np

def compute_localmin(x: np.ndarray, axis: int) -> np.ndarray:
    

Solution:


    return librosa.util.localmin(x, axis=axis)

Test:

axis=0
x = np.array([[1,0,1], [2, -1, 0], [2, 1, 3]])

sol = compute_localmin(x, axis)

gt = np.array([[False, False, False],
 [False, True, True],
 [False, False, False]])

assert np.array_equal(gt, sol)
Library: librosa==0.8.0 (Python 3.7, released 2020-07)
Additional dependencies: numpy==1.16.0 scipy==1.1.0 soundfile==0.10.2

Problem: Complete the function to compute the variable-Q transform of an audio signal.

Starting code:
import librosa
import numpy as np
import scipy
from typing import Union, Optional

DTypeLike = Union[np.dtype, type]


def compute_vqt(y: np.ndarray, sr: int) -> np.ndarray:
    

Solution:


    return librosa.vqt(y, sr=sr)

Test:

filename = librosa.util.example_audio_file()
y, sr = librosa.load(filename)

sol = compute_vqt(y, sr)
test_sol = librosa.vqt(y, sr=sr)
assert np.allclose(test_sol, sol)
Library: librosa==0.8.0 (Python 3.7, released 2020-07)
Additional dependencies: numpy==1.16.0 scipy==1.1.0 soundfile==0.10.2

Problem: Complete the function to compute the approximate constant-Q magnitude spectrogram inversion using the “fast” Griffin-Lim algorithm.

Starting code:
import librosa
import numpy as np
import scipy
from typing import Union, Optional

DTypeLike = Union[np.dtype, type]

def compute_griffinlim_cqt(y: np.ndarray, sr: int, C, n_iter: int, hop_length: int, fmin: int, bins_per_octave: int, tuning: float, filter_scale: 1, norm: int, sparsity: float, window: str, scale: bool, pad_mode: str, res_type: str, dtype: DTypeLike, length: Optional[int], momentum: float, init: Optional[str]) -> np.ndarray:
    rng = np.random.RandomState(seed=0)

Solution:


    return librosa.griffinlim_cqt(C, sr=sr, bins_per_octave=bins_per_octave, init=init)

Test:

filename = librosa.util.example_audio_file()
y, sr = librosa.load(filename)
y=y[:10000]

C = np.abs(librosa.cqt(y=y, sr=sr, bins_per_octave=36, n_bins=7*36))
n_iter=32
hop_length=512
fmin=None
bins_per_octave=36
tuning=0.0
filter_scale=1
norm=1
sparsity=0.01
window="hann"
scale=True
pad_mode="reflect"
res_type="kaiser_fast"
dtype=None
length=None
momentum=0.99
init=None
rng = np.random.RandomState(seed=0)
sol = compute_griffinlim_cqt(y, sr, C, n_iter, hop_length, fmin, bins_per_octave, tuning, filter_scale, norm, sparsity, window, scale, pad_mode, res_type, dtype, length, momentum, init)

if fmin is None:
    fmin = librosa.note_to_hz("C1")

angles = np.empty(C.shape, dtype=np.complex64)
if init == "random":
    angles[:] = np.exp(2j * np.pi * rng.rand(*C.shape))
elif init is None:
    angles[:] = 1.0
rebuilt = 0.0

for _ in range(n_iter):
    tprev = rebuilt

    inverse = librosa.constantq.icqt(
    C * angles,
    sr=sr,
    hop_length=hop_length,
    bins_per_octave=bins_per_octave,
    fmin=fmin,
    tuning=tuning,
    filter_scale=filter_scale,
    window=window,
    length=length,
    res_type=res_type,
    )

    rebuilt = librosa.constantq.cqt(
    inverse,
    sr=sr,
    bins_per_octave=bins_per_octave,
    n_bins=C.shape[0],
    hop_length=hop_length,
    fmin=fmin,
    tuning=tuning,
    filter_scale=filter_scale,
    window=window,
    res_type=res_type,
    )
    angles[:] = rebuilt - (momentum / (1 + momentum)) * tprev
    angles[:] /= np.abs(angles) + 1e-16

test_sol = librosa.constantq.icqt(
 C * angles,
 sr=sr,
 hop_length=hop_length,
 bins_per_octave=bins_per_octave,
 tuning=tuning,
 filter_scale=filter_scale,
 fmin=fmin,
 window=window,
 length=length,
 res_type=res_type,
)
assert np.allclose(test_sol, sol)
Library: librosa==0.6.0 (Python 3.7, released 2018-02)
Additional dependencies: numpy==1.16.0 scipy==1.1.0 soundfile==0.10.2

Problem: Complete the function to invert Mel-frequency cepstral coefficients to approximate a Mel power spectrogram.

Starting code:
import librosa
import numpy as np
import scipy

def compute_mfcc_to_mel(mfcc: np.ndarray, n_mels: int=128, dct_type: int=2, norm: str='ortho', ref: float=1.0) -> np.ndarray:
    """
    Invert Mel-frequency cepstral coefficients to approximate a Mel power spectrogram.

    Parameters:
        mfcc (np.ndarray): Mel-frequency cepstral coefficients.
        n_mels (int): Number of Mel bands to generate.
        dct_type (int): Type of DCT to use.
        norm (str): Normalization to use.
        ref: Reference power for (inverse) decibel calculation

    Returns:
        An approximate Mel power spectrum recovered from mfcc.        
    """
    np.random.seed(seed=0)

Solution:


    logmel = scipy.fftpack.idct(mfcc, axis=0, type=dct_type, norm=norm, n=n_mels)
    return librosa.db_to_power(logmel, ref=ref)


Test:
filename = librosa.util.example_audio_file()
y, sr = librosa.load(filename)
mfcc = librosa.feature.mfcc(y=y, sr=sr)

sol =  compute_mfcc_to_mel(mfcc)
def mfcc_to_mel(mfcc, n_mels=128, dct_type=2, norm='ortho', ref=1.0):
    logmel = scipy.fftpack.idct(mfcc, axis=0, type=dct_type, norm=norm, n=n_mels)
    return librosa.db_to_power(logmel, ref=ref)

np.random.seed(seed=0)
test_sol = mfcc_to_mel(mfcc)
assert np.allclose(test_sol, sol)
Library: librosa==0.7.0 (Python 3.7, released 2019-07)
Additional dependencies: numpy==1.16.0 scipy==1.1.0 soundfile==0.10.2

Problem: Complete the function to invert Mel-frequency cepstral coefficients to approximate a Mel power spectrogram.

Starting code:
import librosa
import numpy as np
import scipy

def compute_mfcc_to_mel(mfcc: np.ndarray, n_mels: int=128, dct_type: int=2, norm: str='ortho', ref: float=1.0) -> np.ndarray:
    """
    Invert Mel-frequency cepstral coefficients to approximate a Mel power spectrogram.

    Parameters:
        mfcc (np.ndarray): Mel-frequency cepstral coefficients.
        n_mels (int): Number of Mel bands to generate.
        dct_type (int): Type of DCT to use.
        norm (str): Normalization to use.
        ref: Reference power for (inverse) decibel calculation

    Returns:
        An approximate Mel power spectrum recovered from mfcc.        
    """    
    np.random.seed(seed=0)

Solution:


    return librosa.feature.inverse.mfcc_to_mel(mfcc)

Test:

filename = librosa.util.example_audio_file()
y, sr = librosa.load(filename)
mfcc = librosa.feature.mfcc(y=y, sr=sr)

sol = compute_mfcc_to_mel(mfcc)

np.random.seed(seed=0)
test_sol = librosa.feature.inverse.mfcc_to_mel(mfcc)
assert np.allclose(test_sol, sol)
Library: pillow==7.0.0 (Python 3.7, released 2020-01)
Additional dependencies: numpy==1.16

Problem: Implement the function to superimpose two images on top of each other using the Overlay algorithm.

Starting code:
import numpy as np
from PIL import Image, ImageChops


def imaging(img1: Image, img2: Image) -> Image:
    

Solution:


    def create(imIn1, imIn2, mode=None):
        if imIn1.shape != imIn2.shape:
            return None
        return np.empty_like(imIn1, dtype=np.uint8)

    def imaging_overlay(imIn1, imIn2):
        imOut = create(imIn1, imIn2)
        if imOut is None:
            return None
        
        ysize, xsize, _ = imOut.shape
        for y in range(ysize):
            for x in range(xsize):
                for c in range(3):  # Loop over RGB channels
                    in1, in2 = int(imIn1[y, x, c]), int(imIn2[y, x, c])
                    if in1 < 128:
                        imOut[y, x, c] = np.clip((in1 * in2) // 127, 0, 255)
                    else:
                        imOut[y, x, c] = np.clip(255 - (((255 - in1) * (255 - in2)) // 127), 0, 255)
        
        return imOut

    return imaging_overlay(np.array(img1), np.array(img2))

Test:
def generate_random_image(width, height):
    random_data = np.random.randint(0, 256, (height, width, 3), dtype=np.uint8)
    return Image.fromarray(random_data)

def create(imIn1, imIn2, mode=None):
    if imIn1.shape != imIn2.shape:
        return None
    return np.empty_like(imIn1, dtype=np.uint8)

def imaging_overlay(imIn1, imIn2):
    imOut = create(imIn1, imIn2)
    if imOut is None:
        return None
    
    ysize, xsize, _ = imOut.shape
    for y in range(ysize):
        for x in range(xsize):
            for c in range(3):  # Loop over RGB channels
                in1, in2 = int(imIn1[y, x, c]), int(imIn2[y, x, c])
                if in1 < 128:
                    imOut[y, x, c] = np.clip((in1 * in2) // 127, 0, 255)
                else:
                    imOut[y, x, c] = np.clip(255 - (((255 - in1) * (255 - in2)) // 127), 0, 255)
    
    return imOut

width, height = 256, 256
img1 = generate_random_image(width, height)
img2 = generate_random_image(width, height)
gt = imaging_overlay(np.array(img1), np.array(img2))
sol = imaging(img1, img2)
assert np.allclose(np.array(gt), np.array(sol))
Library: pillow==7.0.0 (Python 3.7, released 2020-01)
Additional dependencies: numpy==1.16

Problem: Implement the function to superimpose two images on top of each other using the Soft Light algorithm.

Starting code:
import numpy as np
from PIL import Image, ImageChops

def imaging(img1: Image, img2: Image) -> Image:
    

Solution:


    def create(imIn1, imIn2, mode=None):
        if imIn1.shape != imIn2.shape:
            return None
        return np.empty_like(imIn1, dtype=np.uint8)

    def imaging_softlight(imIn1, imIn2):
        if imIn1.shape != imIn2.shape:
            return None
        
        imOut = create(imIn1, imIn2)
        ysize, xsize, _ = imOut.shape
        for y in range(ysize):
            for x in range(xsize):
                for c in range(3):  # Loop over RGB channels
                    in1, in2 = int(imIn1[y, x, c]), int(imIn2[y, x, c])
                    imOut[y, x, c] = int((((255 - in1) * (in1 * in2)) // 65536) +  (in1 * (255 - ((255 - in1) * (255 - in2) // 255))) // 255)
        return imOut
    return imaging_softlight(np.array(img1), np.array(img2))

Test:

def generate_random_image(width, height):
    random_data = np.random.randint(0, 256, (height, width, 3), dtype=np.uint8)
    return Image.fromarray(random_data)

def create(imIn1, imIn2, mode=None):
    if imIn1.shape != imIn2.shape:
        return None
    return np.empty_like(imIn1, dtype=np.uint8)

np.random.seed(42)
width, height = 8, 8
img1 = generate_random_image(width, height)
img2 = generate_random_image(width, height)


gt = np.array([
    [[131, 189, 237],
     [ 88, 204, 105],
     [222, 168, 112],
     [  0,  38, 249],
     [ 19, 153, 241],
     [ 54,  68, 251],
     [ 51, 156,  62],
     [177, 203, 188]],

    [[159, 214,  77],
     [154,  36,   8],
     [220, 210,  71],
     [212, 244,  44],
     [180,  35,  33],
     [109, 209,  32],
     [251,   8, 240],
     [234, 106,  40]],

    [[ 41,  89, 223],
     [ 15, 203,  99],
     [101, 139,  38],
     [180, 203, 200],
     [ 87, 251,  87],
     [ 79, 117, 140],
     [233,  99,  50],
     [229, 132,   5]],

    [[152,  29, 109],
     [227, 109, 115],
     [124, 217, 115],
     [  7,  37,   8],
     [ 14, 254,  73],
     [ 15,   0,   0],
     [123, 252, 140],
     [239, 223, 171]],

    [[217, 238,  47],
     [198, 138, 252],
     [ 26, 226,  17],
     [190,  32,  19],
     [128,  14,  18],
     [  0, 173,  34],
     [ 97,  59, 172],
     [189,   0, 254]],

    [[ 16, 193, 247],
     [ 40, 187,  53],
     [ 33, 179, 225],
     [238, 212,  35],
     [ 71, 102, 105],
     [168,  38, 162],
     [115, 132, 250],
     [ 13, 191,   0]],

    [[241, 246, 183],
     [ 50,  45, 121],
     [226,   0,  71],
     [254, 176, 116],
     [205, 166,  42],
     [119,  69,  87],
     [131, 126, 254],
     [ 23, 110,  62]],

    [[157, 196, 191],
     [ 43, 255,  56],
     [238,  15, 188],
     [252, 226,  54],
     [236,   0, 107],
     [248, 209, 210],
     [169,  94,   5],
     [237, 116,  32]]
])
sol = imaging(img1, img2)
assert np.allclose(np.array(gt), np.array(sol))
Library: pillow==7.1.0 (Python 3.7, released 2020-04)
Additional dependencies: numpy==1.16

Problem: Implement the function to superimpose two images on top of each other using the Overlay algorithm.

Starting code:
import numpy as np
from PIL import Image, ImageChops


def imaging(img1: Image, img2: Image) -> Image:
    

Solution:

    return ImageChops.overlay(img1, img2)

Test:

import numpy as np
from PIL import Image, ImageChops

def generate_random_image(width, height):
 random_data = np.random.randint(0, 256, (height, width, 3), dtype=np.uint8)
 return Image.fromarray(random_data)

np.random.seed(42)
width, height = 8, 8
img1 = generate_random_image(width, height)
img2 = generate_random_image(width, height)

gt = np.array([
    [[151, 185, 241],
     [ 86, 216, 120],
     [221, 161, 126],
     [  1,   0, 250],
     [ 20, 159, 242],
     [ 57,  41, 252],
     [ 22, 146,  59],
     [172, 238, 186]],

    [[149, 234,  83],
     [156,  38,   1],
     [225, 252,  50],
     [213, 245,  46],
     [236,  37,  33],
     [106, 211,  22],
     [252,   3, 247],
     [235,  77,  43]],

    [[ 29,  48, 225],
     [ 17, 205, 108],
     [ 69, 160,  13],
     [180, 210, 199],
     [ 65, 253,  71],
     [ 76, 129, 125],
     [235,  64,  13],
     [229, 123,   0]],

    [[154,  20, 125],
     [248,  91,  90],
     [104, 246,  92],
     [  7,  27,   9],
     [  5, 254,  44],
     [ 15,   1,   0],
     [145, 253, 170],
     [240, 227, 168]],

    [[217, 239,  51],
     [197, 127, 253],
     [ 11, 226,  15],
     [186,   0,  10],
     [130,  15,  10],
     [  0, 169,  36],
     [ 62,  63, 168],
     [222,   1, 254]],

    [[ 17, 222, 248],
     [ 40, 205,  48],
     [ 35, 194, 232],
     [246, 211,  18],
     [ 76, 114,  76],
     [178,  41, 205],
     [132, 133, 250],
     [ 12, 188,   1]],

    [[243, 247, 213],
     [  6,  23, 134],
     [226,   1,  77],
     [254, 207, 135],
     [205, 170,  19],
     [108,  74,  81],
     [115, 108, 254],
     [  3, 122,  36]],

    [[153, 193, 197],
     [ 46, 255,  51],
     [239,  16, 183],
     [253, 234,  46],
     [254,   0, 121],
     [249, 209, 209],
     [162,  97,   5],
     [239,  93,  24]]
])

sol = imaging(img1, img2)
assert np.allclose(np.array(gt), np.array(sol))