图片相关的基本面试题

1.描述图像大小,通道数?

 长:331 宽:500 通道数:3

2.img[:,:,0]的含义

 0,1,2表示图像的RGB通道

3.

如图的iread设置参数0的含义?

就是读取灰度图像

4.

如何让该图片颜色显示正常?设置cv2.COLOR_BGR2RGB

5.如下代码的效果

# 相似变换 
import cv2
def rotate(img_ori, aug_value, scale):
    '''
    img_ori: 图像
    aug_value:旋转角度
    scale:缩放值
    M :旋转矩阵
    '''
    M = cv2.getRotationMatrix2D((0.5*img_ori.shape[1], 0.5*img_ori.shape[0]), aug_value, scale)
    new_img = cv2.warpAffine(img_ori, M, (img_ori.shape[1], img_ori.shape[0]))
    return new_img

 对图像进行相似变换

6.一下代码的效果


src = np.float32([[50, 50], [200, 50], [50, 200]])
dst = np.float32([[10, 100], [20, 50], [100, 290]])

new_img = Affine(img, src, dst)

def Affine(img_ori, src, dst):
    M = cv2.getAffineTransform(src, dst)
    new_img = cv2.warpAffine(img_ori, M, (img_ori.shape[1], img_ori.shape[0]))
    return new_img

对旧图片进行仿射变换,将原坐标变换为目标坐标

7.以下的代码的作用

%matplotlib inline
#读取图片
img = cv2.imread('Lane_line.jpg',1)
#读取图片大小信息
rows,cols = img.shape[:2] # 848 * 1277

#选取原图中需要被转换物体的四个顶点
#pts1 = np.float32([[100,550],[1200,550],[500,400],[750,400]])
pts1 = np.float32([[0,600],[1277,600],[500,400],[800,400]])

#设置在新图像中原图像的四个顶点的位置
pts2 = np.float32([[0,rows],[cols,rows],[0,0],[cols,0]])

#计算转换M矩阵
M = cv2.getPerspectiveTransform(pts1,pts2)

#应用M矩阵到原图像
dst = cv2.warpPerspective(img,M,(cols,rows))

8.

dst = cv.GaussianBlur(src, ksize, sigmaX[, dst[, sigmaY[, borderType]]])

高斯滤波的ksize越大意味着图像越()?

sigmax是什么?越大导致图像越()? 

9.拉普拉斯滤波法的作用

kernel_strong = np.array([[1,1,1],[1,-8,1],[1,1,1]])

lap_img = cv2.filter2D(img_rgb,-1,kernel_strong)

提取边缘特征

Guess you like

Origin blog.csdn.net/weixin_45955767/article/details/121500673