最邻近插值和线性插值

news2024/10/7 6:40:53

最邻近插值

在图像分割任务中:原图的缩放一般采用双线性插值,用于上采样或下采样;而标注图像的缩放有特定的规则,需使用最临近插值,不用于上采样或下采样。

自定义函数

 这个是通过输入原始图像和一个缩放因子来对图像进行邻近插值:

def nearest_neighbor_interpolation1(image, scale_factor):
    """
    最邻近插值算法
    :paraninput_array
    :输入图像数组:param output_shape
    :输出图像的 shape:return
    :输出图像数组"""
    # 输入图像的宽高
    height, width = image.shape[:2]
    # 计算输出图像的宽高
    out_height = int(height * scale_factor)
    out_width = int(width * scale_factor)

    # 创建输出图像
    output_image = np.zeros((out_height, out_width, 3), dtype = np.uint8)

    # 遍历输出图像的每个像素,分别计算其在输入图像中最近的像素坐标,并将其像素值赋值给当前像素
    for out_y in range(out_height):
        for out_x in range(out_width):
            # 计算当前像素在输入图像中的坐标
            input_x = int(round(out_x / scale_factor))
            input_y = int(round(out_y / scale_factor))
            # 判断计算出来的输入像素坐标是否越界,如果越界则赋值为边界像素
            input_x = min(input_x, width - 1)
            input_y = min(input_y, height - 1)
            # 将输入像素的像素值赋值给输出像素
            output_image[out_y, out_x] = image[input_y, input_x]

    return output_image

  这个是通过输入原始图像和目标图像的高和宽来对图像进行邻近插值:

def nearest_neighbor_interpolation2(image, target_height, target_width):
    """
    Nearest neighbor interpolation algorithm
    :param image: Input image array
    :param target_height: Target height of the output image
    :param target_width: Target width of the output image
    :return: Output image array
    """
    # Input image dimensions
    height, width = image.shape[:2]

    # Create output image
    output_image = np.zeros((target_height, target_width, 3), dtype=np.uint8)

    # Calculate scaling factors
    scale_x = target_width / width
    scale_y = target_height / height

    # Traverse each pixel in the output image, calculate the nearest pixel coordinates in the input image,
    # and assign its pixel value to the current pixel
    for out_y in range(target_height):
        for out_x in range(target_width):
            # Calculate the nearest pixel coordinates in the input image
            input_x = int(round(out_x / scale_x))
            input_y = int(round(out_y / scale_y))
            # Ensure that the calculated input pixel coordinates are within the bounds of the input image
            input_x = min(input_x, width - 1)
            input_y = min(input_y, height - 1)
            # Assign the pixel value of the input pixel to the output pixel
            output_image[out_y, out_x] = image[input_y, input_x]

    return output_image

 使用第二个函数将图像进行可视化:

# 读取图像
image_path = "D:\\My Data\\Figure\\下载.jpg"
image = np.array(Image.open(image_path))

# 目标图像大小
target_height, target_width = 512, 512

# 使用自定义线性插值对图像进行缩放
output_image = nearest_neighbor_interpolation2(image, target_height, target_width)

import matplotlib.pyplot as plt

# 可视化处理后的图像
plt.imshow(output_image)
plt.axis('off')  # 关闭坐标轴
plt.show()

 torch官方定义的函数

 F.interpolate(image_tensor, size=(target_height, target_width), mode='nearest')

from PIL import Image
import torch
import torch.nn.functional as F
import numpy as np
import matplotlib.pyplot as plt

# 读取图像
image_path = "D:\\My Data\\Figure\\下载.jpg"
image = Image.open(image_path)

# 将图像转换为 PyTorch 张量,并添加批量维度
image_tensor = torch.tensor(np.array(image), dtype=torch.float32).permute(2, 0, 1).unsqueeze(0)

# 目标图像大小
target_height, target_width = 512, 512

# 使用最近邻插值对图像进行缩放
output_nearest = F.interpolate(image_tensor, size=(target_height, target_width), mode='nearest')
# 将张量转换回 numpy 数组
output_nearest_array = output_nearest.squeeze().permute(1, 2, 0).numpy().astype(np.uint8)

 将图像进行可视化

# 可视化处理后的图像
plt.imshow(output_nearest_array)
plt.axis('off')  # 关闭坐标轴
plt.show()

 双线性插值

