当前位置: 首页>>代码示例>>Python>>正文


Python cv2.dct方法代码示例

本文整理汇总了Python中cv2.dct方法的典型用法代码示例。如果您正苦于以下问题:Python cv2.dct方法的具体用法?Python cv2.dct怎么用?Python cv2.dct使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在cv2的用法示例。


在下文中一共展示了cv2.dct方法的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: _compute_frame_dct

# 需要导入模块: import cv2 [as 别名]
# 或者: from cv2 import dct [as 别名]
def _compute_frame_dct(data):

    num_frames = data.shape[0]
    num_channels = data.shape[-1]

    dct = np.zeros(shape=data.shape[:-1])

    for i in range(num_frames):
        frame = data[i, :]
        if num_channels == 3:
            gray = cv2.cvtColor(frame, cv2.COLOR_RGB2GRAY)
        else:
            gray = np.squeeze(frame)

        dct[i, :, :] = cv2.dct(gray)

    return dct 
开发者ID:georgesterpu,项目名称:pyVSR,代码行数:19,代码来源:dct.py

示例2: block_get_wm

# 需要导入模块: import cv2 [as 别名]
# 或者: from cv2 import dct [as 别名]
def block_get_wm(self,block,index):
        block_dct = cv2.dct(block)
        block_dct_flatten = block_dct.flatten().copy()
        block_dct_flatten = block_dct_flatten[index]
        block_dct_shuffled = block_dct_flatten.reshape(self.block_shape)

        U,s,V = np.linalg.svd(block_dct_shuffled)
        max_s = s[0]
        wm_1 = 255 if max_s%self.mod >self.mod/2 else 0
        if self.mod2:
            max_s = s[1]
            wm_2 = 255 if max_s%self.mod2 >self.mod2/2 else 0
            wm = (wm_1*3+wm_2*1)/4
        else:
            wm = wm_1
        return wm 
开发者ID:fire-keeper,项目名称:BlindWatermark,代码行数:18,代码来源:BlindWatermark.py

示例3: get_blurness

# 需要导入模块: import cv2 [as 别名]
# 或者: from cv2 import dct [as 别名]
def get_blurness(self, image, block_size=8):
        """Estimate the blurness of an image.
        Args:
            image: image as a numpy array of shape [height, width, channels].
            block_size: the size of the minimal DCT block size.
        Returns:
            a float value represents the blurness.
        """
        # A 2D histogram.
        hist = np.zeros((8, 8), dtype=int)

        # Only the illumination is considered in blur.
        image = cv2.cvtColor(image, cv2.COLOR_BGR2GRAY)

        # Split the image into patches and do DCT on the image patch.
        height, width = image.shape
        round_v = int(height / block_size)
        round_h = int(width / block_size)
        for v in range(round_v):
            for h in range(round_h):
                v_start = v * block_size
                v_end = v_start + block_size
                h_start = h * block_size
                h_end = h_start + block_size

                image_patch = image[v_start:v_end, h_start:h_end]
                image_patch = np.float32(image_patch)
                patch_spectrum = cv2.dct(image_patch)
                patch_none_zero = np.abs(patch_spectrum) > self.dct_threshold
                hist += patch_none_zero.astype(int)

        _blur = hist < self.max_hist * hist[0, 0]
        _blur = (np.multiply(_blur.astype(int), self.hist_weight)).sum()
        return _blur/self.weight_total 
开发者ID:yinguobing,项目名称:image_utility,代码行数:36,代码来源:blur_detector.py

示例4: block_dct_and_idct

# 需要导入模块: import cv2 [as 别名]
# 或者: from cv2 import dct [as 别名]
def block_dct_and_idct(g,QQF):
    T = cv2.dct(g)
    IT = np.round(cv2.idct(np.round(np.round(16.0*T/QQF)*QQF/16)))
    return IT 
开发者ID:HypoX64,项目名称:DeepMosaics,代码行数:6,代码来源:image_processing.py

示例5: block_add_wm

# 需要导入模块: import cv2 [as 别名]
# 或者: from cv2 import dct [as 别名]
def block_add_wm(self,block,index,i):
        
        i = i%(self.wm_shape[0]*self.wm_shape[1])

        wm_1 = self.wm_flatten[i]
        block_dct = cv2.dct(block)
        block_dct_flatten = block_dct.flatten().copy()
        
        block_dct_flatten = block_dct_flatten[index]
        block_dct_shuffled = block_dct_flatten.reshape(self.block_shape)
        U,s,V = np.linalg.svd(block_dct_shuffled)
        max_s = s[0]
        s[0] = (max_s-max_s%self.mod+3/4*self.mod) if wm_1>=128 else (max_s-max_s%self.mod+1/4*self.mod)
        if self.mod2:
            max_s = s[1]
            s[1] = (max_s-max_s%self.mod2+3/4*self.mod2) if wm_1>=128 else (max_s-max_s%self.mod2+1/4*self.mod2)
        # s[1] = (max_s-max_s%self.mod2+3/4*self.mod2) if wm_1<128 else (max_s-max_s%self.mod2+1/4*self.mod2)

        ###np.dot(U[:, :k], np.dot(np.diag(sigma[:k]),v[:k, :]))
        block_dct_shuffled = np.dot(U,np.dot(np.diag(s),V))

        block_dct_flatten = block_dct_shuffled.flatten()
   
        block_dct_flatten[index] = block_dct_flatten.copy()
        block_dct  = block_dct_flatten.reshape(self.block_shape)

        return cv2.idct(block_dct) 
开发者ID:fire-keeper,项目名称:BlindWatermark,代码行数:29,代码来源:BlindWatermark.py

示例6: analyze

# 需要导入模块: import cv2 [as 别名]
# 或者: from cv2 import dct [as 别名]
def analyze(self, images):
        image = images['gray']
        scaled = cv2.resize(image, (self.img_size, self.img_size), interpolation=cv2.INTER_AREA)
        scaled = numpy.float32(scaled)
        dct = cv2.dct(scaled)
        dctlowfreq = dct[:self.hash_size, :self.hash_size]
        med = numpy.median(dctlowfreq)
        diff = dctlowfreq > med
        return numpy.packbits(numpy.uint8(diff.reshape(-1, 1))) 
开发者ID:ReneHollander,项目名称:rep0st,代码行数:11,代码来源:analyze.py

示例7: compute_jpeg_coef

# 需要导入模块: import cv2 [as 别名]
# 或者: from cv2 import dct [as 别名]
def compute_jpeg_coef(image): 

	height = image.shape[1]
	width = image.shape[0]
	nb_channels = image.shape[2]
	result = np.zeros([8*int(width/8), 8*int(height/8), nb_channels], dtype = np.float32)

	for c in range(nb_channels):
		for i in range(int(width/8)):
			for j in range(int(height/8)): 
				result[8*i:8*(i+1), 8*j:8*(j+1), c] = np.round(cv2.dct(np.float32((image[8*i:8*(i+1), 8*j:8*(j+1), c])-128)))
				# print(np.max(result[8*i:8*(i+1), 8*j:8*(j+1), c]))
	return(result) 
开发者ID:NicoRahm,项目名称:CGvsPhoto,代码行数:15,代码来源:lbp.py


注:本文中的cv2.dct方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。