自定义函数

 corner_align=False为不使用角对齐为边对齐,True为使用角对齐,这个是处理灰度图像的双线性插值

import numpy as np
import torch
import torch.nn.functional as F

def bilinear_interpolation(image, out_height, out_width, corner_align=False):
    # 获取输入图像的宽高
    height, width = image.shape[:2]

    # 创建输出图像
    output_image =np.zeros((out_height, out_width), dtype=np.float32)

    # 计算x、y轴缩放因子
    scale_x_corner = float(width - 1) / (out_width - 1)  # (3-1)/(5-1)=0.5
    scale_y_corner = float(height - 1) / (out_height - 1)  # (3-1)/(5-1)=0.5

    scale_x = float(width) / out_width  # 3/5=0.6
    scale_y = float(height) / out_height

    # 遍历输出图像的每个像素,分别计算其在输入图像中最近的四个像素的坐标,然后按照加权值计算当前像素的像素值
    for out_y in range(out_height):
        for out_x in range(out_width):
            if corner_align == True:
                # 计算当前像素在输入图像中的位置
                x = out_x * scale_x_corner
                y = out_y * scale_y_corner
            else:
                x = (out_x + 0.5) * scale_x - 0.5
                y = (out_y + 0.5) * scale_y - 0.5
                x = np.clip(x, 0, width - 1)
                y = np.clip(y, 0, height - 1)

            # 获取当前像素在输入图像中最近的四个像素的坐标
            x0, y0 = int(x), int(y)
            x1, y1 = x0 + 1, y0 + 1

            #对原图像边缘进行特殊处理
            if x0 == width - 1:
                xθ = width - 2
                x1 = width - 1
            if y0 == height - 1:
                yθ = height - 2
                y1 = height - 1

            xd = x - x0
            yd = y - y0
            p00 = image[y0, x0]
            p01 = image[y0, x1]
            p10 = image[y1, x0]
            p11 = image[y1, x1]
            x0y = p01 * xd + (1 - xd) * p00
            x1y = p11 * xd + (1 - xd) * p10
            output_image[out_y, out_x] = x1y * yd + (1 - yd) * x0y

    return output_image

def bilinear_interpolation(image,out_height, out_width, corner_align=False):
    # 获取输入图像的宽高
    height, width = image.shape[:2]

    # 创建输出图像
    output_image =np.zeros((out_height, out_width),dtype=np.float32)

    # 计算x、y轴缩放因子
    scale_x_corner = float(width - 1) / (out_width - 1)  # (3-1)/(5-1)=0.5
    scale_y_corner = float(height - 1) / (out_height - 1)  # (3-1)/(5-1)=0.5

    scale_x = float(width) / out_width  # 3/5=0.6
    scale_y = float(height) / out_height

    # 遍历输出图像的每个像素,分别计算其在输入图像中最近的四个像素的坐标,然后按照加权值计算当前像素的像素值
    for out_y in range(out_height):
        for out_x in range(out_width):
            if corner_align == True:
                # 计算当前像素在输入图像中的位置
                x = out_x * scale_x_corner
                y = out_y * scale_y_corner
            else:
                x =(out_x + 0.5)* scale_x - 0.5
                y =(out_y + 0.5)* scale_y - 0.5
                x = np.clip(x, 0 , width - 1)
                y = np.clip(y, 0 , height - 1)

            # 获取当前像素在输入图像中最近的四个像素的坐标
            x0, y0 = int(x), int(y)
            x1, y1 = x0 + 1, y0 + 1

            #对原图像边缘进行特殊处理
            if x0 == width -1:
                xθ = width - 2
                x1 = width - 1
            if y0 == height -1:
                yθ = height - 2
                y1 = height - 1

            xd = x - x0
            yd = y - y0
            p00 = image[y0, x0]
            p01 = image[y0, x1]
            p10 = image[y1, x0]
            p11 = image[y1, x1]
            x0y = p01 * xd +(1 - xd) * p00
            x1y = p11 * xd +(1 - xd) * p10
            output_image[out_y, out_x] = x1y * yd +(1 - yd) * x0y

    return output_image

我们随机生成一张3×3的图像,与torch中的代码进行比较,查看输出结果:

image_array = np.random.rand(3,3)
image = torch.as_tensor(image_array, dtype=torch.float32).unsqueeze(0).unsqueeze(0)

result = F.interpolate(image, size = (5, 5), mode='bilinear', align_corners=False)
result1 = F.interpolate(image, size = (5, 5), mode='bilinear', align_corners=True)

image = bilinear_interpolation(image_array, 5, 5, corner_align=False)
image1 = bilinear_interpolation(image_array, 5, 5, corner_align=True)

print('image:', image)
print('result:', result)
print('image1:', image1)
print('result1:', result1)

 输出结果对比

image: [[0.8258898  0.82657003 0.8275904  0.6760163  0.5749669 ]
 [0.6941199  0.68340033 0.667321   0.5252699  0.4305692 ]
 [0.49646503 0.46864578 0.42691696 0.29915038 0.21397266]
 [0.4779709  0.5350506  0.62067014 0.63449866 0.64371765]
 [0.46564147 0.57932043 0.74983895 0.8580642  0.9302143 ]]
result: tensor([[[[0.8259, 0.8266, 0.8276, 0.6760, 0.5750],
          [0.6941, 0.6834, 0.6673, 0.5253, 0.4306],
          [0.4965, 0.4686, 0.4269, 0.2992, 0.2140],
          [0.4780, 0.5351, 0.6207, 0.6345, 0.6437],
          [0.4656, 0.5793, 0.7498, 0.8581, 0.9302]]]])
image1: [[0.8258898  0.8267401  0.8275904  0.7012786  0.5749669 ]
 [0.6611774  0.6442155  0.62725365 0.5108617  0.39446977]
 [0.49646503 0.461691   0.42691696 0.3204448  0.21397266]
 [0.48105323 0.5347156  0.58837795 0.5802357  0.5720935 ]
 [0.46564147 0.6077402  0.74983895 0.8400266  0.9302143 ]]
result1: tensor([[[[0.8259, 0.8267, 0.8276, 0.7013, 0.5750],
          [0.6612, 0.6442, 0.6273, 0.5109, 0.3945],
          [0.4965, 0.4617, 0.4269, 0.3204, 0.2140],
          [0.4811, 0.5347, 0.5884, 0.5802, 0.5721],
          [0.4656, 0.6077, 0.7498, 0.8400, 0.9302]]]])

进程已结束,退出代码0
 

 这个是处理彩色图像3通道的双线性插值:不一样的地方为output_image = np.zeros((out_height, out_width, 3), dtype=np.uint8)。

def bilinear_interpolation(image, out_height, out_width, corner_align=False):
    height, width = image.shape[:2]
    output_image = np.zeros((out_height, out_width, 3), dtype=np.uint8)

    scale_x_corner = float(width - 1) / (out_width - 1)
    scale_y_corner = float(height - 1) / (out_height - 1)
    scale_x = float(width) / out_width
    scale_y = float(height) / out_height

    for out_y in range(out_height):
        for out_x in range(out_width):
            if corner_align:
                x = out_x * scale_x_corner
                y = out_y * scale_y_corner
            else:
                x = (out_x + 0.5) * scale_x - 0.5
                y = (out_y + 0.5) * scale_y - 0.5
                x = np.clip(x, 0, width - 1)
                y = np.clip(y, 0, height - 1)

            x0, y0 = int(x), int(y)
            x1, y1 = x0 + 1, y0 + 1
            if x0 == width - 1:
                x1 = width - 1
            if y0 == height - 1:
                y1 = height - 1

            xd = x - x0
            yd = y - y0
            p00 = image[y0, x0]
            p01 = image[y0, x1]
            p10 = image[y1, x0]
            p11 = image[y1, x1]
            x0y = p01 * xd + (1 - xd) * p00
            x1y = p11 * xd + (1 - xd) * p10
            output_image[out_y, out_x] = x1y * yd + (1 - yd) * x0y

    return output_image

  torch官方定义的函数

from PIL import Image
import torch
import torch.nn.functional as F
import numpy as np
import matplotlib.pyplot as plt

# 读取图像
image_path = "D:\\My Data\\Figure\\下载.jpg"
image = Image.open(image_path)

# 将图像转换为 PyTorch 张量,并添加批量维度
image_tensor = torch.tensor(np.array(image), dtype=torch.float32).permute(2, 0, 1).unsqueeze(0)

# 目标图像大小
target_height, target_width = 512, 512


# 使用双线性插值角对齐对图像进行缩放
output_bilinear_corners_True = F.interpolate(image_tensor, size=(target_height, target_width), mode='bilinear', align_corners=True)
# 将张量转换回 numpy 数组
output_bilinear_corners_True_array = output_bilinear_corners_True.squeeze().permute(1, 2, 0).numpy().astype(np.uint8)

# 使用双线性插值边对齐对图像进行缩放
output_bilinear_corners_False = F.interpolate(image_tensor, size=(target_height, target_width), mode='bilinear', align_corners=False)
# 将张量转换回 numpy 数组
output_bilinear_corners_False_array = output_bilinear_corners_False.squeeze().permute(1, 2, 0).numpy().astype(np.uint8)

 将其进行可视化

# 可视化处理后的图像
plt.imshow(output_bilinear_corners_True_array)
plt.axis('off')  # 关闭坐标轴
plt.show()

例子 

自定义函数图像处理

import numpy as np
from PIL import Image
import matplotlib.pyplot as plt
import torch
import torch.nn.functional as F

def bilinear_interpolation(image, out_height, out_width, corner_align=False):
    height, width = image.shape[:2]
    output_image = np.zeros((out_height, out_width, 3), dtype=np.uint8)

    scale_x_corner = float(width - 1) / (out_width - 1)
    scale_y_corner = float(height - 1) / (out_height - 1)
    scale_x = float(width) / out_width
    scale_y = float(height) / out_height

    for out_y in range(out_height):
        for out_x in range(out_width):
            if corner_align:
                x = out_x * scale_x_corner
                y = out_y * scale_y_corner
            else:
                x = (out_x + 0.5) * scale_x - 0.5
                y = (out_y + 0.5) * scale_y - 0.5
                x = np.clip(x, 0, width - 1)
                y = np.clip(y, 0, height - 1)

            x0, y0 = int(x), int(y)
            x1, y1 = x0 + 1, y0 + 1
            if x0 == width - 1:
                x1 = width - 1
            if y0 == height - 1:
                y1 = height - 1

            xd = x - x0
            yd = y - y0
            p00 = image[y0, x0]
            p01 = image[y0, x1]
            p10 = image[y1, x0]
            p11 = image[y1, x1]
            x0y = p01 * xd + (1 - xd) * p00
            x1y = p11 * xd + (1 - xd) * p10
            output_image[out_y, out_x] = x1y * yd + (1 - yd) * x0y

    return output_image


def nearest_neighbor_interpolation(image, scale_factor):
    """
    最邻近插值算法
    :paraninput_array
    :输入图像数组:param output_shape
    :输出图像的 shape:return
    :输出图像数组"""
    # 输入图像的宽高
    height, width = image.shape[:2]
    # 计算输出图像的宽高
    out_height = int(height * scale_factor)
    out_width = int(width * scale_factor)

    # 创建输出图像
    output_image = np.zeros((out_height, out_width, 3), dtype = np.uint8)

    # 遍历输出图像的每个像素,分别计算其在输入图像中最近的像素坐标,并将其像素值赋值给当前像素
    for out_y in range(out_height):
        for out_x in range(out_width):
            # 计算当前像素在输入图像中的坐标
            input_x = int(round(out_x / scale_factor))
            input_y = int(round(out_y / scale_factor))
            # 判断计算出来的输入像素坐标是否越界,如果越界则赋值为边界像素
            input_x = min(input_x, width - 1)
            input_y = min(input_y, height - 1)
            # 将输入像素的像素值赋值给输出像素
            output_image[out_y, out_x] = image[input_y, input_x]

    return output_image




#读取原始图像
input_image = Image.open("D:\My Data\Figure\下载.jpg")
image_array = np.array(input_image)
image_tensor = torch.as_tensor(image_array, dtype=torch.float32)
# 添加批量维度,并将通道维度放在第二个位置
image_tensor = image_tensor.permute(2, 0, 1).unsqueeze(0)  # 转换为 (3, 288, 200) 的张量
#最近邻插值输出缩放后的图像
output_array = nearest_neighbor_interpolation(image_array,1.5)
output_nearest_neighbor_interpolation = Image.fromarray(output_array)


#双线性插值输出缩放后的图像,使用角对齐
output_bilinear_corner_True = bilinear_interpolation(image_array, 512, 512, corner_align=True)
# output_bilinear_corner_True = Image.fromarray(output_bilinear_corner_True)

# output_bilinear_corner_True = F.interpolate(image_tensor, size = (512, 512), mode='bilinear', align_corners=True)
# output_bilinear_corner_True =output_bilinear_corner_True.squeeze().permute(1, 2, 0).numpy().astype(np.uint8)

#双线性插值输出缩放后的图像,使用边对齐
output_bilinear_corner_False = bilinear_interpolation(image_array, 512, 512, corner_align=False)
# output_bilinear_corner_False = Image.fromarray(output_bilinear_corner_False)

# output_bilinear_corner_False = F.interpolate(image_tensor, size = (512, 512), mode='bilinear', align_corners=False)
# output_bilinear_corner_False = output_bilinear_corner_False.squeeze().permute(1, 2, 0).numpy().astype(np.uint8)
print('原始图像 :', image_array.shape )
print('邻近插值 :', output_array.shape )
print('双线性插值角对齐:', output_bilinear_corner_True.shape )
print('双线性插值边对齐 :', output_bilinear_corner_False.shape )

# 设置中文字体
plt.rcParams['font.sans-serif'] = ['SimSun']# 创建一个包含四个子图的画布
# 创建一个包含四个子图的画布
fig, axes = plt.subplots(2, 2)

# 第一张子图:原始图像
axes[0, 0].imshow(input_image)
axes[0, 0].set_title('原始图像')
axes[0, 0].axis('off')

# 第二张子图:插值后的图像
axes[0, 1].imshow(output_nearest_neighbor_interpolation)
axes[0, 1].set_title('邻近插值')
axes[0, 1].axis('off')

# 第三张子图:缩放后的图像
axes[1, 0].imshow(output_bilinear_corner_True)
axes[1, 0].set_title('双线性插值角对齐')
axes[1, 0].axis('off')

# 第四张子图:其他图像(你想添加的图像)
axes[1, 1].imshow(output_bilinear_corner_False)
axes[1, 1].set_title('双线性插值边对齐')
axes[1, 1].axis('off')

# 调整布局,防止标题重叠
plt.tight_layout()

# 展示图像
plt.show()

torch官方函数处理图像对比

from PIL import Image
import torch
import torch.nn.functional as F
import numpy as np
import matplotlib.pyplot as plt

# 读取图像
image_path = "D:\\My Data\\Figure\\下载.jpg"
image = Image.open(image_path)

# 将图像转换为 PyTorch 张量,并添加批量维度
image_tensor = torch.tensor(np.array(image), dtype=torch.float32).permute(2, 0, 1).unsqueeze(0)

# 目标图像大小
target_height, target_width = 512, 512

# 使用最近邻插值对图像进行缩放
output_nearest = F.interpolate(image_tensor, size=(target_height, target_width), mode='nearest')
# 将张量转换回 numpy 数组
output_nearest_array = output_nearest.squeeze().permute(1, 2, 0).numpy().astype(np.uint8)

# 使用双线性插值角对齐对图像进行缩放
output_bilinear_corners_True = F.interpolate(image_tensor, size=(target_height, target_width), mode='bilinear', align_corners=True)
# 将张量转换回 numpy 数组
output_bilinear_corners_True_array = output_bilinear_corners_True.squeeze().permute(1, 2, 0).numpy().astype(np.uint8)

# 使用双线性插值边对齐对图像进行缩放
output_bilinear_corners_False = F.interpolate(image_tensor, size=(target_height, target_width), mode='bilinear', align_corners=False)
# 将张量转换回 numpy 数组
output_bilinear_corners_False_array = output_bilinear_corners_False.squeeze().permute(1, 2, 0).numpy().astype(np.uint8)


print('原始图像:', np.array(image).shape )
print('邻近插值 :', output_nearest_array.shape )
print('双线性插值角对齐 :', output_bilinear_corners_True_array.shape )
print('双线性插值边对齐 :', output_bilinear_corners_False_array .shape )

# 设置中文字体
plt.rcParams['font.sans-serif'] = ['SimSun']# 创建一个包含四个子图的画布
fig, axes = plt.subplots(2, 2)

# 第一张子图:原始图像
axes[0, 0].imshow(image)
axes[0, 0].set_title('原始图像')
axes[0, 0].axis('off')

# 第二张子图:插值后的图像
axes[0, 1].imshow(output_nearest_array)
axes[0, 1].set_title('邻近插值')
axes[0, 1].axis('off')

# 第三张子图:缩放后的图像
axes[1, 0].imshow(output_bilinear_corners_True_array)
axes[1, 0].set_title('双线性插值角对齐')
axes[1, 0].axis('off')

# 第四张子图:其他图像(你想添加的图像)
axes[1, 1].imshow(output_bilinear_corners_False_array)
axes[1, 1].set_title('双线性插值边对齐')
axes[1, 1].axis('off')

# 调整布局,防止标题重叠
plt.tight_layout()

# 展示图像
plt.show()

参考视频:

插值算法 | 最近邻插值法_哔哩哔哩_bilibili

插值算法 |双线性插值法_哔哩哔哩_bilibili

本文来自互联网用户投稿,该文观点仅代表作者本人,不代表本站立场。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如若转载,请注明出处:http://www.coloradmin.cn/o/1611038.html

如若内容造成侵权/违法违规/事实不符,请联系多彩编程网进行投诉反馈,一经查实,立即删除!

相关文章

JVM类加载基本流程及双亲委派模型

1.JVM内存区域划分 一个运行起来的Java进程就是一个JVM虚拟机,这就需要从操作系统中申请一片内存区域。JVM申请到内存之后,会把这个内存划分为几个区域,每个区域都有各自的作用。 一般会把内存划分为四个区域:方法区(也称 "…

力扣287. 寻找重复数

Problem: 287. 寻找重复数 文章目录 题目描述思路解题方法复杂度Code 题目描述 思路 利用二分查找搜索1 ~ n中重复的元素,我们每次取出当前二分查找的区间的中间元素mid并在元始的数组nums中统计小于mid的元素的个数count: 若count > mid则说明重复的…

大数据学习的第三天

文章目录 学习大数据命令的方式查看文件拷贝文件的方式添加数据的方式 出现了问题移动文件 hadoop工作流程和工作机制的方式namenodedatanodesecondarynamenode(主节点) 学习大数据命令的方式 查看文件 hadoop fs -cat /test/2.txt下载文件 hadoop fs -get -f /test/2.txt-f …

通俗说字解词:什么是道理?常说讲道理,李秘书讲写作这节就给你讲“道理”!

通俗说字解词:什么是道理?常说讲道理,李秘书讲写作这节就给你讲“道理”! 说到“道理”,这可真是个有意思的词。它由“道”和“理”两个部分组成,就像一碗好吃的面,有汤有料,缺一不可…

xilinx cpri ip 开发记录

CPRI是无线通信里的一个标准协议,连接REC和RE的通信。 Xilinx有提供CPRI IP核。 区别于其它通信协议,如以太网等,CPRI是一个同步系统。 这就意味着两端的Master和Slave应当是同源时钟的,两边不存在频差,并且内部延时…

ikigai极简3p模型:想、能、有

ikigai模型简化为3p模型: - passion 想要、想做 - professional 能要、能做 - profit 有益、有利 根据三角形不可能定律,三者满足两个就很不容易了。又想做又能做的未必有钱,又能做又有钱的未必想做,又想做又有钱的未必能做。 要实…

(C语言)sscanf 与 sprintf详解

目录 1.sprintf函数详解 2. sscanf函数详解 1.sprintf函数详解 头文件&#xff1a;stdio.h 作用&#xff1a;将格式化的数据写入字符串里&#xff0c;也就是将格式化的数据转变为字符串。 演示&#xff1a; #include <stdio.h> struct S {char name[10];int height;…

LeetCode---128双周赛

题目列表 3110. 字符串的分数 3111. 覆盖所有点的最少矩形数目 3112. 访问消失节点的最少时间 3113. 边界元素是最大值的子数组数目 一、字符串的分数 按照题目要求&#xff0c;直接模拟遍历即可&#xff0c;代码如下 class Solution { public:int scoreOfString(string …

如何通过通过钉钉发送信息????????

1、通过钉钉群添加一个机器人 2、代码实现 /*** 发钉钉审核.** param*/private void sendDingDing(String tableName) {String url "https://oapi.dingtalk.com/robot/send?access_token229c627d05a3157f79a5ef1942d29c4dfb4515bf5c0ad65e3c69423bc016f97c";JSONOb…

达梦数据库的AWR报告

达梦数据库的AWR报告 数据库快照是一个只读的静态的数据库。 DM 快照功能是基于数据库实现的&#xff0c;每个快照是基于数据库的只读镜像。通过检索快照&#xff0c;可以获取源数据库在快照创建时间点的相关数据信息。 为了方便管理自动工作集负载信息库 AWR&#xff08;Auto…

网络编程初步

协议&#xff1a; 一组规则 分层模型结构&#xff1a; OSI七层模型&#xff1a;物、数、网、传、会、表、应 TCP/IP 4层模型&#xff1a;网&#xff08;链路层/网络接口层)、网、传、应 应用层&#xff1a;http、 ftp、 nfs、 ssh、 telneto o .传输层:TCP、UDP 网络层&…

累加(C语言)

一、题目&#xff1b; 二、N-S流程图&#xff1b; 三、运行结果&#xff1b; 四、源代码&#xff1b; # define _CRT_SECURE_NO_WARNINGS # include <stdio.h>int main() {//初始化变量值&#xff1b;int i 0;int j 0;int n 5;int result 0;int sum 0;//运算&#…

笔试强训未触及题目(个人向)

NC398 腐烂的苹果 1.题目 2.解析 这是一个广度优先搜索问题&#xff0c;我们可以先找到所有的烂苹果&#xff0c;把它加入到队列中&#xff0c;然后再同时让这几个苹果向外面腐蚀&#xff0c;我们可以用一个boolean数组来表示是否被腐蚀&#xff0c;也可以直接在原数组中将这…

ThingsBoard通过规则链创建报警信息

什么是规则引擎? 典型实例 1、复制根规则链为报警规则链路 2、拖动Script Filter 规则节点放入链中并配置如下脚本: 3、配置名称为&#xff1a;高温报警&#xff0c;并执行下面的脚本 4、将Script于上一个节点进行关联 5、选择动作里面的create alarm节点信息并放入其中…

解决微信打开文件编辑显示只读状态

微信官网下载地址&#xff1a;微信&#xff0c;是一个生活方式 新版本解决方案&#xff1a; 微信打开文件只读问题终于得到彻底解决了&#xff01;请尽快升级微信 Windows3.9.6 或者微信 mac3.8.1 版本&#xff0c;均新增聊天文件取消只读开关. 旧版本解决方案&#xff1a; …

【笔记】应对Chrome更新导致Chromedriver失效的解决方案:Chrome For Test

随着网络应用和网站的不断发展&#xff0c;自动化测试变得越来越重要&#xff0c;而Selenium成为了许多开发者和测试人员的首选工具之一。然而&#xff0c;对于使用Selenium来进行网站测试的人来说&#xff0c;Chrome浏览器的频繁更新可能会成为一个头疼的问题。每当Chrome更新…

如何在本地服务器部署TeslaMate

文章目录 1.主要参考官方文档2.准备文件&#xff1a;docker-compose.yml3.运行4.成功后4.1 在这个链接&#xff0c;更具提示登录4.2 在这个链接可以看到电池健康和行车数据等 5.后续说明6.进行数据备份6.1 先将数据进行备份&#xff0c;参考链接6.2 数据迁移6.3 下图为我挂该数…

洛谷P1057 [NOIP2008 普及组] 传球游戏

#include<iostream> using namespace std; int n;// n个人传球游戏 默认开始球在编号为1的位置 int m;// 传递m次球 int main(){cin>>n>>m;// 动态转方程&#xff1a;// 球传递到编号为k人的手中// 种类总数 传递到k-1编号种类总数 传递到k1编号种类总数//…

精通代码格式:如何有效管理Python代码行长度

文章目录 1. 问题描述2. 设置文本编辑器的规则2.1 PyCharm 设置2.2 Visual Studio Code 设置 今天写代码遇到一个滑稽的问题&#xff0c;python代码的换行也有规则&#xff0c;于是记录一下 1. 问题描述 在刷LeetCode验证二叉树的时候我写了如下代码&#xff1a; if (not hel…

二分答案复习

y总二分查找算法模板 int bsearch_1(int l, int r) {while (l < r){int mid l r >> 1;//性质在右边&#xff0c;区间划分成[l, mid]和[mid 1, r]if (check(mid)) r mid;else l mid 1;}return l; }int bsearch_2(int l, int r) {while (l < r){int mid l r …